chiark / gitweb /
portability: Scripts and documentation for Mac OS X support.
authorRichard Kettlewell <rjk@greenend.org.uk>
Sun, 19 Jun 2011 08:08:17 +0000 (09:08 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 26 Jun 2011 11:07:28 +0000 (12:07 +0100)
Signed-off-by: Richard Kettlewell <richard@greenend.org.uk>
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Makefile.in
README.mac [new file with mode: 0644]
setup.mac [new file with mode: 0755]
uk.org.greenend.secnet.plist [new file with mode: 0644]

index e5ea84b..d339444 100644 (file)
@@ -60,6 +60,7 @@ OBJECTS:=secnet.o util.o conffile.yy.o conffile.tab.o conffile.o modules.o \
 DISTDIRS:=debian
 DISTFILES:=BUGS COPYING CREDITS INSTALL LICENSE.txt Makefile.in \
        NEWS NOTES README TODO \
+       setup.mac uk.org.greenend.secnet.plist README.mac \
        ac_prog_cc_no_writeable_strings.m4 \
        conffile.c conffile.fl conffile.h conffile.y \
        conffile_internal.h \
diff --git a/README.mac b/README.mac
new file mode 100644 (file)
index 0000000..899f4d1
--- /dev/null
@@ -0,0 +1,31 @@
+How to install secnet on a Fink-equipped OS X system:
+  - Install GMP:
+    fink install gmp
+  - Download and install ADNS:
+    ./configure --disable-dynamic
+    make
+    sudo make install
+  - Build secnet:
+    ./configure CPPFLAGS=-I/sw/include LDFLAGS=-L/sw/lib
+    make
+    sudo make install
+  - Install tuntap for OSX from http://tuntaposx.sourceforge.net/
+  - Create /etc/secnet/{key,secnet.conf,sites.conf} as usual
+  - If you don't want secnet 'always on', edit
+    uk.org.greenend.secnet.plist and remove *both* these two lines:
+        <key>RunAtLoad</key>
+        <true/>
+  - Create the 'secnet' user and install the job configuration:
+    ./setup.mac.
+
+To start secnet:
+  sudo launchctl start uk.org.greenend.secnet
+
+To stop secnet:
+  sudo launchctl stop uk.org.greenend.secnet
+
+To uninstall:
+  sudo launchctl unload uk.org.greenend.secnet
+  sudo rm -f /Library/LaunchDaemons/uk.org.greenend.secnet.plist
+
+Richard Kettlewell 2011-06-18
diff --git a/setup.mac b/setup.mac
new file mode 100755 (executable)
index 0000000..4473a2e
--- /dev/null
+++ b/setup.mac
@@ -0,0 +1,66 @@
+#!/bin/bash
+#
+# Richard Kettlewell 2011-06-18
+#
+set -e
+
+group=${group:-secnet}
+user=${user:-secnet}
+
+# pick ID1 ID2 ... IDn
+# Echoes an ID matching none of ID1..IDn
+pick() {
+  local n
+  n=250                                # better not choose 0!
+  while :; do
+    ok=true
+    for k in "$@"; do
+      if [ $n = $k ]; then
+        ok=false
+        break
+      fi
+    done
+    if $ok; then
+      echo $n
+      return
+    fi
+    n=$((1+$n))
+  done
+}
+
+if dscl . -read /Groups/$group >/dev/null 2>&1; then
+  :
+else
+  gids=$(dscl . -list /Groups PrimaryGroupID|awk '{print $2}')
+  gid=$(pick $gids)
+  dscl . -create /Groups/$group
+  dscl . -create /Groups/$group PrimaryGroupID $gid
+  dscl . -create /Groups/$group Password \*
+fi
+
+if dscl . -read /Users/$user >/dev/null 2>&1; then
+  :
+else
+  uids=$(dscl . -list /Users UniqueID|awk '{print $2}')
+  uid=$(pick $uids)
+  gid=$(dscl . -read /Groups/$group PrimaryGroupID | awk '{print $2}')
+  dscl . -create /Users/$user
+  dscl . -create /Users/$user UniqueID $uid
+  dscl . -create /Users/$user UserShell /usr/bin/false
+  dscl . -create /Users/$user RealName 'secnet'
+  dscl . -create /Users/$user NFSHomeDirectory pkgstatedir
+  dscl . -create /Users/$user PrimaryGroupID $gid
+  dscl . -create /Users/$user Password \*
+fi
+
+cp uk.org.greenend.secnet.plist /Library/LaunchDaemons/.
+launchctl load /Library/LaunchDaemons
+echo "To start secnet:"
+echo "  sudo launchctl start uk.org.greenend.secnet"
+echo
+echo "To stop secnet:"
+echo "  sudo launchctl stop uk.org.greenend.secnet"
+echo
+echo "To uninstall:"
+echo "  sudo launchctl unload uk.org.greenend.secnet"
+echo "  sudo rm -f /Library/LaunchDaemons/uk.org.greenend.secnet.plist"
diff --git a/uk.org.greenend.secnet.plist b/uk.org.greenend.secnet.plist
new file mode 100644 (file)
index 0000000..f80184b
--- /dev/null
@@ -0,0 +1,24 @@
+<?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>EnvironmentVariables</key>
+       <dict>
+               <key>LANG</key>
+               <string>en_GB.UTF-8</string>
+               <key>LC_ALL</key>
+               <string>en_GB.UTF-8</string>
+       </dict>
+       <key>Label</key>
+       <string>uk.org.greenend.secnet</string>
+       <key>ProgramArguments</key>
+       <array>
+               <string>/usr/local/sbin/secnet</string>
+               <string>-n</string>
+       </array>
+       <key>WorkingDirectory</key>
+       <string>/</string>
+       <key>RunAtLoad</key>
+       <true/>
+</dict>
+</plist>