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