27b8d0ba8c
- set 'CC="$(HOSTCC)"' to avoid cross-compile failure (see [1]): /bin/sh: line 1: .../build/ntpsec-1_2_0/build/host/ntpd/keyword-gen: cannot execute binary file: Exec format error Waf: Leaving directory `.../build/ntpsec-1_2_0/build/host' Build failed -> task in 'ntp_keyword.h' failed with exit status 126 (run with -v to display more information) - set '-std=gnu99"' to avoid compile failure with old compilers - explicitly set PYTHON_CONFIG - add patch 001-ntptime-fix-jfmt5-ofmt5-jfmt6-ofmt6-related-compile-.patch to fix ntptime jfmt5/ofmt5 jfmt6/ofmt6 related compile failure - add patch 0002-wscript-remove-checks-for-bsd-string.h-fixes-host-co.patch to fix host-compile failure in case target libbsd is detected - add SYSV init file (S49ntp) - add example ntpd.conf (with legacy option enabled and provide skeleton for NTS configuration) - add config option for NTS support - add ntp user/group and run ntpd as restricted user - add libcap dependency (compile time optional but needed for droproot support) [1] https://gitlab.com/NTPsec/ntpsec/-/issues/694 Signed-off-by: Peter Seiderer <ps.report@gmx.net> [Thomas: S49ntp -> S49ntpd] Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
59 lines
997 B
Bash
59 lines
997 B
Bash
#!/bin/sh
|
|
#
|
|
# Starts Network Time Protocol daemon
|
|
#
|
|
|
|
DAEMON="ntpd"
|
|
PIDFILE="/var/run/$DAEMON.pid"
|
|
|
|
NTPD_ARGS="-g -u ntp:ntp -s /var/run/ntp"
|
|
|
|
# shellcheck source=/dev/null
|
|
[ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON"
|
|
|
|
mkdir -p /var/run/ntp && chown ntp:ntp /var/run/ntp
|
|
|
|
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
|
|
start|stop|restart)
|
|
"$1";;
|
|
reload)
|
|
# Restart, since there is no true "reload" feature.
|
|
restart;;
|
|
*)
|
|
echo "Usage: $0 {start|stop|restart|reload}"
|
|
exit 1
|
|
esac
|