Skip to content

Commit

Permalink
make it a macOS service
Browse files Browse the repository at this point in the history
  • Loading branch information
kamarya committed Feb 18, 2017
1 parent 29e686a commit 065347a
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 4 deletions.
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ all: dnssec.c
gcc -g -Wall dnssec.c -lcurl -std=gnu99 -o dnsd
install:
cp dnsd.conf /etc/dnsd.conf
cp dnsd /usr/sbin/
cp dnsd /usr/local/bin/
linux-service:
cp service/dnsd.service /lib/systemd/system/
chmod 644 /lib/systemd/system/dnsd.service
cp service/dnsd /etc/init.d/
chmod 755 /etc/init.d/dnsd
macos-service:
cp service/service.dnsd.plist /Library/LaunchDaemons
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ make linux-service
systemctl daemon-reload
service dnsd start
```
For macOS systems install and launch the service as follows.
```
make macos-service
launchctl load /Library/LaunchDaemons/service.dnsd.plist
```
### Verification
You can verify wether the service is accessible through ```host -va github.com localhost```.
```
Expand Down
3 changes: 1 addition & 2 deletions service/dnsd
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ set -e

# Source function library.

PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/dnsd
DAEMON=/usr/local/bin/dnsd
NAME=dnsd
DESC="DNSd Daemon"
PIDFILE=/var/run/$NAME.pid
Expand Down
2 changes: 1 addition & 1 deletion service/dnsd.service
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ After=network.target
[Service]
Type=forking
PIDFile=/var/run/dnsd.pid
ExecStart=/usr/sbin/dnsd -f /etc/dnsd.conf
ExecStart=/usr/local/bin/dnsd -f /etc/dnsd.conf
KillMode=process
Restart=on-failure

Expand Down
17 changes: 17 additions & 0 deletions service/service.dnsd.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>service.dnsd</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/dnsd</string>
<string>-f</string>
<string>/etc/dnsd.conf</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>

0 comments on commit 065347a

Please sign in to comment.