Import Upstream version 1.8.5
[hcoop/debian/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 else
120 /usr/libexec/PlistBuddy -c "Add :Darwin:All:FSEvents bool" config/settings.plist && /usr/libexec/PlistBuddy -c "Set :Darwin:All:FSEvents true" config/settings.plist
121 fi
122 elif [ -e config/afssettings ]; then
123 # turn off execution of afssettings
124 chmod a-x config/afssettings
125 fi
126
127 # properly, we should acquire a certificate from a real CA and ship
128 # signed binaries. for now, make Application Firewall (Security prefs pane)
129 # happy like this. See TN2206
130 if [ $majorvers -lt 14 ]; then
131 if [ -f /usr/bin/codesign ]; then
132 codesign -s - /usr/sbin/afsd
133 fi
134 fi
135
136 #here we should run tools which configure the client, and then if it's enabled:
137 #start the new launchd daemon
138 launchctl load -w /Library/LaunchDaemons/org.openafs.filesystems.afs.plist