OSX Launchd Startup Manage with Preference Pane
[openafs.git] / src / packaging / MacOS / OpenAFS.pre_upgrade
1 #!/bin/sh
2 DAEMON=/private/var/db/openafs/etc/launchafs.sh
3 DAEMON_LAUNCHD_SCRIPT=/Library/LaunchDaemons/org.openafs.filesystems.afs.plist
4 DAEMON_UP=$(ps -ef | grep "$DAEMON_NAME" | grep -v grep | wc -l)
5 PREFERENCE_PANE=/Library/PreferencePanes/OpenAFS.prefPane
6
7 cd /var/db/openafs/etc
8 # only do these checks if we're upgrading from a pre-1.2.7
9 if [ -f CellServDB -a ! -f CellServDB.master ]; then 
10     CK=`md5 CellServDB | awk '{ print $4 }'`
11     if grep -q $CK $1/Contents/Resources/CellServDB.list; then
12        # it matched one of our previously released files
13        echo Unmodified CellServDB -- not preserving
14        :
15     else
16        if [ ! -f CellServDB.master.last ]; then
17           echo Modified CellServDB -- saving as /var/db/openafs/etc/CellServDB.save
18           echo Please re-merge it manually -- this will not be required for future upgrades
19        fi
20        cp CellServDB CellServDB.save
21     fi
22 fi
23 if [ -f config/afsd.options -a -f config/afsd.options.sample ]; then
24   if cmp -s config/afsd.options config/afs.options.sample; then
25     echo Removing no-longer needed afsd.options file
26     rm -f config/afsd.options
27   fi
28 fi
29
30 if [ -f /Library/StartupItems/OpenAFS/OpenAFS ]; then
31   /Library/StartupItems/OpenAFS/OpenAFS stop
32 else
33   if [ -f /Library/LaunchDaemons/org.openafs.filesystems.afs.plist ]; then
34         if ps ax | grep -v grep | grep $DAEMON > /dev/null
35         then
36                 launchctl stop org.openafs.filesystems.afs
37         else
38                 echo "$DAEMON is not running"
39         fi
40
41         launchctl unload -w $DAEMON_LAUNCHD_SCRIPT
42   fi
43 fi
44
45 if [ -d /Library/PreferencePanes/OpenAFS.prefPane ]; then
46         rm -R /Library/PreferencePanes/OpenAFS.prefPane
47 fi