systemd service configuration and make install target
authorJames Bunton <jamesbunton@delx.net.au>
Tue, 22 Sep 2015 09:57:34 +0000 (09:57 +0000)
committerJames Bunton <jamesbunton@delx.net.au>
Tue, 22 Sep 2015 09:57:34 +0000 (09:57 +0000)
Makefile
socks5server.conf [new file with mode: 0644]
socks5server.service [new file with mode: 0644]

index cf1ab52..5732821 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,5 @@
 VERSION := 0.1
+PREFIX  := /usr/local
 CFLAGS  += -Wall -Wextra -Werror -std=c99 -DVERSION='"$(VERSION)"'
 LDFLAGS += -lpthread -lbsd
 
@@ -8,7 +9,13 @@ socks5server: socks5server.c
 test: socks5server
        ./test_proxy.py
 
+install: socks5server
+       install -m 0755 -D -t $(PREFIX)/bin socks5server
+       install -m 0644 -D -t $(PREFIX)/etc socks5server.conf
+       install -m 0644 -D -t $(PREFIX)/lib/systemd/system socks5server.service
+       sed -i 's|PREFIX|$(PREFIX)|g' $(PREFIX)/lib/systemd/system/socks5server.service
+
 clean:
        rm -f socks5server
-.PHONY: clean
 
+.PHONY: clean install test
diff --git a/socks5server.conf b/socks5server.conf
new file mode 100644 (file)
index 0000000..ee976da
--- /dev/null
@@ -0,0 +1,6 @@
+LISTEN_PORT=1080
+
+#ALLOW_ALL=1
+
+#ALLOW_HOST_1=example.com
+#ALLOW_HOST_2=fe80::1
diff --git a/socks5server.service b/socks5server.service
new file mode 100644 (file)
index 0000000..9dc2b9d
--- /dev/null
@@ -0,0 +1,22 @@
+[Unit]
+Description=SOCKS5 Server
+After=network.target
+Requires=network.target
+
+[Service]
+EnvironmentFile=PREFIX/etc/socks5server.conf
+ExecStart=PREFIX/bin/socks5server
+Restart=on-failure
+RestartSec=60s
+StartLimitInterval=0
+
+User=daemon
+PrivateTmp=true
+PrivateDevices=true
+ProtectSystem=true
+ProtectHome=true
+NoNewPrivileges=true
+InaccessibleDirectories=/home
+
+[Install]
+WantedBy=multi-user.target