rngd: update initskript and add hwrngtty support
[ipfire-2.x.git] / src / initscripts / system / rngd
1 #!/bin/sh
2 ########################################################################
3 # Begin $rc_base/init.d/rngd
4 #
5 # Description : Random Number Generator Daemon
6 #
7 # Authors     : Michael Tremer <michael.tremer@ipfire.org>
8 #
9 ########################################################################
10
11 . /etc/sysconfig/rc
12 . ${rc_functions}
13
14 case "${1}" in
15         start)
16                 if pidofproc -s /usr/sbin/rngd; then
17                         boot_mesg "Random Number Generator Daemon is already running..."
18                         echo_ok;
19                         exit 0
20                 fi
21                 if [ -e /dev/hwrngtty ]; then
22                         HWRNG=/dev/hwrngtty
23                 else
24                         HWRNG=/dev/hwrng
25                 fi
26                 boot_mesg "Starting Random Number Generator Daemon..."
27                 loadproc /usr/sbin/rngd -r $HWRNG --quiet
28                 ;;
29
30         stop)
31                 boot_mesg "Stopping Random Number Generator Daemon..."
32                 killproc -p /var/run/rngd.pid /usr/sbin/rngd
33                 ;;
34
35         restart)
36                 ${0} stop
37                 sleep 1
38                 ${0} start
39                 ;;
40
41         status)
42                 statusproc /usr/sbin/rngd
43                 ;;
44
45         udev-event)
46                 $0 restart &>/dev/null
47                 ;;
48
49         *)
50                 echo "Usage: ${0} {start|stop|restart|status}"
51                 exit 1
52                 ;;
53 esac
54
55 # End $rc_base/init.d/rngd