]> git.ipfire.org Git - people/ms/libloc.git/commitdiff
Add systemd unit files for location-downloader
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 17 Nov 2019 14:52:24 +0000 (14:52 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 17 Nov 2019 14:52:24 +0000 (14:52 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
.gitignore
Makefile.am
configure.ac
src/systemd/location-downloader.service.in [new file with mode: 0644]
src/systemd/location-downloader.timer.in [new file with mode: 0644]

index 19e05bdf62f12d7cc48e4828e6fddc67db157560..45e2feade38cf66dd79cf0ed760c2a51e22aad98 100644 (file)
@@ -14,5 +14,7 @@ Makefile.in
 /stamp-h1
 /src/python/location-downloader
 /src/python/location-query
+/src/systemd/location-downloader.service
+/src/systemd/location-downloader.timer
 /test.db
 /testdata.db
index 33a7e9804777d2bcf02d7ef1444882367096861a..859d9cdbe1798de9ea6198fad42b63b8b5d463bc 100644 (file)
@@ -1,5 +1,6 @@
 EXTRA_DIST =
 CLEANFILES =
+INSTALL_DIRS =
 ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
 AM_MAKEFLAGS = --no-print-directory
 
@@ -36,11 +37,15 @@ LIBLOC_CURRENT=0
 LIBLOC_REVISION=0
 LIBLOC_AGE=0
 
+DISTCHECK_CONFIGURE_FLAGS = \
+       --with-systemdsystemunitdir=$$dc_install_base/$(systemdsystemunitdir)
+
 SED_PROCESS = \
        $(AM_V_GEN)$(MKDIR_P) $(dir $@) && $(SED) \
        -e 's,@VERSION\@,$(VERSION),g' \
        -e 's,@prefix\@,$(prefix),g' \
        -e 's,@exec_prefix\@,$(exec_prefix),g' \
+       -e 's,@bindir\@,$(bindir),g' \
        -e 's,@libdir\@,$(libdir),g' \
        -e 's,@includedir\@,$(includedir),g' \
        -e 's,@databasedir\@,$(databasedir),g' \
@@ -220,6 +225,23 @@ EXTRA_DIST += \
 CLEANFILES += \
        src/python/location-downloader \
        src/python/location-query
+# ------------------------------------------------------------------------------
+
+if HAVE_SYSTEMD
+systemdsystemunit_DATA = \
+       src/systemd/location-downloader.service \
+       src/systemd/location-downloader.timer
+
+CLEANFILES += \
+       $(systemdsystemunit_DATA)
+
+INSTALL_DIRS += \
+       $(systemdsystemunitdir)
+endif
+
+EXTRA_DIST += \
+       src/systemd/location-downloader.service.in \
+       src/systemd/location-downloader.timer.in
 
 # ------------------------------------------------------------------------------
 
index c4ba1f3f446c6904b14dc0e18327bde951ac3f3f..cd224eb423ee201334617d3093ad5adebe20e564 100644 (file)
@@ -96,6 +96,42 @@ my_CFLAGS="\
 "
 AC_SUBST([my_CFLAGS])
 
+# ------------------------------------------------------------------------------
+
+AC_ARG_WITH([systemd],
+       AS_HELP_STRING([--with-systemd], [Enable systemd support.])
+)
+
+AS_IF([test "x$with_systemd" != "xno"],
+      [PKG_CHECK_MODULES(systemd, [libsystemd],
+      [have_systemd=yes], [have_systemd=no])],
+      [have_systemd=no]
+)
+
+AS_IF([test "x$have_systemd" = "xyes"],
+      [AC_MSG_CHECKING([for systemd system unit directory])
+       AC_ARG_WITH([systemdsystemunitdir],
+               AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files]),
+               [], [with_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)]
+       )
+
+       AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])
+
+       if test -n "$systemdsystemunitdir" -a "x$systemdsystemunitdir" != xno; then
+               AC_MSG_RESULT([$systemdsystemunitdir])
+       else
+               AC_MSG_ERROR([not found (try --with-systemdsystemunitdir)])
+       fi
+      ],
+      [AS_IF([test "x$with_systemd" = "xyes"],
+             [AC_MSG_ERROR([Systemd support is enabled but no systemd has been found.])
+      ])
+])
+
+AM_CONDITIONAL(HAVE_SYSTEMD, [test "x$have_systemd" = "xyes"])
+
+# ------------------------------------------------------------------------------
+
 # Python
 AM_PATH_PYTHON([3.4])
 PKG_CHECK_MODULES([PYTHON], [python-${PYTHON_VERSION}])
@@ -130,6 +166,7 @@ AC_MSG_RESULT([
         ldflags:                ${LDFLAGS}
 
         debug:                  ${enable_debug}
+        systemd support:        ${have_systemd}
 
        Bindings:
          perl:                 ${enable_perl}
diff --git a/src/systemd/location-downloader.service.in b/src/systemd/location-downloader.service.in
new file mode 100644 (file)
index 0000000..12c9e05
--- /dev/null
@@ -0,0 +1,7 @@
+[Unit]
+Description=Automatic Location Database Updater
+Requires=network.target
+
+[Service]
+Type=oneshot
+ExecStart=@bindir@/location-downloader update
diff --git a/src/systemd/location-downloader.timer.in b/src/systemd/location-downloader.timer.in
new file mode 100644 (file)
index 0000000..5e3be1a
--- /dev/null
@@ -0,0 +1,9 @@
+[Unit]
+Description=Update location database once a day
+
+[Timer]
+OnCalendar=daily
+RandomizedDelaySec=24h
+
+[Install]
+WantedBy=timers.target