Discussion:
[Linuxptp-devel] [PATCH RFC v2] create systemd service script for ptp4l
Jacob Keller
2013-07-12 23:46:29 UTC
Permalink
This patch adds a systemd service unit for ptp4l. Currently does not allow
systemd to create any sockets, as this becomes really tricky since there are so
many types of configuration. The initial systemd service will be kept very
simple.:wq

Signed-off-by: Jacob Keller <***@intel.com>
---
makefile | 14 ++++++++++++--
ptp4l.8 | 7 +++++++
ptp4l.service.in | 9 +++++++++
3 files changed, 28 insertions(+), 2 deletions(-)
create mode 100644 ptp4l.service.in

diff --git a/makefile b/makefile
index 71dcf0c..96cb0b7 100644
--- a/makefile
+++ b/makefile
@@ -28,6 +28,7 @@ INC = -I$(KBUILD_OUTPUT)/usr/include
VER = -DVER=$(version)
CFLAGS = -Wall $(VER) $(INC) $(DEBUG) $(FEAT_CFLAGS) $(EXTRA_CFLAGS)
LDLIBS = -lm -lrt $(EXTRA_LDFLAGS)
+SRV = ptp4l.service
PRG = ptp4l pmc phc2sys hwstamp_ctl
OBJ = bmc.o clock.o clockadj.o config.o fault.o fsm.o ptp4l.o mave.o \
msg.o phc.o pi.o port.o print.o raw.o servo.o sk.o stats.o tlv.o tmtab.o \
@@ -43,9 +44,16 @@ VPATH = $(srcdir)
prefix = /usr/local
sbindir = $(prefix)/sbin
mandir = $(prefix)/man
+etcdir = $(prefix)/etc
man8dir = $(mandir)/man8
+srvdir = /lib/systemd/system/

-all: $(PRG)
+all: $(PRG) $(SRV)
+
+ptp4l.service: ptp4l.service.in
+ cat $(<) | sed \
+ -e 's_@@sbindir@@_$(sbindir)_g' \
+ -e 's_@@etcdir@@_$(etcdir)_g' >$(@)

ptp4l: $(OBJ)

@@ -70,10 +78,12 @@ force:
install: $(PRG)
mkdir -p $(sbindir) $(man8dir)
install $(PRG) $(sbindir)
+ install -p -m 644 $(SRV) $(srvdir)
install -p -m 644 -t $(man8dir) $(PRG:%=%.8)
+ cp default.cfg $(etcdir)/ptp4l.cfg

clean:
- rm -f $(OBJECTS) $(DEPEND)
+ rm -f $(OBJECTS) $(DEPEND) $(SRV)

distclean: clean
rm -f $(PRG)
diff --git a/ptp4l.8 b/ptp4l.8
index 6f42c1c..2f14b5a 100644
--- a/ptp4l.8
+++ b/ptp4l.8
@@ -395,6 +395,13 @@ of local clock in use. The value is purely informational, having no
effect on the outcome of the Best Master Clock algorithm, and is
advertised when the clock becomes grand master.

+.SH SYSTEMD SERVICE FILE
+
+.B ptp4l.service
+is a systemd service file for use with the systemd init system. This service
+file can be used with systemd and its utilities to manage the ptp4l daemon
+process.
+
.SH TIME SCALE USAGE

.B ptp4l
diff --git a/ptp4l.service.in b/ptp4l.service.in
new file mode 100644
index 0000000..a2f04e9
--- /dev/null
+++ b/ptp4l.service.in
@@ -0,0 +1,9 @@
+[Unit]
+Description=LinuxPTP daemon for the IEEE 1588 Time Sync protocol
+After=network.target
+
+[Service]
+ExecStart=@@sbindir@@/ptp4l -f @@etcdir@@/ptp4l.cfg -m
+
+[Install]
+WantedBy=multi-user.target
Keller, Jacob E
2013-07-12 23:48:26 UTC
Permalink
Sorry once again, noticed a typo in the patch description. Sorry for thrash.

- Jake
-----Original Message-----
Sent: Friday, July 12, 2013 4:46 PM
Subject: [Linuxptp-devel] [PATCH RFC v2] create systemd service script
for ptp4l
This patch adds a systemd service unit for ptp4l. Currently does not allow
systemd to create any sockets, as this becomes really tricky since there are so
many types of configuration. The initial systemd service will be kept very
simple.:wq
---
makefile | 14 ++++++++++++--
ptp4l.8 | 7 +++++++
ptp4l.service.in | 9 +++++++++
3 files changed, 28 insertions(+), 2 deletions(-)
create mode 100644 ptp4l.service.in
diff --git a/makefile b/makefile
index 71dcf0c..96cb0b7 100644
--- a/makefile
+++ b/makefile
@@ -28,6 +28,7 @@ INC = -I$(KBUILD_OUTPUT)/usr/include
VER = -DVER=$(version)
CFLAGS = -Wall $(VER) $(INC) $(DEBUG) $(FEAT_CFLAGS)
$(EXTRA_CFLAGS)
LDLIBS = -lm -lrt $(EXTRA_LDFLAGS)
+SRV = ptp4l.service
PRG = ptp4l pmc phc2sys hwstamp_ctl
OBJ = bmc.o clock.o clockadj.o config.o fault.o fsm.o ptp4l.o mave.o \
msg.o phc.o pi.o port.o print.o raw.o servo.o sk.o stats.o tlv.o tmtab.o \
@@ -43,9 +44,16 @@ VPATH = $(srcdir)
prefix = /usr/local
sbindir = $(prefix)/sbin
mandir = $(prefix)/man
+etcdir = $(prefix)/etc
man8dir = $(mandir)/man8
+srvdir = /lib/systemd/system/
-all: $(PRG)
+all: $(PRG) $(SRV)
+
+ptp4l.service: ptp4l.service.in
+ cat $(<) | sed \
ptp4l: $(OBJ)
install: $(PRG)
mkdir -p $(sbindir) $(man8dir)
install $(PRG) $(sbindir)
+ install -p -m 644 $(SRV) $(srvdir)
install -p -m 644 -t $(man8dir) $(PRG:%=%.8)
+ cp default.cfg $(etcdir)/ptp4l.cfg
- rm -f $(OBJECTS) $(DEPEND)
+ rm -f $(OBJECTS) $(DEPEND) $(SRV)
distclean: clean
rm -f $(PRG)
diff --git a/ptp4l.8 b/ptp4l.8
index 6f42c1c..2f14b5a 100644
--- a/ptp4l.8
+++ b/ptp4l.8
@@ -395,6 +395,13 @@ of local clock in use. The value is purely informational, having no
effect on the outcome of the Best Master Clock algorithm, and is
advertised when the clock becomes grand master.
+.SH SYSTEMD SERVICE FILE
+
+.B ptp4l.service
+is a systemd service file for use with the systemd init system. This service
+file can be used with systemd and its utilities to manage the ptp4l daemon
+process.
+
.SH TIME SCALE USAGE
.B ptp4l
diff --git a/ptp4l.service.in b/ptp4l.service.in
new file mode 100644
index 0000000..a2f04e9
--- /dev/null
+++ b/ptp4l.service.in
@@ -0,0 +1,9 @@
+[Unit]
+Description=LinuxPTP daemon for the IEEE 1588 Time Sync protocol
+After=network.target
+
+[Service]
+
+[Install]
+WantedBy=multi-user.target
------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/os
tg.clktrk
_______________________________________________
Linuxptp-devel mailing list
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel
Loading...