From f74595c11bad2b6a5cc6b424878f19545a610120 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Luttringer?= Date: Fri, 2 Aug 2013 01:57:40 +0200 Subject: [PATCH 1/2] By user systemd service/socket Instead of having a socket for a static and predefined user http, this patch allow to easily setup multiple sockets with your needed users. This is particulary useful when you want have socket for dedicated user. You can create an http socket (in /run/fcgiwrap-http.sock) with: $ systemctl enable fcgiwrap@http.socket and if you need a socket for munin (in /run/fcgiwrap-munin.sock): $ systemctl enable fcgiwrap@munin.socket --- Makefile.in | 4 ++-- systemd/fcgiwrap.service | 11 ----------- systemd/fcgiwrap.socket | 8 -------- systemd/fcgiwrap@.service | 7 +++++++ systemd/fcgiwrap@.socket | 8 ++++++++ 5 files changed, 17 insertions(+), 21 deletions(-) delete mode 100644 systemd/fcgiwrap.service delete mode 100644 systemd/fcgiwrap.socket create mode 100644 systemd/fcgiwrap@.service create mode 100644 systemd/fcgiwrap@.socket diff --git a/Makefile.in b/Makefile.in index 97378e5..ba7d65c 100644 --- a/Makefile.in +++ b/Makefile.in @@ -12,8 +12,8 @@ install: all install -m 644 fcgiwrap.8 $(man8dir) ifneq ("@systemdsystemunitdir@", "") install -d -m 755 $(DESTDIR)@systemdsystemunitdir@ - install -m 644 systemd/fcgiwrap.socket $(DESTDIR)@systemdsystemunitdir@ - install -m 644 systemd/fcgiwrap.service $(DESTDIR)@systemdsystemunitdir@ + install -m 644 systemd/fcgiwrap@.socket $(DESTDIR)@systemdsystemunitdir@ + install -m 644 systemd/fcgiwrap@.service $(DESTDIR)@systemdsystemunitdir@ endif LDLIBS = -lfcgi @systemd_LIBS@ diff --git a/systemd/fcgiwrap.service b/systemd/fcgiwrap.service deleted file mode 100644 index 7b010c9..0000000 --- a/systemd/fcgiwrap.service +++ /dev/null @@ -1,11 +0,0 @@ -[Unit] -Description=Simple CGI Server -After=nss-user-lookup.target - -[Service] -ExecStart=/usr/sbin/fcgiwrap -User=http -Group=http - -[Install] -Also=fcgiwrap.socket diff --git a/systemd/fcgiwrap.socket b/systemd/fcgiwrap.socket deleted file mode 100644 index dc074f1..0000000 --- a/systemd/fcgiwrap.socket +++ /dev/null @@ -1,8 +0,0 @@ -[Unit] -Description=fcgiwrap Socket - -[Socket] -ListenStream=/run/fcgiwrap.sock - -[Install] -WantedBy=sockets.target diff --git a/systemd/fcgiwrap@.service b/systemd/fcgiwrap@.service new file mode 100644 index 0000000..9993f65 --- /dev/null +++ b/systemd/fcgiwrap@.service @@ -0,0 +1,7 @@ +[Unit] +Description=Simple CGI Server for user %I +After=nss-user-lookup.target + +[Service] +ExecStart=/usr/sbin/fcgiwrap -s /run/fcgiwrap-%I.sock +User=%I diff --git a/systemd/fcgiwrap@.socket b/systemd/fcgiwrap@.socket new file mode 100644 index 0000000..a362c13 --- /dev/null +++ b/systemd/fcgiwrap@.socket @@ -0,0 +1,8 @@ +[Unit] +Description=fcgiwrap socket for user %I + +[Socket] +ListenStream=/run/fcgiwrap-%I.sock + +[Install] +WantedBy=sockets.target From 632064d227ed0f2e79b92ce97ac2b98cf2dbff5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Luttringer?= Date: Fri, 2 Aug 2013 02:49:29 +0200 Subject: [PATCH 2/2] Use autoconf sbindir in systemd units --- Makefile.in | 9 ++++++++- configure.ac | 1 + systemd/{fcgiwrap@.service => fcgiwrap@.service.in} | 2 +- systemd/{fcgiwrap@.socket => fcgiwrap@.socket.in} | 0 4 files changed, 10 insertions(+), 2 deletions(-) rename systemd/{fcgiwrap@.service => fcgiwrap@.service.in} (64%) rename systemd/{fcgiwrap@.socket => fcgiwrap@.socket.in} (100%) diff --git a/Makefile.in b/Makefile.in index ba7d65c..1cdc5b8 100644 --- a/Makefile.in +++ b/Makefile.in @@ -4,7 +4,7 @@ datarootdir = .PHONY: clean distclean -all: fcgiwrap +all: fcgiwrap systemd/fcgiwrap@.socket systemd/fcgiwrap@.service install: all install -d -m 755 $(targetdir) install -m 755 fcgiwrap $(targetdir) @@ -21,9 +21,16 @@ CFLAGS = @AM_CFLAGS@ fcgiwrap: fcgiwrap.c +systemd/fcgiwrap@.socket: systemd/fcgiwrap@.socket.in + $(SED) -e 's,[@]sbindir[@],@sbindir@,g' < $< > $@ + +systemd/fcgiwrap@.service: systemd/fcgiwrap@.service.in + $(SED) -e 's,[@]sbindir[@],@sbindir@,g' < $< > $@ + #>+ 21 clean: -rm -f fcgiwrap + -rm -f systemd/fcgiwrap@.socket systemd/fcgiwrap@.service #>+ 21 distclean: clean diff --git a/configure.ac b/configure.ac index bb3674e..cd347be 100644 --- a/configure.ac +++ b/configure.ac @@ -15,6 +15,7 @@ AC_SUBST([AM_CFLAGS]) # Checks for programs. AC_PROG_CC PKG_PROG_PKG_CONFIG +AC_PROG_SED # Create the config.h. AC_CONFIG_HEADERS([config.h]) diff --git a/systemd/fcgiwrap@.service b/systemd/fcgiwrap@.service.in similarity index 64% rename from systemd/fcgiwrap@.service rename to systemd/fcgiwrap@.service.in index 9993f65..cb2bab0 100644 --- a/systemd/fcgiwrap@.service +++ b/systemd/fcgiwrap@.service.in @@ -3,5 +3,5 @@ Description=Simple CGI Server for user %I After=nss-user-lookup.target [Service] -ExecStart=/usr/sbin/fcgiwrap -s /run/fcgiwrap-%I.sock +ExecStart=@sbindir@/fcgiwrap -s /run/fcgiwrap-%I.sock User=%I diff --git a/systemd/fcgiwrap@.socket b/systemd/fcgiwrap@.socket.in similarity index 100% rename from systemd/fcgiwrap@.socket rename to systemd/fcgiwrap@.socket.in