xref: /OK3568_Linux_fs/buildroot/package/linuxptp/S66phc2sys (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1#!/bin/sh
2#
3# Start linuxptp
4#
5
6DAEMON="phc2sys"
7
8PIDFILE="/var/run/$DAEMON.pid"
9
10PHC2SYS_ARGS="-a -r -S 1.0"
11
12# shellcheck source=/dev/null
13[ -r "/etc/default/phc2sys" ] && . "/etc/default/phc2sys"
14
15start() {
16	printf "Starting linuxptp system clock synchronization: "
17	start-stop-daemon -S -b -q -m -p $PIDFILE \
18		-x /usr/sbin/$DAEMON -- $PHC2SYS_ARGS
19	status=$?
20	if [ "$status" -eq 0 ]; then
21		echo "OK"
22	else
23		echo "FAIL"
24	fi
25	return $status
26}
27
28stop() {
29	printf "Stopping linuxptp system clock synchronization: "
30	start-stop-daemon -K -q -p $PIDFILE
31	status=$?
32	if [ "$status" -eq 0 ]; then
33		rm -f "$PIDFILE"
34		echo "OK"
35	else
36		echo "FAIL"
37	fi
38	return $status
39}
40
41case "$1" in
42  start)
43	start
44	;;
45  stop)
46	stop
47	;;
48  restart|reload)
49	stop
50	start
51	;;
52  *)
53	echo "Usage: $0 {start|stop|restart}"
54	exit 1
55esac
56
57exit $?
58