From af2f2f91ab6750e8f7d36764b83d2eaec7cdfb26 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Wed, 13 May 2015 05:40:55 +0200 Subject: added systemd service file --- contrib/systemd.service | 14 ++++++++++++++ src/Makefile | 11 +++++++++-- src/configure | 11 +++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 contrib/systemd.service diff --git a/contrib/systemd.service b/contrib/systemd.service new file mode 100644 index 0000000..7bcf48e --- /dev/null +++ b/contrib/systemd.service @@ -0,0 +1,14 @@ +[Unit] +Description=tcp proxy server + +[Service] +ExecStart=/usr/bin/tcpproxy -u tcpproxy -g tcpproxy -D +ExecReload=/bin/kill -HUP $MAINPID +Restart=on-failure +PrivateTmp=yes +PrivateDevices=yes +ProtectSystem=full +ProtectHome=yes + +[Install] +WantedBy=multi-user.target diff --git a/src/Makefile b/src/Makefile index 4524b29..b86007f 100644 --- a/src/Makefile +++ b/src/Makefile @@ -98,8 +98,8 @@ manpage: $(MAKE) --directory="../doc/" manpage -INSTALL_TARGETS := install-bin install-etc -REMOVE_TARGETS := remove-bin remove-etc +INSTALL_TARGETS := install-bin install-systemd install-etc +REMOVE_TARGETS := remove-bin remove-systemd remove-etc ifdef MANDIR INSTALL_TARGETS += install-man @@ -117,6 +117,10 @@ install-bin: $(EXECUTABLE) $(INSTALL) -d $(DESTDIR)$(BINDIR) $(INSTALL) -m 755 $(EXECUTABLE) $(DESTDIR)$(BINDIR) +install-systemd: + $(INSTALL) -d $(DESTDIR)$(SYSTEMDDIR) + $(INSTALL) -m 755 ../contrib/systemd.service $(DESTDIR)$(SYSTEMDDIR)/$(EXECUTABLE).service + install-etc: $(INSTALL) -d $(DESTDIR)$(ETCDIR)/init.d/ $(INSTALL) -m 755 ../contrib/initscript $(DESTDIR)$(ETCDIR)/init.d/$(EXECUTABLE) @@ -140,6 +144,9 @@ remove: $(REMOVE_TARGETS) remove-bin: rm -f $(DESTDIR)$(BINDIR)/$(EXECUTABLE) +remove-systemd: + rm -f $(DESTDIR)$(SYSTEMDDIR)/$(EXECUTABLE).service + remove-etc: rm -f $(DESTDIR)$(ETCDIR)/init.d/$(EXECUTABLE) diff --git a/src/configure b/src/configure index 3d8982b..d651903 100755 --- a/src/configure +++ b/src/configure @@ -33,6 +33,7 @@ USE_CLANG=0 PREFIX='/usr/local' BINDIR='' +SYSTEMDDIR='' ETCDIR='' MANDIR='' INSTALLMANPAGE=1 @@ -44,6 +45,7 @@ print_usage() { echo " --target= build target i.e. Linux (default: autodetect)" echo " --prefix= the installation prefix (default: /usr/local)" echo " --bindir= the path to the bin directory (default: $PREFIX/bin)" + echo " --systemddir= the path to the systemd service unit directory (default: /usr/lib/systemd/system)" echo " --sysconfdir= the path to the system configuration directory (default: $PREFIX/etc" echo " --mandir= the path to the system man pages (default: $PREFIX/share/man)" echo " --no-manpage dont't install manpage" @@ -67,6 +69,9 @@ do --bindir=*) BINDIR=${arg#--bindir=} ;; + --systemddir=*) + SYSTEMDDIR=${arg#--systemddir=} + ;; --sysconfdir=*) ETCDIR=${arg#--sysconfdir=} ;; @@ -133,6 +138,10 @@ if [ -z "$BINDIR" ]; then BINDIR=$PREFIX/bin fi +if [ -z "$SYSTEMDDIR" ]; then + SYSTEMDDIR=/usr/lib/systemd/system +fi + if [ -z "$ETCDIR" ]; then ETCDIR=$PREFIX/etc fi @@ -160,6 +169,7 @@ RAGEL := ragel prefix := '$PREFIX' BINDIR := '$BINDIR' +SYSTEMDDIR := '$SYSTEMDDIR' ETCDIR := '$ETCDIR' EOF @@ -206,6 +216,7 @@ cat > config.h <