c840b1897708d23eb85e33fd52f679258761054d
[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 if [ ! -f config/afsd.options -a -f config/afsd.options.sample ]; then
40    cp config/afsd.options.sample config/afsd.options
41 fi
42
43 # testing case -- upgrading from pre 1.2.7, but .last file exists.
44 # merge the .save and .last....
45 if [ ! -f CellServDB -a -f CellServDB.save -a -f CellServDB.master.last ]; then
46    cp CellServDB.save CellServDB
47 fi
48
49 # upgrading between 2 post-1.2.7 releases (or the testing case)
50 if [ -f CellServDB.master.last ]; then
51   if cmp -s CellServDB.master.last CellServDB.master ; then
52     echo No CellServDB updates
53     done=1
54   fi
55 fi
56
57 # the local changes were included in the update
58 if [ -z "$done" -a  -f CellServDB ]; then
59   if cmp -s CellServDB CellServDB.master ; then
60     echo CellServDB is up to date.
61     cp CellServDB.master CellServDB.master.last
62     if [ ! -f CellServDB ]; then
63       cp CellServDB.master CellServDB
64     fi
65     done=1
66   fi
67 fi
68
69 if [ -z "$done" ]; then
70   # there are local changes to be merged
71   if [ -f CellServDB -a -f CellServDB.master.last ]; then
72     echo Merging CellServDB entries....
73     perl $1/Contents/Resources/csrvdbmerge.pl
74     echo done
75   else
76     # this is a new install, or an upgrade from pre-1.2.7
77     echo "Installing new CellServDB"
78     cp CellServDB.master CellServDB.master.last
79     if [ ! -f CellServDB ]; then
80         cp CellServDB.master CellServDB
81     fi
82   fi
83 fi
84
85 if [ $majorvers -ge 7 ]; then
86   # make config/settings.plist if it doesn't exist
87   if [ ! -e config/settings.plist -a -e config/settings.plist.orig ]; then
88     cp config/settings.plist.orig config/settings.plist
89   fi
90 elif [ -e config/afssettings ]; then
91   # turn off execution of afssettings
92   chmod a-x config/afssettings
93 fi
94
95 #here we should run tools which configure the client, and then if it's enabled:
96 /Library/StartupItems/OpenAFS/OpenAFS start
97