Add systemd units

This commit is contained in:
Star Brilliant
2017-10-04 01:10:58 +08:00
parent c4a57edc7f
commit 3230cc0a0a
4 changed files with 49 additions and 5 deletions

View File

@@ -9,13 +9,13 @@ clean:
rm -f doh-client/doh-client doh-server/doh-server
install: doh-client/doh-client doh-server/doh-server
install -Dm0755 doh-client/doh-client $(PREFIX)/bin/doh-client
install -Dm0755 doh-server/doh-server $(PREFIX)/bin/doh-server
setcap cap_net_bind_service=+ep $(PREFIX)/bin/doh-client
setcap cap_net_bind_service=+ep $(PREFIX)/bin/doh-server
install -Dm0755 doh-client/doh-client "$(DESTDIR)$(PREFIX)/bin/doh-client"
install -Dm0755 doh-server/doh-server "$(DESTDIR)$(PREFIX)/bin/doh-server"
$(MAKE) -C systemd install "DESTDIR=$(DESTDIR)" "PREFIX=$(PREFIX)"
uninstall:
rm -f $(PREFIX)/bin/doh-client $(PREFIX)/bin/doh-server
rm -f "$(DESTDIR)$(PREFIX)/bin/doh-client" "$(DESTDIR)$(PREFIX)/bin/doh-server"
$(MAKE) -C systemd uninstall "DESTDIR=$(DESTDIR)" "PREFIX=$(PREFIX)"
doh-client/doh-client: doh-client/client.go doh-client/main.go json-dns/error.go json-dns/globalip.go json-dns/marshal.go json-dns/response.go json-dns/unmarshal.go
cd doh-client && $(GOBUILD)

14
systemd/Makefile Normal file
View File

@@ -0,0 +1,14 @@
.PHONY: install uninstall
PREFIX = /usr/local
SYSTEMD_DIR = /usr/lib/systemd
SYSTEMD_UNIT_DIR = $(SYSTEMD_DIR)/system
install:
install -Dm0644 doh-client.service "$(DESTDIR)$(SYSTEMD_UNIT_DIR)/doh-client.service"
install -Dm0644 doh-server.service "$(DESTDIR)$(SYSTEMD_UNIT_DIR)/doh-server.service"
systemctl daemon-reload || true
uninstall:
rm -f "$(DESTDIR)$(SYSTEMD_UNIT_DIR)/doh-client.service" "$(DESTDIR)$(SYSTEMD_UNIT_DIR)/doh-server.service"
systemctl daemon-reload || true

View File

@@ -0,0 +1,15 @@
[Unit]
Description=DNS-over-HTTPS Client
After=network.target
[Service]
AmbientCapabilities=CAP_NET_BIND_SERVICE
ExecStart=/usr/local/bin/doh-client -addr :53 -upstream https://dns.google.com/resolve
LimitNOFILE=1048576
Restart=always
RestartSec=3
Type=simple
User=nobody
[Install]
WantedBy=multi-user.target

View File

@@ -0,0 +1,15 @@
[Unit]
Description=DNS-over-HTTPS Server
After=network.target
[Service]
AmbientCapabilities=CAP_NET_BIND_SERVICE
ExecStart=/usr/local/bin/doh-server
LimitNOFILE=1048576
Restart=always
RestartSec=3
Type=simple
User=nobody
[Install]
WantedBy=multi-user.target