#!/bin/sh
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin

. /usr/share/runit/scripts/runit-functions.sh
. /etc/runit/config/system.conf

SERVICE1=random-seed

load_service(){
    cp /var/lib/random-seed /dev/urandom >/dev/null 2>&1 || true
    ( umask 077; bytes=$(cat /proc/sys/kernel/random/poolsize) || bytes=512; dd if=/dev/urandom of=/var/lib/random-seed count=1 bs=$bytes >/dev/null 2>&1 )
}

unload_service(){
    ( umask 077; bytes=$(cat /proc/sys/kernel/random/poolsize) || bytes=512; dd if=/dev/urandom of=/var/lib/random-seed count=1 bs=$bytes >/dev/null 2>&1 )
}

#~ # MAIN START
#~ stat_busy "Starting $SERVICE1"
#~ load_service || stat_die $SERVICE1
#~ add_daemon $SERVICE1
#~ stat_done $SERVICE1

# MAIN STOP
stat_busy "Stopping $SERVICE1"
unload_service || stat_die $SERVICE1
rm_daemon $SERVICE1
stat_done $SERVICE1
