hc
2023-11-20 2e7bd41e4e8ab3d1efdabd9e263a2f7fe79bff8c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/sh
 
NAME="rngd"
DAEMON="/usr/sbin/${NAME}"
DAEMON_ARGS=""
CFG_FILE="/etc/default/${NAME}"
PID_FILE="/var/run/${NAME}.pid"
 
# Read configuration variable file if it is present
[ -r "${CFG_FILE}" ] && . "${CFG_FILE}"
 
start()
{
   printf "Starting ${NAME}: "
   start-stop-daemon -S -q -x "${DAEMON}" -- ${DAEMON_ARGS}
   [ $? = 0 ] && echo "OK" || echo "FAIL"
}
 
stop()
{
   printf "Stopping ${NAME}: "
   # This daemon does not exit properly with the default TERM signal unless
   # it's forced to work by something reading /dev/random. Killing it and
   # removing its PID file is more straightforward.
   if start-stop-daemon -K -q -s KILL -p "${PID_FILE}" -n "${NAME}"; then
       rm -f "${PID_FILE}"
       echo "OK"
   else
       echo "FAIL"
   fi
}
 
case "$1" in
   start)
       start
       ;;
   stop)
       stop
       ;;
   restart|reload)
       stop
       start
       ;;
   *)
       echo "Usage: $0 {start|stop|restart|reload}" >&2
       exit 1
       ;;
esac