blob: 686c80cc9fb5aa4ae58dada87df4e52986e5a7b3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
#!/bin/sh
#
# random Script to snapshot random state and reload it at boot time.
#
# Author: Theodore Ts'o <tytso@mit.edu>
#
# chkconfig: 2345 20 80
# description: Saves and restores system entropy pool for higher quality \
# random number generation.
random_seed=/var/run/random-seed
# See how we were called.
case "$1" in
start)
echo "Initializing random number generator..."
# Carry a random seed from start-up to start-up
# Load and then save 512 bytes, which is the size of the entropy pool
if [ -f $random_seed ]; then
cat $random_seed >/dev/urandom
else
touch $random_seed
fi
chmod 600 $random_seed
dd if=/dev/urandom of=$random_seed count=1 bs=512 2>/dev/null
touch /var/lock/subsys/random
;;
stop)
# Carry a random seed from shut-down to start-up
# Save 512 bytes, which is the size of the entropy pool
echo "Saving random seed..."
touch $random_seed
chmod 600 $random_seed
dd if=/dev/urandom of=$random_seed count=1 bs=512 2>/dev/null
rm -f /var/lock/subsys/random
;;
status)
status random
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: random {start|stop|restart|status}"
exit 1
esac
exit 0
|