xref: /OK3568_Linux_fs/buildroot/package/htpdate/S43htpdate (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1#!/bin/sh
2
3DAEMON="htpdate"
4PIDFILE="/var/run/$DAEMON.pid"
5
6HTPDATE_ARGS="-a -s -t https://google.com"
7test -r "/etc/default/$DAEMON" && . "/etc/default/$DAEMON"
8
9start() {
10	printf 'Starting %s: ' "$DAEMON"
11	# shellcheck disable=SC2086 # we need the word splitting
12	start-stop-daemon -S -q -x "/usr/bin/$DAEMON" \
13		-- -D -i "$PIDFILE" $HTPDATE_ARGS
14	status=$?
15	if [ "$status" -eq 0 ]; then
16		echo "OK"
17	else
18		echo "FAIL"
19	fi
20	return "$status"
21}
22
23stop() {
24	printf 'Stopping %s: ' "$DAEMON"
25	start-stop-daemon -K -q -p "$PIDFILE"
26	status=$?
27	if [ "$status" -eq 0 ]; then
28		rm -f "$PIDFILE"
29		echo "OK"
30	else
31		echo "FAIL"
32	fi
33	return "$status"
34}
35
36restart() {
37	stop
38	sleep 1
39	start
40}
41
42case "$1" in
43	start|stop|restart)
44		"$1";;
45	reload)
46		# Restart, since there is no true "reload" feature.
47		restart;;
48	*)
49		echo "Usage: $0 {start|stop|restart|reload}"
50		exit 1
51esac
52