]> git.pld-linux.org Git - projects/rc-scripts.git/blob - rc.d/init.d/random
81af963c8c9dce718c9d2bad67f4e67c4272d7aa
[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: random,v 1.5 1999/12/02 10:38:55 kloczek Exp $
11
12 # NLS
13 NLS_DOMAIN="rc-scripts"
14
15 # Source function library.
16 . /etc/rc.d/init.d/functions
17
18 random_seed=/var/run/random-seed
19
20 # See how we were called.
21 case "$1" in
22   start)
23         show "Initializing random number generator"
24         busy
25         # Carry a random seed from start-up to start-up
26         # Load and then save 512 bytes, which is the size of the entropy pool
27         if [ -f $random_seed ]; then
28                 cat $random_seed >/dev/urandom
29         else
30                 touch $random_seed
31         fi
32         chmod 600 $random_seed
33         dd if=/dev/urandom of=$random_seed count=1 bs=512 2>/dev/null
34         touch /var/lock/subsys/random
35         deltext
36         ok
37         ;;
38   stop)
39         # Carry a random seed from shut-down to start-up
40         # Save 512 bytes, which is the size of the entropy pool
41         show "Saving random seed"
42         busy
43         touch $random_seed
44         chmod 600 $random_seed
45         dd if=/dev/urandom of=$random_seed count=1 bs=512 2>/dev/null
46         
47         rm -f /var/lock/subsys/random
48         deltext
49         ok
50         ;;
51   status)
52         # this is way overkill, but at least we have some status output...
53         if [ -c /dev/random ] ; then
54                 nls "The random data source exists"
55         else
56                 nls "The random data source is missing"
57         fi
58         ;;
59   restart|reload)
60         # do not do anything; this is unreasonable
61         :
62         ;;
63   *)
64         # do not advertise unreasonable commands that there is no reason
65         # to use with this device
66         echo "Usage: random {start|stop|status|restart|reload}"
67         exit 1
68 esac
69
70 exit 0
This page took 0.023946 seconds and 2 git commands to generate.