macos code signature for afsd
[openafs.git] / src / packaging / MacOS / OpenAFS.post_install
index 82f2534..8f569d2 100644 (file)
@@ -1,10 +1,24 @@
 #!/bin/sh
+# Portions Copyright (c) 2003 Apple Computer, Inc.  All rights reserved.
 if [ -d /afs -a ! -h /afs ]; then
    rmdir /afs
 fi
-mkdir -p /Network/afs
-if [ ! -h /afs ]; then
-  ln -s /Network/afs /afs
+majorvers=`uname -r | sed 's/\..*//'`
+if [ $majorvers -ge 7 ]; then
+  # /Network is now readonly, so put AFS in /afs; make sure /afs is a directory
+  if [ -e /afs ]; then
+    if [ -h /afs -o ! -d /afs ]; then
+      rm -f /afs
+      mkdir /afs
+    fi
+  else
+    mkdir /afs
+  fi
+else
+  mkdir -p /Network/afs
+  if [ ! -h /afs ]; then
+    ln -s /Network/afs /afs
+  fi
 fi
 
 cd /var/db/openafs/etc
@@ -13,6 +27,49 @@ if [ ! -f cacheinfo ]; then
    cp cacheinfo.sample cacheinfo
 fi
 
+if [ `grep /Network/afs cacheinfo` ]; then
+    cat cacheinfo |sed s#/Network/afs#/afs# > cacheinfo.new
+    mv cacheinfo.new cacheinfo
+fi
+
+# if the installer plugin generated ThisCell and/or CellAlias
+# files, copy them in here
+tmpthiscell=/private/tmp/org.OpenAFS.Install.ThisCell.$USER
+tmpcellalias=/private/tmp/org.OpenAFS.Install.CellAlias.$USER
+if [ -f $tmpthiscell ]; then
+    cp $tmpthiscell ThisCell
+    rm -f $tmpthiscell
+fi
+if [ -f $tmpcellalias ]; then
+    cp $tmpcellalias CellAlias
+    rm -f $tmpcellalias
+fi
+
+if [ ! -f ThisCell -a -f ThisCell.sample ]; then
+   cp ThisCell.sample ThisCell
+fi
+
+# force reversion of 10.4 memcache mistake
+rm -f config/afsd.options.broken
+echo '-memcache -afsdb -stat 2000 -dcache 800 -daemons 3 -volumes 70 -dynroot -fakestat-all' > config/afsd.options.broken
+if cmp -s config/afsd.options.broken config/afsd.options ; then
+   rm -f config/afsd.options
+fi
+rm -f config/afsd.options.broken
+
+# if the user hasn't changed these settings, then they should just use the new
+# afsd.conf file
+rm -f config/afsd.options.old
+echo '-afsdb -stat 2000 -dcache 800 -daemons 3 -volumes 70 -dynroot -fakestat-all' >config/afsd.options.old
+if cmp -s config/afsd.options.old config/afsd.options ; then
+   rm -f config/afsd.options
+fi
+rm -f config/afsd.options.old
+
+if [ ! -f config/afs.conf -a -f config/afs.conf.sample ]; then
+   cp config/afs.conf.sample config/afs.conf
+fi
+
 # testing case -- upgrading from pre 1.2.7, but .last file exists.
 # merge the .save and .last....
 if [ ! -f CellServDB -a -f CellServDB.save -a -f CellServDB.master.last ]; then
@@ -32,6 +89,9 @@ if [ -z "$done" -a  -f CellServDB ]; then
   if cmp -s CellServDB CellServDB.master ; then
     echo CellServDB is up to date.
     cp CellServDB.master CellServDB.master.last
+    if [ ! -f CellServDB ]; then
+      cp CellServDB.master CellServDB
+    fi
     done=1
   fi
 fi
@@ -46,6 +106,29 @@ if [ -z "$done" ]; then
     # this is a new install, or an upgrade from pre-1.2.7
     echo "Installing new CellServDB"
     cp CellServDB.master CellServDB.master.last
-    cp CellServDB.master CellServDB
+    if [ ! -f CellServDB ]; then
+       cp CellServDB.master CellServDB
+    fi
   fi
 fi
+
+if [ $majorvers -ge 7 ]; then
+  # make config/settings.plist if it doesn't exist
+  if [ ! -e config/settings.plist -a -e config/settings.plist.orig ]; then
+    cp config/settings.plist.orig config/settings.plist
+  fi
+elif [ -e config/afssettings ]; then
+  # turn off execution of afssettings
+  chmod a-x config/afssettings
+fi
+
+# properly, we should acquire a certificate from a real CA and ship 
+# signed binaries. for now, make Application Firewall (Security prefs pane)
+# happy like this. See TN2206
+if [ -f /usr/bin/codesign ]; then
+  codesign -s - /usr/sbin/afsd
+fi
+
+#here we should run tools which configure the client, and then if it's enabled:
+#start the new launchd daemon
+launchctl load -w /Library/LaunchDaemons/org.openafs.filesystems.afs.plist