50 lines
1.2 KiB
Plaintext
50 lines
1.2 KiB
Plaintext
|
#!/bin/sh
|
||
|
# random - save system entropy pool at shutdown and reload it at boot time
|
||
|
# to increase the quality of random number generation
|
||
|
|
||
|
[ -c /dev/urandom ] || exit 0
|
||
|
|
||
|
. /etc/sysconfig/rc
|
||
|
. $rc_functions
|
||
|
|
||
|
PATH=/sbin:/usr/sbin:/bin:/usr/bin
|
||
|
|
||
|
RANDOMSEED=/var/lib/misc/random-seed
|
||
|
POOLSIZE=512
|
||
|
[ -r /proc/sys/kernel/random/poolsize ] && POOLSIZE="$(cat /proc/sys/kernel/random/poolsize)"
|
||
|
|
||
|
case "$1" in
|
||
|
start)
|
||
|
echo -n $"Initializing random number generator: "
|
||
|
if [ -f $RANDOMSEED ]; then
|
||
|
cat $RANDOMSEED > /dev/urandom
|
||
|
else
|
||
|
touch $RANDOMSEED
|
||
|
fi
|
||
|
chmod 600 $RANDOMSEED
|
||
|
dd if=/dev/urandom of=$RANDOMSEED count=1 bs=$POOLSIZE >/dev/null 2>&1
|
||
|
evaluate_retval
|
||
|
echo
|
||
|
;;
|
||
|
stop)
|
||
|
echo -n $"Saving random seed: "
|
||
|
touch $RANDOMSEED
|
||
|
chmod 600 $RANDOMSEED
|
||
|
dd if=/dev/urandom of=$RANDOMSEED count=1 bs=$POOLSIZE >/dev/null 2>&1
|
||
|
evaluate_retval
|
||
|
echo
|
||
|
;;
|
||
|
status)
|
||
|
echo -n $"Checking for random generator: "
|
||
|
echo_success
|
||
|
echo
|
||
|
;;
|
||
|
restart|reload|force-reload)
|
||
|
echo "Error: argument '$1' not supported" >&2
|
||
|
exit 3
|
||
|
;;
|
||
|
*) echo "Usage: $0 start|stop|status"
|
||
|
exit 1
|
||
|
;;
|
||
|
esac
|