Merge branch 'libyang' of https://github.com/CESNET/mod_netconf into libyang
diff --git a/Makefile.am b/Makefile.am
index 8f25ef3..56b967c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -9,6 +9,12 @@
dist-hook:
find "$(distdir)" -name .gitignore -exec rm {} \;
+DISTCHECK_CONFIGURE_FLAGS="--without-systemd"
+if HAVE_SYSTEMD
+systemddir=@SYSTEMD_UNIT_DIR@
+systemd_DATA=nemea-supervisor.service
+endif
+
if MAKE_RPMS
RPMFILENAME=$(PACKAGE_NAME)-$(VERSION)
diff --git a/configure.ac b/configure.ac
index 3fe7f44..f5a7259 100644
--- a/configure.ac
+++ b/configure.ac
@@ -81,9 +81,33 @@
AC_FUNC_REALLOC
AC_CHECK_FUNCS([getdelim gettimeofday memset socket strdup strerror])
+# allow to skip systemd, enabled by default
+AC_ARG_WITH([systemd],
+ AC_HELP_STRING([--without-systemd], [Disable checking and usage of systemd]),
+ [if test "$withval" = "no"; then
+ withsystemd="no"
+ else
+ withsystemd="yes"
+ fi], [withsystemd="yes"])
+
+if test "x$withsystemd" = "xyes"; then
+ PKG_CHECK_MODULES([systemd], [systemd], [
+ SYSTEMD_UNIT_DIR=$(pkg-config --variable=systemdsystemunitdir systemd)
+ SYSTEMD_SERVICE_FILE="$SYSTEMD_UNIT_DIR/netopeerguid.service"
+ AC_SUBST(SYSTEMD_SERVICE_FILE)
+ AC_SUBST(SYSTEMD_UNIT_DIR)
+ AM_CONDITIONAL([HAVE_SYSTEMD], [true])
+ ], [AM_CONDITIONAL([HAVE_SYSTEMD], [false])])
+else
+ # disabled systemd
+ AM_CONDITIONAL([HAVE_SYSTEMD], [false])
+fi
+
+
AC_CONFIG_FILES([Makefile
config.h
netopeerguid.spec
+ netopeerguid.service
src/netopeerguid.rc
src/Makefile
])
diff --git a/netopeerguid.service.in b/netopeerguid.service.in
new file mode 100644
index 0000000..14abbf2
--- /dev/null
+++ b/netopeerguid.service.in
@@ -0,0 +1,29 @@
+# It's not recommended to modify this file in-place, because it will be
+# overwritten during package upgrades. If you want to customize, the best
+# way is to create a file "/etc/systemd/system/netopeerguid.service",
+# containing
+# .include /lib/systemd/system/netopeerguid.service
+# ...make your changes here...
+# For more info about custom unit files, see
+# http://fedoraproject.org/wiki/Systemd#How_do_I_customize_a_unit_file.2F_add_a_custom_unit_file.3F
+#
+# For example, to pass additional options (for instance, -D definitions) to the
+# supervisor binary at startup, you need to create a file named
+# "/etc/systemd/system/netopeerguid.service" containing:
+# .include /lib/systemd/system/netopeerguid.service
+# [Service]
+# Environment=OPTIONS=-DMY_DEFINE
+
+[Unit]
+Description=NetopeerGUI backend daemon
+After=network.target local-fs.target remote-fs.target
+
+[Service]
+Type=simple
+Environment=LANG=C
+ExecStart=@bindir@/netopeerguid
+KillMode=process
+PrivateTmp=false
+
+[Install]
+WantedBy=multi-user.target
diff --git a/netopeerguid.spec.in b/netopeerguid.spec.in
index d20c23b..e40e980 100644
--- a/netopeerguid.spec.in
+++ b/netopeerguid.spec.in
@@ -39,4 +39,7 @@
rm -f /var/run/netopeerguid.sock
%files
+%{_bindir}/netopeerguid
%doc README
+@SYSTEMD_SERVICE_FILE@
+