mirror of
https://gitlab.com/buildroot.org/buildroot.git
synced 2026-09-30 22:11:59 -09:00
package/ntp: base sysv script on current template
Signed-off-by: Simon Rowe <simon.rowe@citrix.com> Tested-by: Carlos Santos <unixmania@gmail.com> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
This commit is contained in:
committed by
Thomas Petazzoni
parent
dfb0567f6e
commit
34a556a95d
@@ -1,34 +1,56 @@
|
|||||||
#! /bin/sh
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# Starts Network Time Protocol daemon
|
||||||
|
#
|
||||||
|
|
||||||
NAME=ntpd
|
DAEMON="ntpd"
|
||||||
|
PIDFILE="/var/run/$DAEMON.pid"
|
||||||
|
|
||||||
# Read config file if it is present.
|
NTPD_ARGS="-g"
|
||||||
if [ -r /etc/default/$NAME ]
|
|
||||||
then
|
# shellcheck source=/dev/null
|
||||||
. /etc/default/$NAME
|
[ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON"
|
||||||
fi
|
|
||||||
|
start() {
|
||||||
|
printf 'Starting %s: ' "$DAEMON"
|
||||||
|
# shellcheck disable=SC2086 # we need the word splitting
|
||||||
|
start-stop-daemon -S -q -p "$PIDFILE" -x "/usr/sbin/$DAEMON" \
|
||||||
|
-- $NTPD_ARGS -p "$PIDFILE"
|
||||||
|
status=$?
|
||||||
|
if [ "$status" -eq 0 ]; then
|
||||||
|
echo "OK"
|
||||||
|
else
|
||||||
|
echo "FAIL"
|
||||||
|
fi
|
||||||
|
return "$status"
|
||||||
|
}
|
||||||
|
|
||||||
|
stop() {
|
||||||
|
printf 'Stopping %s: ' "$DAEMON"
|
||||||
|
start-stop-daemon -K -q -p "$PIDFILE"
|
||||||
|
status=$?
|
||||||
|
if [ "$status" -eq 0 ]; then
|
||||||
|
rm -f "$PIDFILE"
|
||||||
|
echo "OK"
|
||||||
|
else
|
||||||
|
echo "FAIL"
|
||||||
|
fi
|
||||||
|
return "$status"
|
||||||
|
}
|
||||||
|
|
||||||
|
restart() {
|
||||||
|
stop
|
||||||
|
sleep 1
|
||||||
|
start
|
||||||
|
}
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start|stop|restart)
|
||||||
printf "Starting $NAME: "
|
"$1";;
|
||||||
start-stop-daemon -S -q -x /usr/sbin/ntpd -- -g
|
reload)
|
||||||
[ $? = 0 ] && echo "OK" || echo "FAIL"
|
# Restart, since there is no true "reload" feature.
|
||||||
;;
|
restart;;
|
||||||
stop)
|
*)
|
||||||
printf "Stopping $NAME: "
|
echo "Usage: $0 {start|stop|restart|reload}"
|
||||||
start-stop-daemon -K -q -n $NAME
|
exit 1
|
||||||
[ $? = 0 ] && echo "OK" || echo "FAIL"
|
|
||||||
;;
|
|
||||||
restart|reload)
|
|
||||||
echo "Restarting $NAME: "
|
|
||||||
$0 stop
|
|
||||||
sleep 1
|
|
||||||
$0 start
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Usage: $0 {start|stop|restart|reload}" >&2
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
exit 0
|
|
||||||
|
|||||||
Reference in New Issue
Block a user