Files
buildroot/package/chrony/S49chronyd
Fiona Klute (WIWA) 01177dcc81 package/chrony: rewrite start script
This patch brings package/chrony/S49chronyd in line with the start
script standards. Note that users will need to update the location of
any script config from /etc/default/chrony to /etc/default/chronyd.

One deviation from the standard remains (and thus the check-package
override): The PID file is placed in /var/run/chrony/$DAEMON.pid. This
is necessary because chronyd drops privileges, and would not be able
to delete the PID file from root-owned /var/run on shutdown.

Signed-off-by: Fiona Klute (WIWA) <fiona.klute@gmx.de>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2024-10-29 21:23:35 +01:00

66 lines
1.0 KiB
Bash

#!/bin/sh
#
# Start chrony
DAEMON="chronyd"
# /var/run/chrony is owned by the chrony user, this allows chrony to
# delete the PID file during shutdown, long after dropping privileges.
PIDFILE="/var/run/chrony/$DAEMON.pid"
CHRONY_ARGS=""
# shellcheck source=/dev/null
[ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON"
start() {
printf "Starting %s: " "$DAEMON"
# shellcheck disable=SC2086 # we need the word splitting
start-stop-daemon --start --pidfile "$PIDFILE" \
--exec "/usr/sbin/$DAEMON" \
-- $CHRONY_ARGS
status=$?
if [ "$status" -eq 0 ]; then
echo "OK"
else
echo "FAIL"
fi
return "$status"
}
stop() {
printf "Stopping %s: " "$DAEMON"
start-stop-daemon --stop --pidfile "$PIDFILE" \
--exec "/usr/sbin/$DAEMON"
status=$?
if [ "$status" -eq 0 ]; then
echo "OK"
else
echo "FAIL"
fi
while [ -f "$PIDFILE" ]; do
sleep 0.1
done
return "$status"
}
restart() {
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac
exit $?