]> git.pld-linux.org Git - projects/rc-scripts.git/blob - rc.d/init.d/random
- comment says do not, so won't!
[projects/rc-scripts.git] / rc.d / init.d / random
1 #!/bin/sh
2 #
3 # random        Script to snapshot random state and reload it at boot time.
4 #
5 # chkconfig:    12345 20 80
6 #
7 # description:  Saves and restores system entropy pool for higher quality \
8 #               random number generation.
9 #
10 # $Id$
11
12 # Source function library.
13 . /etc/rc.d/init.d/functions
14
15 random_seed=/var/run/random-seed
16
17 # See how we were called.
18 case "$1" in
19   start)
20         show "Initializing random number generator"
21         busy
22         # Carry a random seed from start-up to start-up
23         # Load and then save 512 bytes, which is the size of the entropy pool
24         if [ -f $random_seed ]; then
25                 cat $random_seed >/dev/urandom
26         else
27                 touch $random_seed
28         fi
29         chmod 600 $random_seed
30         dd if=/dev/urandom of=$random_seed count=1 bs=512 2>/dev/null
31         touch /var/lock/subsys/random
32         deltext
33         ok
34         ;;
35   stop)
36         # Carry a random seed from shut-down to start-up
37         # Save 512 bytes, which is the size of the entropy pool
38         show "Saving random seed"
39         busy
40         touch $random_seed
41         chmod 600 $random_seed
42         dd if=/dev/urandom of=$random_seed count=1 bs=512 2>/dev/null
43
44         rm -f /var/lock/subsys/random
45         deltext
46         ok
47         ;;
48   status)
49         # this is way overkill, but at least we have some status output...
50         if [ -c /dev/random ] ; then
51                 nls "The random data source exists"
52         else
53                 nls "The random data source is missing"
54         fi
55         ;;
56   restart|reload)
57         # do not do anything; this is unreasonable
58         :
59         ;;
60   *)
61         # do not advertise unreasonable commands that there is no reason
62         # to use with this device
63         msg_usage "$0 {start|stop|status}"
64         exit 3
65 esac
66
67 exit 0
This page took 0.073718 seconds and 3 git commands to generate.