]> arthur.barton.de Git - servertools.macosx.git/blob - install.sh
Log a note when unloading already configured launch daemon config
[servertools.macosx.git] / install.sh
1 #!/bin/bash
2
3 NAME="servertools.macosx"
4 PREFIX="/usr/local"
5
6 if [ -z "$*" ]; then
7         echo "Usage: `basename \"$0\"` <tool> [<tool> [...]]"
8         exit 1
9 fi
10
11 msg() {
12         echo " * $*"
13 }
14 warn() {
15         echo " > $*"
16 }
17 abort() {
18         echo -n " ! ERROR, aborting!"
19         [ -n "$*" ] && echo " ($*)" || echo
20         exit 1
21 }
22
23 install_odbackup() {
24         msg "Installing 'odbackup' ..."
25         mkdir -p $PREFIX/sbin || aboirt "mkdir"
26         install -c -m 755 -o root -g wheel \
27          odbackup/odbackup $PREFIX/sbin || abort "install odbackup"
28         launchctl list de.maccc.odbackup >/dev/null 2>&1
29         if [ $? -eq 0 ]; then
30                 msg "Unloading existing launch daemon configuration ..."
31                 launchctl unload -w \
32                         /Library/LaunchDaemons/de.maccc.odbackup.plist \
33                         || abort "unloading de.maccc.odbackup.plist"
34         fi
35         install -c -m 644 -o root -g wheel \
36          odbackup/de.maccc.odbackup.plist /Library/LaunchDaemons \
37          || abort "install de.maccc.odbackup.plist"
38         if [ -x /usr/sbin/slapconfig ]; then
39                 launchctl load -w \
40                         /Library/LaunchDaemons/de.maccc.odbackup.plist \
41                         || abort "loading de.maccc.odbackup.plist"
42                 msg "Enabled odbackup launch daemon."
43         else
44                 warn "'slapconfig' not found, not enabling launch daemon!"
45         fi
46 }
47
48 for tool in $*; do
49         type "install_${tool}" >/dev/null 2>&1
50         if [ $? -ne 0 ]; then
51                 echo "`basename \"$0\"`: tool \"${tool}\" not found!"
52                 exit 1
53         fi
54         install_${tool}
55 done