8f569d2bc0a8dc94139f8a4a85dee86d55f9bd5c
[openafs.git] / src / packaging / MacOS / OpenAFS.post_install
1 #!/bin/sh
2 # Portions Copyright (c) 2003 Apple Computer, Inc.  All rights reserved.
3 if [ -d /afs -a ! -h /afs ]; then
4    rmdir /afs
5 fi
6 majorvers=`uname -r | sed 's/\..*//'`
7 if [ $majorvers -ge 7 ]; then
8   # /Network is now readonly, so put AFS in /afs; make sure /afs is a directory
9   if [ -e /afs ]; then
10     if [ -h /afs -o ! -d /afs ]; then
11       rm -f /afs
12       mkdir /afs
13     fi
14   else
15     mkdir /afs
16   fi
17 else
18   mkdir -p /Network/afs
19   if [ ! -h /afs ]; then
20     ln -s /Network/afs /afs
21   fi
22 fi
23
24 cd /var/db/openafs/etc
25
26 if [ ! -f cacheinfo ]; then
27    cp cacheinfo.sample cacheinfo
28 fi
29
30 if [ `grep /Network/afs cacheinfo` ]; then
31     cat cacheinfo |sed s#/Network/afs#/afs# > cacheinfo.new
32     mv cacheinfo.new cacheinfo
33 fi
34
35 # if the installer plugin generated ThisCell and/or CellAlias
36 # files, copy them in here
37 tmpthiscell=/private/tmp/org.OpenAFS.Install.ThisCell.$USER
38 tmpcellalias=/private/tmp/org.OpenAFS.Install.CellAlias.$USER
39 if [ -f $tmpthiscell ]; then
40     cp $tmpthiscell ThisCell
41     rm -f $tmpthiscell
42 fi
43 if [ -f $tmpcellalias ]; then
44     cp $tmpcellalias CellAlias
45     rm -f $tmpcellalias
46 fi
47
48 if [ ! -f ThisCell -a -f ThisCell.sample ]; then
49    cp ThisCell.sample ThisCell
50 fi
51
52 # force reversion of 10.4 memcache mistake
53 rm -f config/afsd.options.broken
54 echo '-memcache -afsdb -stat 2000 -dcache 800 -daemons 3 -volumes 70 -dynroot -fakestat-all' > config/afsd.options.broken
55 if cmp -s config/afsd.options.broken config/afsd.options ; then
56    rm -f config/afsd.options
57 fi
58 rm -f config/afsd.options.broken
59
60 # if the user hasn't changed these settings, then they should just use the new
61 # afsd.conf file
62 rm -f config/afsd.options.old
63 echo '-afsdb -stat 2000 -dcache 800 -daemons 3 -volumes 70 -dynroot -fakestat-all' >config/afsd.options.old
64 if cmp -s config/afsd.options.old config/afsd.options ; then
65    rm -f config/afsd.options
66 fi
67 rm -f config/afsd.options.old
68
69 if [ ! -f config/afs.conf -a -f config/afs.conf.sample ]; then
70    cp config/afs.conf.sample config/afs.conf
71 fi
72
73 # testing case -- upgrading from pre 1.2.7, but .last file exists.
74 # merge the .save and .last....
75 if [ ! -f CellServDB -a -f CellServDB.save -a -f CellServDB.master.last ]; then
76    cp CellServDB.save CellServDB
77 fi
78
79 # upgrading between 2 post-1.2.7 releases (or the testing case)
80 if [ -f CellServDB.master.last ]; then
81   if cmp -s CellServDB.master.last CellServDB.master ; then
82     echo No CellServDB updates
83     done=1
84   fi
85 fi
86
87 # the local changes were included in the update
88 if [ -z "$done" -a  -f CellServDB ]; then
89   if cmp -s CellServDB CellServDB.master ; then
90     echo CellServDB is up to date.
91     cp CellServDB.master CellServDB.master.last
92     if [ ! -f CellServDB ]; then
93       cp CellServDB.master CellServDB
94     fi
95     done=1
96   fi
97 fi
98
99 if [ -z "$done" ]; then
100   # there are local changes to be merged
101   if [ -f CellServDB -a -f CellServDB.master.last ]; then
102     echo Merging CellServDB entries....
103     perl $1/Contents/Resources/csrvdbmerge.pl
104     echo done
105   else
106     # this is a new install, or an upgrade from pre-1.2.7
107     echo "Installing new CellServDB"
108     cp CellServDB.master CellServDB.master.last
109     if [ ! -f CellServDB ]; then
110         cp CellServDB.master CellServDB
111     fi
112   fi
113 fi
114
115 if [ $majorvers -ge 7 ]; then
116   # make config/settings.plist if it doesn't exist
117   if [ ! -e config/settings.plist -a -e config/settings.plist.orig ]; then
118     cp config/settings.plist.orig config/settings.plist
119   fi
120 elif [ -e config/afssettings ]; then
121   # turn off execution of afssettings
122   chmod a-x config/afssettings
123 fi
124
125 # properly, we should acquire a certificate from a real CA and ship 
126 # signed binaries. for now, make Application Firewall (Security prefs pane)
127 # happy like this. See TN2206
128 if [ -f /usr/bin/codesign ]; then
129   codesign -s - /usr/sbin/afsd
130 fi
131
132 #here we should run tools which configure the client, and then if it's enabled:
133 #start the new launchd daemon
134 launchctl load -w /Library/LaunchDaemons/org.openafs.filesystems.afs.plist