Hi Miklos,

> I'm attaching a patch adding strongswan.service for systemd[1]. I'm
> submitting it as a patch, as one of systemd's great idea is to let
> upstream ship service files, so the "every distro packager writes his
> own rc script" issue won't happen again. :)

Thanks for the patch. Some comments:

> +AC_ARG_WITH([systemdsystemunitdir],
> +           AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for 
> systemd service files]),

We have some helper macros to simplify WITH argument handling,
ARG_WITH_SET() would work fine here.

> +           [], [with_systemdsystemunitdir=$($PKG_CONFIG 
> --variable=systemdsystemunitdir systemd)])

I think this statement requires pkg-config installed, but pkg-config is
not a strongSwan dependency (only to build a ./configure for a
distribution, not to run it).

> +++ b/scripts/strongswan.service

Scripts is probably not the best place for init system stuff, it mainly
contains developer tools not installed on a end user system. I'd prefer
a new subdirectory "init", with systemd being one of the variants in
there.

> +[Service]
> +ExecStart=/usr/sbin/ipsec start --nofork

sbindir by default points to /usr/local/sbin, we should replace this
value by sbindir.

I've attached a patch addressing these issues. I don't have a systemd
enabled installation, please let me know if that works as expected.

Regards
Martin
>From fc16b361ef5290510fe92f17b8f821ea809d7604 Mon Sep 17 00:00:00 2001
From: Miklos Vajna <[email protected]>
Date: Mon, 28 Mar 2011 20:04:00 +0200
Subject: [PATCH] Install systemd service file if systemd is available

---
 Makefile.am                        |    2 +-
 configure.in                       |    9 +++++++++
 init/Makefile.am                   |    6 ++++++
 init/systemd/Makefile.am           |    8 ++++++++
 init/systemd/strongswan.service.in |   10 ++++++++++
 5 files changed, 34 insertions(+), 1 deletions(-)
 create mode 100644 init/Makefile.am
 create mode 100644 init/systemd/Makefile.am
 create mode 100644 init/systemd/strongswan.service.in

diff --git a/Makefile.am b/Makefile.am
index cba5048..4757c8c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = src man testing
+SUBDIRS = src man init testing
 
 if USE_SCRIPTS
   SUBDIRS += scripts
diff --git a/configure.in b/configure.in
index 6dcf65c..4c66b75 100644
--- a/configure.in
+++ b/configure.in
@@ -43,6 +43,13 @@ ARG_WITH_SUBST([routing-table-prio], [220], [set priority for IPsec routing tabl
 ARG_WITH_SET([capabilities],         [no], [set capability dropping library. Currently supported values are "libcap" and "native"])
 ARG_WITH_SET([mpz_powm_sec],         [yes], [use the more side-channel resistant mpz_powm_sec in libgmp, if available])
 
+if test -n "$PKG_CONFIG"; then
+	systemdsystemunitdir_default=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)
+fi
+ARG_WITH_SET([systemdsystemunitdir], [$systemdsystemunitdir_default], [directory for systemd service files])
+AM_CONDITIONAL(HAVE_SYSTEMD, [test -n "$systemdsystemunitdir" -a "x$systemdsystemunitdir" != xno])
+AC_SUBST(systemdsystemunitdir)
+
 AC_ARG_WITH(
 	[xauth-module],
 	AS_HELP_STRING([--with-xauth-module=lib],[set the path to the XAUTH module]),
@@ -957,6 +964,8 @@ dnl ==============================
 AC_OUTPUT(
 	Makefile
 	man/Makefile
+	init/Makefile
+	init/systemd/Makefile
 	src/Makefile
 	src/include/Makefile
 	src/libstrongswan/Makefile
diff --git a/init/Makefile.am b/init/Makefile.am
new file mode 100644
index 0000000..69439a1
--- /dev/null
+++ b/init/Makefile.am
@@ -0,0 +1,6 @@
+
+SUBDIRS =
+
+if HAVE_SYSTEMD
+  SUBDIRS += systemd
+endif
diff --git a/init/systemd/Makefile.am b/init/systemd/Makefile.am
new file mode 100644
index 0000000..e2bbfc4
--- /dev/null
+++ b/init/systemd/Makefile.am
@@ -0,0 +1,8 @@
+
+EXTRA_DIST = strongswan.service.in
+CLEANFILES = strongswan.service
+
+systemdsystemunit_DATA = strongswan.service
+
+strongswan.service : strongswan.service.in
+	sed -e "s:@SBINDIR@:$(sbindir):" $(srcdir)/[email protected] > $@
diff --git a/init/systemd/strongswan.service.in b/init/systemd/strongswan.service.in
new file mode 100644
index 0000000..e8dc5e8
--- /dev/null
+++ b/init/systemd/strongswan.service.in
@@ -0,0 +1,10 @@
+[Unit]
+Description=strongSwan IPsec
+After=syslog.target
+
+[Service]
+ExecStart=@SBINDIR@/ipsec start --nofork
+StandardOutput=syslog
+
+[Install]
+WantedBy=multi-user.target
-- 
1.7.1

_______________________________________________
Dev mailing list
[email protected]
https://lists.strongswan.org/mailman/listinfo/dev

Reply via email to