New make target: "osxpkg" to create an Mac OS X installer package.
[ngircd-alex.git] / contrib / MacOSX / postinstall.sh
1 #!/bin/sh
2 # ngIRCd Mac OS X postinstall/postupgrade script
3
4 LDPLIST="/Library/LaunchDaemons/de.barton.ngircd.plist"
5
6 if [ ! -e /etc/ngircd ]; then
7         echo "Creating symlink: /opt/ngircd/etc -> /etc/ngircd"
8         ln -s /opt/ngircd/etc /etc/ngircd || exit 1
9 else
10         echo "/etc/ngircd already exists. Don't create symlink."
11 fi
12
13 if [ ! -e /opt/ngircd/etc/ngircd.conf ]; then
14         echo "Creating default configuration: /opt/ngircd/etc/ngircd.conf"
15         cp /opt/ngircd/share/doc/ngircd/sample-ngircd.conf \
16          /opt/ngircd/etc/ngircd.conf || exit 1
17 else
18         echo "/opt/ngircd/etc/ngircd.conf exists. Don't copy sample file."
19 fi
20 chmod o-rwx /opt/ngircd/etc/ngircd.conf
21
22 if [ -f "$LDPLIST" ]; then
23         echo "Fixing ownership and permissions of LaunchDaemon script ..."
24         chown root:wheel "$LDPLIST" || exit 1
25         chmod 644 "$LDPLIST" || exit 1
26 fi
27
28 if [ -f /tmp/ngircd_needs_restart ]; then
29         echo "ngIRCd should be (re-)started ..."
30         if [ -r "$LDPLIST" ]; then
31                 echo "LaunchDaemon script found, starting daemon ..."
32                 launchctl load -w "$LDPLIST" || exit 1
33                 echo "OK, LaunchDaemon script loaded successfully."
34         else
35                 echo "LaunchDaemon script not installed. Can't start daemon."
36         fi
37 else
38         echo "Not loading LaunchDaemon script."
39 fi
40 rm -f /tmp/ngircd_needs_restart
41
42 # -eof-