aboutsummaryrefslogtreecommitdiff
path: root/init.d/urandom
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2008-01-11 12:13:46 +0000
committerRoy Marples <roy@marples.name>2008-01-11 12:13:46 +0000
commit3bf49a9bd19d5bbcf6976dd42b4f87f1b173e287 (patch)
tree8b4d6121f0d4b921566eeec2844c9bf76131de78 /init.d/urandom
parent1f4422c72f968405a0b8bf56d4f9c3b619b1b80d (diff)
Adopt a more C style for scripts and remove vim settings.
Diffstat (limited to 'init.d/urandom')
-rwxr-xr-xinit.d/urandom20
1 files changed, 11 insertions, 9 deletions
diff --git a/init.d/urandom b/init.d/urandom
index 9e2632fd..f6585deb 100755
--- a/init.d/urandom
+++ b/init.d/urandom
@@ -6,24 +6,27 @@ urandom_seed=${urandom_seed:-${URANDOM_SEED:-/var/run/random-seed}}
description="Initializes the random number generator."
-depend() {
+depend()
+{
need localmount
}
-save_seed() {
- local poolsize=1
+save_seed()
+{
+ local psz=1
if [ -e /proc/sys/kernel/random/poolsize ]; then
- poolsize=$(($(cat /proc/sys/kernel/random/poolsize) / 4096))
+ psz=$(($(cat /proc/sys/kernel/random/poolsize) / 4096))
fi
( # sub shell to prevent umask pollution
umask 077
- dd if=/dev/urandom of="${urandom_seed}" count=${poolsize} 2>/dev/null
+ dd if=/dev/urandom of="${urandom_seed}" count=${psz} 2>/dev/null
)
}
-start() {
+start()
+{
[ -c /dev/urandom ] || return
if [ -f "${urandom_seed}" ]; then
ebegin "Initializing random number generator"
@@ -34,10 +37,9 @@ start() {
return 0
}
-stop() {
+stop()
+{
ebegin "Saving random seed"
save_seed
eend $? "Failed to save random seed"
}
-
-# vim: set ts=4 :