]> git.ipfire.org Git - ipfire-2.x.git/blob - src/initscripts/system/rngd
Merge branch 'next'
[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 function has_rdrand() {
15 grep -q "rdrand" /proc/cpuinfo
16 }
17
18 function has_hwrng() {
19 [ -e "/dev/hwrng" ]
20 }
21
22 case "${1}" in
23 start)
24 if ! has_hwrng && ! has_rdrand; then
25 boot_mesg "No Hardware Random Number Generator found..."
26 echo_warning
27 exit 0
28 fi
29
30 boot_mesg "Starting Random Number Generator Daemon..."
31
32 if pidofproc /usr/sbin/rngd &>/dev/null; then
33 # Is already running.
34 echo_ok
35 else
36 loadproc /usr/sbin/rngd --no-tpm=1
37 fi
38 ;;
39
40 stop)
41 boot_mesg "Stopping Random Number Generator Daemon..."
42 killproc -p /var/run/rngd.pid /usr/sbin/rngd
43 ;;
44
45 restart)
46 ${0} stop
47 sleep 1
48 ${0} start
49 ;;
50
51 status)
52 statusproc /usr/sbin/rngd
53 ;;
54
55 udev-event)
56 $0 restart &>/dev/null
57 ;;
58
59 *)
60 echo "Usage: ${0} {start|stop|restart|status}"
61 exit 1
62 ;;
63 esac
64
65 # End $rc_base/init.d/rngd