opencryptoki/opencryptoki-2.4.1-systemd.patch

105 lines
3.0 KiB
Diff
Raw Normal View History

From 5f9d27ae7180324a9a808790356d842df87ca695 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dan=20Hor=C3=A1k?= <dan@danny.cz>
Date: Mon, 27 Feb 2012 11:43:49 +0100
Subject: [PATCH] add support for systemd
New configure parameter is introduced (--with-systemdsystemunitdir) and when set
it means that systemd service file will be installed instead of the classis initscript.
---
.gitignore | 1 +
configure.in | 12 ++++++++++++
misc/Makefile.am | 16 +++++++++++++---
misc/pkcsslotd.service.in | 13 +++++++++++++
4 files changed, 39 insertions(+), 3 deletions(-)
create mode 100644 misc/pkcsslotd.service.in
diff --git a/configure.in b/configure.in
index 483a092..577b148 100644
--- a/configure.in
+++ b/configure.in
@@ -175,6 +175,12 @@ AC_ARG_WITH([xcryptolinz],
[],
[with_xcryptolinz=check])
+dnl --- systemd system unit files location
+AC_ARG_WITH([systemdsystemunitdir],
+ AS_HELP_STRING([--with-systemdsystemunitdir@<:@=DIR@:>@],[systemd system unit files location]),
+ [enable_systemd=yes],
+ [enable_systemd=no])
+
dnl ---
dnl ---
dnl --- Now that we have all the options, let's check for a valid build
@@ -495,6 +501,11 @@ AM_CONDITIONAL([ENABLE_DAEMON], [test "x$enable_daemon" = "xyes"])
dnl --- enable_library
AM_CONDITIONAL([ENABLE_LIBRARY], [test "x$enable_library" = "xyes"])
+dnl --- enable systemd and set unit dir
+AM_CONDITIONAL([ENABLE_SYSTEMD], [test "x$enable_systemd" = "xyes"])
+unitdir=$with_systemdsystemunitdir
+AC_SUBST(unitdir)
+
dnl --- enable_icatok
if test "x$enable_icatok" = "xyes"; then
if test "x$with_libica" != "xyes"; then
@@ -677,6 +688,7 @@ echo " Debug build: $enable_debug"
echo " Testcases: $enable_testcases"
echo " Daemon build: $enable_daemon"
echo " Library build: $enable_library"
+echo " Systemd service: $enable_systemd"
echo
echo "Enabled token types:"
echo " ICA token: $enable_icatok"
diff --git a/misc/Makefile.am b/misc/Makefile.am
index d0c6e9b..2954483 100644
--- a/misc/Makefile.am
+++ b/misc/Makefile.am
@@ -1,8 +1,17 @@
-initddir = $(sysconfdir)/rc.d/init.d
-
-EXTRA_DIST = pkcsslotd.in
+EXTRA_DIST = pkcsslotd.in pkcsslotd.service.in
if ENABLE_DAEMON
+if ENABLE_SYSTEMD
+servicedir = $(unitdir)
+service_SCRIPTS = pkcsslotd.service
+
+CLEANFILES = pkcsslotd.service
+
+pkcsslotd.service: pkcsslotd.service.in
+ @SED@ -e s!\@sbindir\@!"@sbindir@"!g < $< > $@-t
+ mv $@-t $@
+else
+initddir = $(sysconfdir)/rc.d/init.d
initd_SCRIPTS = pkcsslotd
CLEANFILES = pkcsslotd
@@ -12,3 +21,4 @@ pkcsslotd: pkcsslotd.in
@CHMOD@ a+x $@-t
mv $@-t $@
endif
+endif
diff --git a/misc/pkcsslotd.service.in b/misc/pkcsslotd.service.in
new file mode 100644
index 0000000..3e64363
--- /dev/null
+++ b/misc/pkcsslotd.service.in
@@ -0,0 +1,13 @@
+[Unit]
+Description=Daemon which manages cryptographic hardware tokens for the openCryptoki package
+After=syslog.target
+
+[Service]
+Type=forking
+PIDFile=/var/run/pkcsslotd.pid
+ExecStartPre=@sbindir@/pkcs11_startup
+ExecStart=@sbindir@/pkcsslotd
+
+[Install]
+WantedBy=multi-user.target
+
--
1.7.7.6