Skip to content

Instantly share code, notes, and snippets.

@jonyesno
Created April 23, 2012 03:41
Show Gist options
  • Save jonyesno/2468712 to your computer and use it in GitHub Desktop.
Save jonyesno/2468712 to your computer and use it in GitHub Desktop.
runit/dnscache setup for OS X
#!/bin/sh
# taken from http://qmail.jms1.net/djbdns/osx.shtml
# find appropriate uid/gids by $ dscl . -list /Users UniqueID | sort -n -k2
# if you are working with a directory services path other than the
# local machine, put the correct path here.
DSPATH="."
# if you need different numeric UID/GID values, set them here
NGID="300" # for group djbdns
RUID="300" # for user dnsrun
LUID="301" # for user dnslog
dscl "$DSPATH" create /Groups/djbdns PrimaryGroupID $NGID
dscl "$DSPATH" create /Users/dnsrun UniqueID $RUID
dscl "$DSPATH" create /Users/dnsrun PrimaryGroupID $NGID
dscl "$DSPATH" create /Users/dnsrun UserShell /bin/false
dscl "$DSPATH" create /Users/dnsrun NFSHomeDirectory /nohome
dscl "$DSPATH" create /Users/dnsrun RealName dnsrun
dscl "$DSPATH" create /Users/dnslog UniqueID $LUID
dscl "$DSPATH" create /Users/dnslog PrimaryGroupID $NGID
dscl "$DSPATH" create /Users/dnslog UserShell /bin/false
dscl "$DSPATH" create /Users/dnslog NFSHomeDirectory /nohome
dscl "$DSPATH" create /Users/dnslog RealName dnslog
dscl "$DSPATH" create /Groups/djbdns GroupMembership dnsrun dnslog
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.smarden.runit</string>
<key>ServiceDescription</key>
<string>runit</string>
<key>ProgramArguments</key>
<array>
<string>/opt/local/bin/runsvdir</string>
<string>/opt/local/var/service</string>
<string>................................</string>
</array>
<key>OnDemand</key>
<false/>
<key>WorkingDirectory</key>
<string>/opt/local/var/service</string>
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>/opt/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin</string>
</dict>
</dict>
</plist>
@jonyesno
Copy link
Author

$ sudo mkdir -p /opt/local/var/service
$ sudo /opt/local/bin/dnscache-conf dnsrun dnslog /opt/local/var/dnscache 127.0.0.1
$ sudo ln -nsf /opt/local/var/dnscache /opt/local/var/service/dnscache
$ sudo cp launchd-config-for-runit.plist /Library/LaunchDaemons/org.smarden.runit.plist
$ sudo launchctl load /Library/LaunchDaemons/org.smarden.runit.plist
$ sudo launchctl start org.smarden.runit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment