/[baselayout]/trunk/init.d/urandom
Gentoo

Contents of /trunk/init.d/urandom

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2763 - (show annotations) (download)
Tue Jul 10 19:09:41 2007 UTC (7 years, 1 month ago) by uberlord
File size: 1108 byte(s)
init scripts and their extra options can now have descriptions, #184327.
1 #!/sbin/runscript
2 # Copyright 1999-2007 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License v2
4
5 URANDOM_SEED=${URANDOM_SEED:-/var/run/random-seed}
6
7 description="Initializes the random number generator."
8
9 depend() {
10 need localmount
11 }
12
13 save_seed() {
14 local poolsize=1
15
16 if [ -e /proc/sys/kernel/random/poolsize ] ; then
17 poolsize=$(($(cat /proc/sys/kernel/random/poolsize) / 4096))
18 fi
19
20 ( # sub shell to prevent umask pollution
21 umask 077
22 dd if=/dev/urandom of="${URANDOM_SEED}" count=${poolsize} 2>/dev/null
23 )
24 }
25
26 start() {
27 [ -c /dev/urandom ] || return
28 if [ -f "${URANDOM_SEED}" ] ; then
29 cat "${URANDOM_SEED}" > /dev/urandom
30 fi
31 if ! rm -f "${URANDOM_SEED}" ; then
32 ewarn "Skipping ${URANDOM_SEED} initialization (ro root?)"
33 return 0
34 fi
35 ebegin "Initializing random number generator"
36 save_seed
37 eend $? "Error initializing random number generator"
38 }
39
40 stop() {
41 ebegin "Saving random seed"
42 # Carry a random seed from shut-down to start-up;
43 # see documentation in linux/drivers/char/random.c
44 save_seed
45 eend $? "Failed to save random seed"
46 }
47
48 # vim: set ts=4 :

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.20