source: projects/initscripts/tags/initscripts-8.91.3/rc.d/init.d/random @ 1108

Revision 1108, 1.5 KB checked in by daisuke, 14 years ago (diff)

import initscripts-8.90.6 from internal cvs repository

Line 
1#!/bin/bash
2#
3# random        Script to snapshot random state and reload it at boot time.
4#
5# Author:       Theodore Ts'o <tytso@mit.edu>
6#
7# chkconfig: 2345 20 80
8# description: Saves and restores system entropy pool for higher quality \
9#              random number generation.
10
11# Source function library.
12. /etc/init.d/functions
13
14random_seed=/var/lib/random-seed
15
16# See how we were called.
17case "$1" in
18  start)
19        # Carry a random seed from start-up to start-up
20        # Load and then save 512 bytes, which is the size of the entropy pool
21        if [ -f $random_seed ]; then
22                cat $random_seed >/dev/urandom
23        else
24                touch $random_seed
25        fi
26        action $"Initializing random number generator: " /bin/true
27        chmod 600 $random_seed
28        dd if=/dev/urandom of=$random_seed count=1 bs=512 2>/dev/null
29        touch /var/lock/subsys/random
30
31        ;;
32  stop)
33        # Carry a random seed from shut-down to start-up
34        # Save 512 bytes, which is the size of the entropy pool
35        touch $random_seed
36        chmod 600 $random_seed
37        action $"Saving random seed: " dd if=/dev/urandom of=$random_seed count=1 bs=512 2>/dev/null
38       
39        rm -f /var/lock/subsys/random
40        ;;
41  status)
42        # this is way overkill, but at least we have some status output...
43        if [ -c /dev/random ] ; then
44                echo $"The random data source exists"
45        else
46                echo $"The random data source is missing"
47        fi
48        ;;
49  restart|reload)
50        # do not do anything; this is unreasonable
51        :
52        ;;
53  *)
54        # do not advertise unreasonable commands that there is no reason
55        # to use with this device
56        echo $"Usage: $0 {start|stop|status|restart|reload}"
57        exit 1
58esac
59
60exit 0
61
Note: See TracBrowser for help on using the repository browser.