6961950b051582e77922464a12e943c86c9bebae
[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 [ ! -f ThisCell -a -f ThisCell.sample ]; then
36    cp ThisCell.sample ThisCell
37 fi
38
39 # force reversion of 10.4 memcache mistake
40 rm -f config/afsd.options.broken
41 echo '-memcache -afsdb -stat 2000 -dcache 800 -daemons 3 -volumes 70 -dynroot -fakestat-all' > config/afsd.options.broken
42 if cmp -s config/afsd.options.broken config/afsd.options ; then
43    rm -f config/afsd.options
44 fi
45 rm -f config/afsd.options.broken
46
47 # if the user hasn't changed these settings, then they should just use the new
48 # afsd.conf file
49 rm -f config/afsd.options.old
50 echo '-afsdb -stat 2000 -dcache 800 -daemons 3 -volumes 70 -dynroot -fakestat-all' >config/afsd.options.old
51 if cmp -s config/afsd.options.old config/afsd.options ; then
52    rm -f config/afsd.options
53 fi
54 rm -f config/afsd.options.old
55
56 if [ ! -f config/afs.conf -a -f config/afs.conf.sample ]; then
57    cp config/afs.conf.sample config/afs.conf
58 fi
59
60 # testing case -- upgrading from pre 1.2.7, but .last file exists.
61 # merge the .save and .last....
62 if [ ! -f CellServDB -a -f CellServDB.save -a -f CellServDB.master.last ]; then
63    cp CellServDB.save CellServDB
64 fi
65
66 # upgrading between 2 post-1.2.7 releases (or the testing case)
67 if [ -f CellServDB.master.last ]; then
68   if cmp -s CellServDB.master.last CellServDB.master ; then
69     echo No CellServDB updates
70     done=1
71   fi
72 fi
73
74 # the local changes were included in the update
75 if [ -z "$done" -a  -f CellServDB ]; then
76   if cmp -s CellServDB CellServDB.master ; then
77     echo CellServDB is up to date.
78     cp CellServDB.master CellServDB.master.last
79     if [ ! -f CellServDB ]; then
80       cp CellServDB.master CellServDB
81     fi
82     done=1
83   fi
84 fi
85
86 if [ -z "$done" ]; then
87   # there are local changes to be merged
88   if [ -f CellServDB -a -f CellServDB.master.last ]; then
89     echo Merging CellServDB entries....
90     perl $1/Contents/Resources/csrvdbmerge.pl
91     echo done
92   else
93     # this is a new install, or an upgrade from pre-1.2.7
94     echo "Installing new CellServDB"
95     cp CellServDB.master CellServDB.master.last
96     if [ ! -f CellServDB ]; then
97         cp CellServDB.master CellServDB
98     fi
99   fi
100 fi
101
102 if [ $majorvers -ge 7 ]; then
103   # make config/settings.plist if it doesn't exist
104   if [ ! -e config/settings.plist -a -e config/settings.plist.orig ]; then
105     cp config/settings.plist.orig config/settings.plist
106   fi
107 elif [ -e config/afssettings ]; then
108   # turn off execution of afssettings
109   chmod a-x config/afssettings
110 fi