mirror of
https://github.com/m13253/dns-over-https.git
synced 2026-03-30 12:05:38 +00:00
Adapt for macOS
This commit is contained in:
35
Makefile
35
Makefile
@@ -3,24 +3,41 @@
|
||||
GOBUILD=go build
|
||||
GOGET=go get -d -v
|
||||
PREFIX=/usr/local
|
||||
ifeq ($(shell uname),Darwin)
|
||||
CONFDIR=/usr/local/etc/dns-over-https
|
||||
else
|
||||
CONFDIR=/etc/dns-over-https
|
||||
endif
|
||||
|
||||
all: doh-client/doh-client doh-server/doh-server
|
||||
|
||||
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 "$(DESTDIR)$(PREFIX)/bin/doh-client"
|
||||
install -Dm0755 doh-server/doh-server "$(DESTDIR)$(PREFIX)/bin/doh-server"
|
||||
[ -e "$(DESTDIR)/etc/dns-over-https/doh-client.conf" ] || install -Dm0644 doh-client/doh-client.conf "$(DESTDIR)/etc/dns-over-https/doh-client.conf"
|
||||
[ -e "$(DESTDIR)/etc/dns-over-https/doh-server.conf" ] || install -Dm0644 doh-server/doh-server.conf "$(DESTDIR)/etc/dns-over-https/doh-server.conf"
|
||||
$(MAKE) -C systemd install "DESTDIR=$(DESTDIR)" "PREFIX=$(PREFIX)"
|
||||
$(MAKE) -C NetworkManager install "DESTDIR=$(DESTDIR)" "PREFIX=$(PREFIX)"
|
||||
install:
|
||||
[ -e doh-client/doh-client ] || $(MAKE) doh-client/doh-client
|
||||
[ -e doh-server/doh-server ] || $(MAKE) doh-server/doh-server
|
||||
mkdir -p "$(DESTDIR)$(PREFIX)/bin/"
|
||||
install -m0755 doh-client/doh-client "$(DESTDIR)$(PREFIX)/bin/doh-client"
|
||||
install -m0755 doh-server/doh-server "$(DESTDIR)$(PREFIX)/bin/doh-server"
|
||||
mkdir -p "$(DESTDIR)$(CONFDIR)/"
|
||||
[ -e "$(DESTDIR)$(CONFDIR)/doh-client.conf" ] || install -m0644 doh-client/doh-client.conf "$(DESTDIR)$(CONFDIR)/doh-client.conf"
|
||||
[ -e "$(DESTDIR)$(CONFDIR)/doh-server.conf" ] || install -m0644 doh-server/doh-server.conf "$(DESTDIR)$(CONFDIR)/doh-server.conf"
|
||||
if [ "`uname`" = "Linux" ]; then \
|
||||
$(MAKE) -C systemd install "DESTDIR=$(DESTDIR)"; \
|
||||
$(MAKE) -C NetworkManager install "DESTDIR=$(DESTDIR)"; \
|
||||
elif [ "`uname`" = "Darwin" ]; then \
|
||||
$(MAKE) -C launchd install "DESTDIR=$(DESTDIR)"; \
|
||||
fi
|
||||
|
||||
uninstall:
|
||||
rm -f "$(DESTDIR)$(PREFIX)/bin/doh-client" "$(DESTDIR)$(PREFIX)/bin/doh-server"
|
||||
$(MAKE) -C systemd uninstall "DESTDIR=$(DESTDIR)" "PREFIX=$(PREFIX)"
|
||||
$(MAKE) -C NetworkManager uninstall "DESTDIR=$(DESTDIR)" "PREFIX=$(PREFIX)"
|
||||
if [ "`uname`" = "Linux" ]; then \
|
||||
$(MAKE) -C systemd uninstall "DESTDIR=$(DESTDIR)"; \
|
||||
$(MAKE) -C NetworkManager uninstall "DESTDIR=$(DESTDIR)"; \
|
||||
elif [ "`uname`" = "Darwin" ]; then \
|
||||
$(MAKE) -C launchd uninstall "DESTDIR=$(DESTDIR)"; \
|
||||
fi
|
||||
|
||||
deps:
|
||||
$(GOGET) ./doh-client ./doh-server
|
||||
|
||||
16
launchd/Makefile
Normal file
16
launchd/Makefile
Normal file
@@ -0,0 +1,16 @@
|
||||
.PHONY: install uninstall
|
||||
|
||||
PREFIX = /usr/local
|
||||
LAUNCHD_DIR = /Library/LaunchDaemons
|
||||
|
||||
install:
|
||||
mkdir -p "$(DESTDIR)$(LAUNCHD_DIR)"
|
||||
install -m0644 doh-client.plist "$(DESTDIR)$(LAUNCHD_DIR)/doh-client.plist"
|
||||
install -m0644 doh-server.plist "$(DESTDIR)$(LAUNCHD_DIR)/doh-server.plist"
|
||||
@echo
|
||||
@echo 'Note:'
|
||||
@echo ' Use "sudo launchctl load $(DESTDIR)$(LAUNCHD_DIR)/doh-client.plist" to start doh-client,'
|
||||
@echo ' use "sudo launchctl load -w $(DESTDIR)$(LAUNCHD_DIR)/doh-server.plist" to enable doh-server.'
|
||||
|
||||
uninstall:
|
||||
rm -f "$(DESTDIR)$(LAUNCHD_DIR)/doh-client.plist" "$(DESTDIR)$(LAUNCHD_DIR)/doh-server.plist"
|
||||
27
launchd/doh-client.plist
Normal file
27
launchd/doh-client.plist
Normal file
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>Label</key>
|
||||
<string>org.eu.starlab.doh.client</string>
|
||||
<key>ProgramArguments</key>
|
||||
<array>
|
||||
<string>/usr/local/bin/doh-client</string>
|
||||
<string>-conf</string>
|
||||
<string>/usr/local/etc/dns-over-https/doh-client.conf</string>
|
||||
</array>
|
||||
<key>RunAtLoad</key>
|
||||
<true/>
|
||||
<key>UserName</key>
|
||||
<string>root</string>
|
||||
<key>GroupName</key>
|
||||
<string>wheel</string>
|
||||
<key>KeepAlive</key>
|
||||
<dict>
|
||||
<key>SuccessfulExit</key>
|
||||
<false/>
|
||||
</dict>
|
||||
<key>ThrottleInterval</key>
|
||||
<integer>5</integer>
|
||||
</dict>
|
||||
</plist>
|
||||
29
launchd/doh-server.plist
Normal file
29
launchd/doh-server.plist
Normal file
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>Label</key>
|
||||
<string>org.eu.starlab.doh.server</string>
|
||||
<key>ProgramArguments</key>
|
||||
<array>
|
||||
<string>/usr/local/bin/doh-server</string>
|
||||
<string>-conf</string>
|
||||
<string>/usr/local/etc/dns-over-https/doh-server.conf</string>
|
||||
</array>
|
||||
<key>Disabled</key>
|
||||
<true/>
|
||||
<key>RunAtLoad</key>
|
||||
<true/>
|
||||
<key>UserName</key>
|
||||
<string>root</string>
|
||||
<key>GroupName</key>
|
||||
<string>wheel</string>
|
||||
<key>KeepAlive</key>
|
||||
<dict>
|
||||
<key>SuccessfulExit</key>
|
||||
<false/>
|
||||
</dict>
|
||||
<key>ThrottleInterval</key>
|
||||
<integer>5</integer>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,6 +1,5 @@
|
||||
.PHONY: install uninstall
|
||||
|
||||
PREFIX = /usr/local
|
||||
SYSTEMD_DIR = /usr/lib/systemd
|
||||
SYSTEMD_UNIT_DIR = $(SYSTEMD_DIR)/system
|
||||
|
||||
|
||||
Reference in New Issue
Block a user