![Heiko Thiery](/assets/img/avatar_default.png)
The "package/busybox/S01sysklogd" is taken as template to change the init script of the linuxptp daemon. The init script is split two parts because there are 2 daemons (ptp4l and phc2sys). Let the user supply its own options in /etc/default/ptp4l and /etc/default/phc2sys. This patch also fixes an issue with the creation of the pid file that is needed to properly stop the daemon again. Signed-off-by: Michael Walle <michael@walle.cc> Signed-off-by: Heiko Thiery <heiko.thiery@gmail.com> Tested-by: Carlos Santos <unixmania@gmail.com> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
58 lines
822 B
Bash
58 lines
822 B
Bash
#!/bin/sh
|
|
#
|
|
# Start linuxptp
|
|
#
|
|
|
|
DAEMON="phc2sys"
|
|
|
|
PIDFILE="/var/run/$DAEMON.pid"
|
|
|
|
PHC2SYS_ARGS="-a -r -S 1.0"
|
|
|
|
# shellcheck source=/dev/null
|
|
[ -r "/etc/default/phc2sys" ] && . "/etc/default/phc2sys"
|
|
|
|
start() {
|
|
printf "Starting linuxptp system clock synchronization: "
|
|
start-stop-daemon -S -b -q -m -p $PIDFILE \
|
|
-x /usr/sbin/$DAEMON -- $PHC2SYS_ARGS
|
|
status=$?
|
|
if [ "$status" -eq 0 ]; then
|
|
echo "OK"
|
|
else
|
|
echo "FAIL"
|
|
fi
|
|
return $status
|
|
}
|
|
|
|
stop() {
|
|
printf "Stopping linuxptp system clock synchronization: "
|
|
start-stop-daemon -K -q -p $PIDFILE
|
|
status=$?
|
|
if [ "$status" -eq 0 ]; then
|
|
rm -f "$PIDFILE"
|
|
echo "OK"
|
|
else
|
|
echo "FAIL"
|
|
fi
|
|
return $status
|
|
}
|
|
|
|
case "$1" in
|
|
start)
|
|
start
|
|
;;
|
|
stop)
|
|
stop
|
|
;;
|
|
restart|reload)
|
|
stop
|
|
start
|
|
;;
|
|
*)
|
|
echo "Usage: $0 {start|stop|restart}"
|
|
exit 1
|
|
esac
|
|
|
|
exit $?
|