[Git][NTPsec/ntpsec][master] 2 commits: Install systemd units with subst

Matt Selsky gitlab at mg.gitlab.com
Sun Mar 3 21:02:16 UTC 2019


Matt Selsky pushed to branch master at NTPsec / ntpsec


Commits:
1ac4406f by Richard Laager at 2019-03-03T18:51:31Z
Install systemd units with subst

This commit fixes several issues with the systemd unit installation:
1) The path for the units varies by distro.  For example, on RedHat,
   it is /usr/lib/systemd/system, but on Debian it is
   /lib/systemd/system.  This change uses pkg-config to lookup the
   correct path.
2) The systemd units are now installed by default, if the system has
   systemd installed, as determined by pkg-config.  If the user has
   systemd installed, but is not using it, the two text files installed
   are moot and harmless.  This eliminates the systemdenable and
   systemddisable waf commands.  If you are using systemd and wish to
   disable the units for some reason, use the built-in mechanism of
   `systemctl disable ntpd.service ntp-wait.service`.
3) The paths for the executables (ntpd and ntp-wait) inside the unit
   files are now set using subst so they match the --sbindir and
   --bindir, respectively, as set at waf configure time.

- - - - -
f9c198d8 by Richard Laager at 2019-03-03T18:55:19Z
Install the ntpviz & ntplogtemp services/timers

The ntpviz and ntplogtemp executables are install by default, so we
should install those units too.

- - - - -


8 changed files:

- etc/README
- etc/ntp-wait.service
- etc/ntpd.service
- etc/ntplogtemp.service
- etc/ntpviz-daily.service
- etc/ntpviz-weekly.service
- + etc/wscript
- wscript


Changes:

=====================================
etc/README
=====================================
@@ -13,9 +13,7 @@ give a sane default configuration.
 The rc files are start/stop scripts for NTP under System-V-style
 init. They are intended as models for distribution packagers.
 
-The ntpd.service file is intended for use with systemd. Note that
-it assumes the waf default installation location /usr/sbin for
-ntpd; you may need to modify this for some distrbutions.
+The *.service and *.timer files are for use with systemd.
 
 Additional information can be found in the ./docs subdirectory of the
 base directory.


=====================================
etc/ntp-wait.service
=====================================
@@ -8,7 +8,7 @@ ConditionCapability=CAP_SYS_TIME
 
 [Service]
 Type=oneshot
-ExecStart=/usr/bin/ntpwait -s 1 -n 30000
+ExecStart=@BINDIR@/ntpwait -s 1 -n 30000
 RemainAfterExit=yes
 StandardOutput=null
 


=====================================
etc/ntpd.service
=====================================
@@ -9,7 +9,7 @@ Conflicts=systemd-timesyncd.service
 [Service]
 Type=forking
 PrivateTmp=true
-ExecStart=/usr/sbin/ntpd -g -N -u ntp:ntp
+ExecStart=@SBINDIR@/ntpd -g -N -u ntp:ntp
 # Specifying -g on the command line allows ntpd to make large adjustments to
 # the clock on boot.  However, if Restart=yes is set, a malicious (or broken)
 # server could send the incorrect time, trip the panic threshold, and when


=====================================
etc/ntplogtemp.service
=====================================
@@ -4,4 +4,4 @@ Description=Temperature information logger for ntpviz
 
 [Service]
 Type=simple
-ExecStart=/usr/bin/ntplogtemp -o -l /var/log/ntpstats/temps
+ExecStart=@BINDIR@/ntplogtemp -o -l /var/log/ntpstats/temps


=====================================
etc/ntpviz-daily.service
=====================================
@@ -6,4 +6,4 @@ Requisite=ntpd.service
 [Service]
 Type=simple
 IOSchedulingClass=idle
-ExecStart=/usr/bin/ntpviz -w l -p 1 -o /var/www/localhost/htdocs/day
+ExecStart=@BINDIR@/ntpviz -w l -p 1 -o /var/www/localhost/htdocs/day


=====================================
etc/ntpviz-weekly.service
=====================================
@@ -6,4 +6,4 @@ Requisite=ntpd.service
 [Service]
 Type=simple
 IOSchedulingClass=idle
-ExecStart=/usr/bin/ntpviz -w l -p 7 -o /var/www/localhost/htdocs/week
+ExecStart=@BINDIR@/ntpviz -w l -p 7 -o /var/www/localhost/htdocs/week


=====================================
etc/wscript
=====================================
@@ -0,0 +1,20 @@
+def build(ctx):
+
+    units = [
+        "ntp-wait.service",
+        "ntpd.service",
+        "ntpviz-daily.service",
+        "ntplogtemp.service",
+        "ntplogtemp.timer",
+        "ntpviz-daily.timer",
+        "ntpviz-weekly.service",
+        "ntpviz-weekly.timer",
+    ]
+
+    # Install unit files
+    ctx(
+        features="subst",
+        source=units,
+        target=units,
+        install_path=ctx.env.SYSTEMD_systemdsystemunitdir,
+    )


=====================================
wscript
=====================================
@@ -197,6 +197,14 @@ def configure(ctx):
     if ctx.options.disable_manpage:
         ctx.env.DISABLE_MANPAGE = True
 
+    ctx.check_cfg(
+        package='systemd', variables=['systemdsystemunitdir'],
+        uselib_store='SYSTEMD', mandatory=False,
+        msg="Checking for systemd")
+    if ctx.env.SYSTEMD_systemdsystemunitdir:
+        ctx.start_msg("systemd unit directory:")
+        ctx.end_msg(ctx.env.SYSTEMD_systemdsystemunitdir)
+
     source_date_epoch = os.getenv('SOURCE_DATE_EPOCH', None)
     if ctx.options.build_epoch is not None:
         build_epoch = ctx.options.build_epoch
@@ -1038,6 +1046,7 @@ def build(ctx):
     ctx.recurse("ntptime")
     ctx.recurse("pylib")
     ctx.recurse("attic")
+    ctx.recurse("etc")
     ctx.recurse("tests")
 
     if ctx.env['PYTHON_CURSES']:
@@ -1114,22 +1123,6 @@ def build(ctx):
             print("--- PYTHONARCHDIR not in PYTHONPATH, "
                   "loading the Python ntp library may be troublesome ---")
 
-#
-# Boot script setup
-#
-
-
-def systemdenable(ctx):
-    "Enable boot time start with systemd. Must run as root."
-    ctx.exec_command("cp etc/ntpd.service etc/ntp-wait.service "
-                     "/usr/lib/systemd/system/")
-
-
-def systemddisable(ctx):
-    "Disable boot time start with systemd. Must run as root."
-    ctx.exec_command("rm -f /usr/lib/systemd/system/ntpd.service "
-                     "/usr/lib/systemd/system/ntp-wait.service")
-
 #
 # Miscellaneous utility productions
 #



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/4c5a32fb16603e05218ef5b09d29709f5ec61f90...f9c198d8ace2a9ae13ce58ca02cb578d0ebe5dc1

-- 
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/4c5a32fb16603e05218ef5b09d29709f5ec61f90...f9c198d8ace2a9ae13ce58ca02cb578d0ebe5dc1
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20190303/350f4b0e/attachment-0001.html>


More information about the vc mailing list