package/linuxptp: make initscript options configurable
v4 cover package/linuxptp: make initscript options configurable
After talking to Michael I've taken his patch and did a new version with some modifications/improvements.
This series changes the SysV init script to match the prefered style (used package/busybox/S01syslogd) for init scripts. Since in the old init script 2 daemons were started this is split in two. The names for the scripts now matches the daemons they start.
The systemd service scripts are also renamed to match the daemon names (this is the same name as used in debian).
---
v3 -> v4
- change default config values for phc2sys
(use the autoconfigure option -a that does not need the network or PHC device)
- added the Tested-by from Carlos for the previous version (I don't know if this is allowed)
- drop the patch that changes the indentation
(Carlos Santos proposed to do that with a version bump)
v2 -> v3
- fix the install hooks to match the renamed files
- rename the systemd service scripts to have the same name as for the SysVinit scripts
- update the indentation of the hash file
v1 -> v2
- rename the init script from S65linuxptp to S65ptp4l
- move the phc2sys stuff to S66phc2sys
- use the style form package/busybox/S01syslogd as template
Heiko Thiery (1):
package/linuxptp: make initscript options configurable
package/linuxptp/S65linuxptp | 46 ---------------------------- package/linuxptp/S65ptp4l | 59 ++++++++++++++++++++++++++++++++++++ package/linuxptp/S66phc2sys | 59 ++++++++++++++++++++++++++++++++++++ 3 files changed, 118 insertions(+), 46 deletions(-) delete mode 100644 package/linuxptp/S65linuxptp create mode 100644 package/linuxptp/S65ptp4l create mode 100644 package/linuxptp/S66phc2sys
Signature · 1 line
2.20.1
PATCH v4 1/2 package/linuxptp: make initscript options configurable
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.
--- package/linuxptp/S65linuxptp | 46 ---------------------------- package/linuxptp/S65ptp4l | 59 ++++++++++++++++++++++++++++++++++++ package/linuxptp/S66phc2sys | 59 ++++++++++++++++++++++++++++++++++++ package/linuxptp/linuxptp.mk | 6 ++-- 4 files changed, 122 insertions(+), 48 deletions(-) delete mode 100644 package/linuxptp/S65linuxptp create mode 100644 package/linuxptp/S65ptp4l create mode 100644 package/linuxptp/S66phc2sys
package/linuxptp/S65linuxptp deleted +0 -46
@@ -1,46 +0,0 @@ -#!/bin/sh -# -# Start linuxptp -# - -start() { - printf "Starting linuxptp daemon: " - start-stop-daemon -S -b -q -p /var/run/linuxptp-ptp4l.pid \ - -x /usr/sbin/ptp4l -- -f /etc/linuxptp.cfg - [ $? = 0 ] && echo "OK" || echo "FAIL" - - printf "Starting linuxptp system clock synchronization: " - start-stop-daemon -S -b -q -p /var/run/linuxptp-phc2sys.pid \ - -x /usr/sbin/phc2sys -- -s eth0 -c CLOCK_REALTIME -w -S 1.0 - [ $? = 0 ] && echo "OK" || echo "FAIL" -} - -stop() { - printf "Stopping linuxptp system clock synchronization: " - start-stop-daemon -K -q -p /var/run/linuxptp-phc2sys.pid \ - -x /usr/sbin/phc2sys - echo "OK" - - printf "Stopping linuxptp daemon: " - start-stop-daemon -K -q -p /var/run/linuxptp-ptp4l.pid \ - -x /usr/sbin/ptp4l - echo "OK" -} - -case "$1" in - start) - start - ;; - stop) - stop - ;; - restart|reload) - stop - start - ;; - *) - echo "Usage: $0 {start|stop|restart}" - exit 1 -esac - -exit $?
package/linuxptp/S65ptp4l new file +59 -0
59 lines not on this page · raw message
package/linuxptp/S66phc2sys new file +59 -0
59 lines not on this page · raw message
package/linuxptp/linuxptp.mk +4 -2
@@ -33,8 +33,10 @@ define LINUXPTP_INSTALL_TARGET_CMDS endef define LINUXPTP_INSTALL_INIT_SYSV - $(INSTALL) -m 755 -D $(LINUXPTP_PKGDIR)/S65linuxptp \ - $(TARGET_DIR)/etc/init.d/S65linuxptp + $(INSTALL) -m 755 -D $(LINUXPTP_PKGDIR)/S65ptp4l \ + $(TARGET_DIR)/etc/init.d/S65ptp4l + $(INSTALL) -m 755 -D $(LINUXPTP_PKGDIR)/S66phc2sys \ + $(TARGET_DIR)/etc/init.d/S66phc2sys endef define LINUXPTP_INSTALL_INIT_SYSTEMD
Signature · 1 line
2.20.1
PATCH v4 1/2 package/linuxptp: make initscript options configurable
Quoted 86 lines · Heiko Thiery
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/ptp4land/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 <[email protected]>Signed-off-by Heiko Thiery <[email protected]>--- package/linuxptp/S65linuxptp | 46 ---------------------------- package/linuxptp/S65ptp4l | 59 ++++++++++++++++++++++++++++++++++++ package/linuxptp/S66phc2sys | 59 ++++++++++++++++++++++++++++++++++++ package/linuxptp/linuxptp.mk | 6 ++-- 4 files changed, 122 insertions(+), 48 deletions(-) delete mode 100644 package/linuxptp/S65linuxptp create mode 100644 package/linuxptp/S65ptp4l create mode 100644 package/linuxptp/S66phc2syspackage/linuxptp/S65linuxptp deleted +0
-46@@ -1,46 +0,0 @@ -#!/bin/sh -# -# Start linuxptp -# - -start() { - printf "Starting linuxptp daemon: " - start-stop-daemon -S -b -q -p /var/run/linuxptp-ptp4l.pid \ - -x /usr/sbin/ptp4l -- -f /etc/linuxptp.cfg - [ $? = 0 ] && echo "OK" || echo "FAIL" - - printf "Starting linuxptp system clock synchronization: " - start-stop-daemon -S -b -q -p /var/run/linuxptp-phc2sys.pid \ - -x /usr/sbin/phc2sys -- -s eth0 -c CLOCK_REALTIME -w -S 1.0 - [ $? = 0 ] && echo "OK" || echo "FAIL" -} - -stop() { - printf "Stopping linuxptp system clock synchronization: " - start-stop-daemon -K -q -p /var/run/linuxptp-phc2sys.pid \ - -x /usr/sbin/phc2sys - echo "OK" - - printf "Stopping linuxptp daemon: " - start-stop-daemon -K -q -p /var/run/linuxptp-ptp4l.pid \ - -x /usr/sbin/ptp4l - echo "OK" -} - -case "$1" in - start) - start - ;; - stop) - stop - ;; - restart|reload) - stop - start - ;; - *) - echo "Usage: $0 {start|stop|restart}" - exit 1 -esac - -exit $?package/linuxptp/S65ptp4l new file +5
-0@@ -0,0 +1,59 @@ +#!/bin/sh +# +# Start linuxptp +# +
package/linuxptp/S65ptp4l line 15
Quoted 10 lines
package/linuxptp/S65ptp4l new file +10
-0+DAEMON="ptp4l" + +PIDFILE="/var/run/$DAEMON.pid" + +PTP4L_ARGS="-f /etc/linuxptp.cfg" + +# shellcheck source=/dev/null +[ -r "/etc/default/ptp4l" ] && . "/etc/default/ptp4l" + +# ptp4l does not create a pidfile, so pass "-n" in the command line
There is no "-n" argument. Copy/past mistake. :-)
Quoted 55 lines
package/linuxptp/S65ptp4l new file +44
-0+# and use "-m" to instruct start-stop-daemon to create one. +start() { + printf "Starting linuxptp daemon: " + start-stop-daemon -S -b -q -m -p $PIDFILE \ + -x /usr/sbin/$DAEMON -- $PTP4L_ARGS + status=$? + if [ "$status" -eq 0 ]; then + echo "OK" + else + echo "FAIL" + fi + return $status +} + +stop() { + printf "Stopping linuxptp 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 +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart|reload) + stop + start + ;; + *) + echo "Usage: $0 {start|stop|restart}" + exit 1 +esac + +exit $?package/linuxptp/S66phc2sys new file +5
-0@@ -0,0 +1,59 @@ +#!/bin/sh +# +# Start linuxptp +# +
package/linuxptp/S66phc2sys line 15
Quoted 10 lines
package/linuxptp/S66phc2sys new file +10
-0+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" + +# phc2sys does not create a pidfile, so pass "-n" in the command line
Same here.
Quoted 62 lines
package/linuxptp/S66phc2sys new file +44
-0+# and use "-m" to instruct start-stop-daemon to create one. +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 $?package/linuxptp/linuxptp.mk +4
-3@@ -33,8 +33,10 @@ define LINUXPTP_INSTALL_TARGET_CMDS endef define LINUXPTP_INSTALL_INIT_SYSV - $(INSTALL) -m 755 -D $(LINUXPTP_PKGDIR)/S65linuxptp \ - $(TARGET_DIR)/etc/init.d/S65linuxptp + $(INSTALL) -m 755 -D $(LINUXPTP_PKGDIR)/S65ptp4l \ + $(TARGET_DIR)/etc/init.d/S65ptp4l + $(INSTALL) -m 755 -D $(LINUXPTP_PKGDIR)/S66phc2sys \ + $(TARGET_DIR)/etc/init.d/S66phc2sys endef define LINUXPTP_INSTALL_INIT_SYSTEMD --
Quoted 2 lines
2.20.1
But I'd not worry about those copy/paste errors. They can be fixed in a subsequent patch or by the submitter when committing this one.
PATCH v4 1/2 package/linuxptp: make initscript options configurable
Hi Carlos,
Am Do., 12. M?rz 2020 um 21:40 Uhr schrieb Carlos Santos <[email protected]>:
Quoted 92 lines · Heiko Thiery
Quoted 90 lines
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/ptp4land/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 <[email protected]>Signed-off-by Heiko Thiery <[email protected]>--- package/linuxptp/S65linuxptp | 46 ---------------------------- package/linuxptp/S65ptp4l | 59 ++++++++++++++++++++++++++++++++++++ package/linuxptp/S66phc2sys | 59 ++++++++++++++++++++++++++++++++++++ package/linuxptp/linuxptp.mk | 6 ++-- 4 files changed, 122 insertions(+), 48 deletions(-) delete mode 100644 package/linuxptp/S65linuxptp create mode 100644 package/linuxptp/S65ptp4l create mode 100644 package/linuxptp/S66phc2syspackage/linuxptp/S65linuxptp deleted +0
-46@@ -1,46 +0,0 @@ -#!/bin/sh -# -# Start linuxptp -# - -start() { - printf "Starting linuxptp daemon: " - start-stop-daemon -S -b -q -p /var/run/linuxptp-ptp4l.pid \ - -x /usr/sbin/ptp4l -- -f /etc/linuxptp.cfg - [ $? = 0 ] && echo "OK" || echo "FAIL" - - printf "Starting linuxptp system clock synchronization: " - start-stop-daemon -S -b -q -p /var/run/linuxptp-phc2sys.pid \ - -x /usr/sbin/phc2sys -- -s eth0 -c CLOCK_REALTIME -w -S 1.0 - [ $? = 0 ] && echo "OK" || echo "FAIL" -} - -stop() { - printf "Stopping linuxptp system clock synchronization: " - start-stop-daemon -K -q -p /var/run/linuxptp-phc2sys.pid \ - -x /usr/sbin/phc2sys - echo "OK" - - printf "Stopping linuxptp daemon: " - start-stop-daemon -K -q -p /var/run/linuxptp-ptp4l.pid \ - -x /usr/sbin/ptp4l - echo "OK" -} - -case "$1" in - start) - start - ;; - stop) - stop - ;; - restart|reload) - stop - start - ;; - *) - echo "Usage: $0 {start|stop|restart}" - exit 1 -esac - -exit $?package/linuxptp/S65ptp4l new file +9
-0@@ -0,0 +1,59 @@ +#!/bin/sh +# +# Start linuxptp +# + +DAEMON="ptp4l" + +PIDFILE="/var/run/$DAEMON.pid" +
Quoted 8 lines
package/linuxptp/S65ptp4l line 15
Quoted 6 lines
package/linuxptp/S65ptp4l new file +6
-0+PTP4L_ARGS="-f /etc/linuxptp.cfg" + +# shellcheck source=/dev/null +[ -r "/etc/default/ptp4l" ] && . "/etc/default/ptp4l" + +# ptp4l does not create a pidfile, so pass "-n" in the command lineThere is no "-n" argument. Copy/past mistake. :-)
Damn .. you're right. Copy/paste :-/
Quoted 3 lines
But I'd not worry about those copy/paste errors. They can be fixed in a subsequent patch or by the submitter when committing this one.
Ok. will wait if the submitter will come with a feedback
Quoted 2 lines
Tested-by Carlos Santos <[email protected]>
Thank you for testing
Signature · 1 line
Heiko
Thomas Petazzoni
AppliedPATCH v4 1/2 package/linuxptp: make initscript options configurable
In reply to Heiko ThieryQuoted 12 lines · On Thu, 12 Mar 2020 20:04:34 +0100 Heiko Thiery <[email protected]> wrote:
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/ptp4land/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 <[email protected]>Signed-off-by Heiko Thiery <[email protected]>
Quoted 9 lines
--- package/linuxptp/S65linuxptp | 46 ---------------------------- package/linuxptp/S65ptp4l | 59 ++++++++++++++++++++++++++++++++++++ package/linuxptp/S66phc2sys | 59 ++++++++++++++++++++++++++++++++++++ package/linuxptp/linuxptp.mk | 6 ++-- 4 files changed, 122 insertions(+), 48 deletions(-) delete mode 100644 package/linuxptp/S65linuxptp create mode 100644 package/linuxptp/S65ptp4l create mode 100644 package/linuxptp/S66phc2sys
Applied to master after fixing the bogus comments. Thanks for the work, and thanks Carlos for the review, testing: thanks to this review/testing, I could blindly apply the patches.
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
PATCH v4 2/2 package/linuxptp: rename systemd service scripts
In reply to Heiko ThieryUse the same name as for the SysVinit scripts. This name is also used in debian.
linuxptp-system-clock.service -> phc2sys.service
linuxptp.service -> ptp4l.service
---
package/linuxptp/linuxptp.mk | 8 ++++----
.../{linuxptp-system-clock.service => phc2sys.service} | 2 +-
package/linuxptp/{linuxptp.service => ptp4l.service} | 2 +-
3 files changed, 6 insertions(+), 6 deletions(-)
rename package/linuxptp/{linuxptp-system-clock.service => phc2sys.service} (89%)
rename package/linuxptp/{linuxptp.service => ptp4l.service} (87%)package/linuxptp/linuxptp.mk +4 -4
@@ -40,10 +40,10 @@ define LINUXPTP_INSTALL_INIT_SYSV endef define LINUXPTP_INSTALL_INIT_SYSTEMD - $(INSTALL) -D -m 644 $(LINUXPTP_PKGDIR)/linuxptp.service \ - $(TARGET_DIR)/usr/lib/systemd/system/linuxptp.service - $(INSTALL) -D -m 644 $(LINUXPTP_PKGDIR)/linuxptp-system-clock.service \ - $(TARGET_DIR)/usr/lib/systemd/system/linuxptp-system-clock.service + $(INSTALL) -D -m 644 $(LINUXPTP_PKGDIR)/ptp4l.service \ + $(TARGET_DIR)/usr/lib/systemd/system/ptp4l.service + $(INSTALL) -D -m 644 $(LINUXPTP_PKGDIR)/phc2sys.service \ + $(TARGET_DIR)/usr/lib/systemd/system/phc2sys.service endef $(eval $(generic-package))
package/linuxptp/phc2sys.service renamed from package/linuxptp/linuxptp-system-clock.service +1 -1
@@ -1,6 +1,6 @@ [Unit] Description=Precision Time Protocol system clock synchronization -After=linuxptp.service +After=ptp4l.service [Service] ExecStart=/usr/sbin/phc2sys -s /dev/ptp0 -c CLOCK_REALTIME -w -S 1.0
package/linuxptp/ptp4l.service renamed from package/linuxptp/linuxptp.service +1 -1
@@ -3,7 +3,7 @@ Description=Precision Time Protocol daemon After=syslog.target network.target Before=time-sync.target Wants=time-sync.target -Wants=linuxptp-system-clock.service +Wants=phc2sys.service [Service] ExecStart=/usr/sbin/ptp4l -f /etc/linuxptp.cfg
Signature · 1 line
2.20.1
PATCH v4 2/2 package/linuxptp: rename systemd service scripts
Quoted 68 lines · Heiko Thiery
Use the same name as for the SysVinit scripts. This name is also used in debian.
linuxptp-system-clock.service -> phc2sys.service
linuxptp.service -> ptp4l.serviceSigned-off-by Heiko Thiery <[email protected]>Tested-by Carlos Santos <[email protected]>--- package/linuxptp/linuxptp.mk | 8 ++++---- .../{linuxptp-system-clock.service => phc2sys.service} | 2 +- package/linuxptp/{linuxptp.service => ptp4l.service} | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) rename package/linuxptp/{linuxptp-system-clock.service => phc2sys.service} (89%) rename package/linuxptp/{linuxptp.service => ptp4l.service} (87%)package/linuxptp/linuxptp.mk +4
-4@@ -40,10 +40,10 @@ define LINUXPTP_INSTALL_INIT_SYSV endef define LINUXPTP_INSTALL_INIT_SYSTEMD - $(INSTALL) -D -m 644 $(LINUXPTP_PKGDIR)/linuxptp.service \ - $(TARGET_DIR)/usr/lib/systemd/system/linuxptp.service - $(INSTALL) -D -m 644 $(LINUXPTP_PKGDIR)/linuxptp-system-clock.service \ - $(TARGET_DIR)/usr/lib/systemd/system/linuxptp-system-clock.service + $(INSTALL) -D -m 644 $(LINUXPTP_PKGDIR)/ptp4l.service \ + $(TARGET_DIR)/usr/lib/systemd/system/ptp4l.service + $(INSTALL) -D -m 644 $(LINUXPTP_PKGDIR)/phc2sys.service \ + $(TARGET_DIR)/usr/lib/systemd/system/phc2sys.service endef $(eval $(generic-package))package/linuxptp/phc2sys.service renamed from package/linuxptp/linuxptp-system-clock.service +1
-1@@ -1,6 +1,6 @@ [Unit] Description=Precision Time Protocol system clock synchronization -After=linuxptp.service +After=ptp4l.service [Service] ExecStart=/usr/sbin/phc2sys -s /dev/ptp0 -c CLOCK_REALTIME -w -S 1.0package/linuxptp/ptp4l.service renamed from package/linuxptp/linuxptp.service +1
-2@@ -3,7 +3,7 @@ Description=Precision Time Protocol daemon After=syslog.target network.target Before=time-sync.target Wants=time-sync.target -Wants=linuxptp-system-clock.service +Wants=phc2sys.service [Service] ExecStart=/usr/sbin/ptp4l -f /etc/linuxptp.cfg --
Quoted 2 lines
2.20.1
Thomas Petazzoni
AppliedPATCH v4 2/2 package/linuxptp: rename systemd service scripts
In reply to Heiko ThieryQuoted 8 lines · On Thu, 12 Mar 2020 20:04:36 +0100 Heiko Thiery <[email protected]> wrote:
Use the same name as for the SysVinit scripts. This name is also used in debian.
linuxptp-system-clock.service -> phc2sys.service
linuxptp.service -> ptp4l.serviceSigned-off-by Heiko Thiery <[email protected]>Tested-by Carlos Santos <[email protected]>
Quoted 7 lines
---
package/linuxptp/linuxptp.mk | 8 ++++----
.../{linuxptp-system-clock.service => phc2sys.service} | 2 +-
package/linuxptp/{linuxptp.service => ptp4l.service} | 2 +-
3 files changed, 6 insertions(+), 6 deletions(-)
rename package/linuxptp/{linuxptp-system-clock.service => phc2sys.service} (89%)
rename package/linuxptp/{linuxptp.service => ptp4l.service} (87%)Applied to master, thanks.
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com