]>
Commit | Line | Data |
---|---|---|
8af8d5d1 MT |
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 | ||
2af81793 MT |
14 | function has_rdrand() { |
15 | grep -q "rdrand" /proc/cpuinfo | |
16 | } | |
17 | ||
18 | function has_hwrng() { | |
19 | [ -e "/dev/hwrng" ] | |
20 | } | |
21 | ||
8af8d5d1 MT |
22 | case "${1}" in |
23 | start) | |
2af81793 MT |
24 | if ! has_hwrng && ! has_rdrand; then |
25 | boot_mesg "No Hardware Random Number Generator found..." | |
8af8d5d1 MT |
26 | echo_warning |
27 | exit 0 | |
28 | fi | |
29 | ||
30 | boot_mesg "Starting Random Number Generator Daemon..." | |
bc70c827 MT |
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 | |
8af8d5d1 MT |
38 | ;; |
39 | ||
40 | stop) | |
41 | boot_mesg "Stopping Random Number Generator Daemon..." | |
bc70c827 | 42 | killproc -p /var/run/rngd.pid /usr/sbin/rngd |
8af8d5d1 MT |
43 | ;; |
44 | ||
45 | restart) | |
46 | ${0} stop | |
47 | sleep 1 | |
48 | ${0} start | |
49 | ;; | |
50 | ||
51 | status) | |
52 | statusproc /usr/sbin/rngd | |
53 | ;; | |
54 | ||
2af81793 MT |
55 | udev-event) |
56 | $0 restart &>/dev/null | |
57 | ;; | |
58 | ||
8af8d5d1 MT |
59 | *) |
60 | echo "Usage: ${0} {start|stop|restart|status}" | |
61 | exit 1 | |
62 | ;; | |
63 | esac | |
64 | ||
65 | # End $rc_base/init.d/rngd |