#!/bin/sh

cd /var/db/openafs/etc
# only do these checks if we're upgrading from a pre-1.2.7
if [ -f CellServDB -a ! -f CellServDB.master ]; then 
    CK=`md5 CellServDB | awk '{ print $4 }'`
    if grep -q $CK $1/Contents/Resources/CellServDB.list; then
       # it matched one of our previously released files
       echo Unmodified CellServDB -- not preserving
       :
    else
       if [ ! -f CellServDB.master.last ]; then
          echo Modified CellServDB -- saving as /var/db/openafs/etc/CellServDB.save
          echo Please re-merge it manually -- this will not be required for future upgrades
       fi
       cp CellServDB CellServDB.save
    fi
fi
if [ -f config/afsd.options -a -f config/afsd.options.sample ]; then
  if cmp -s config/afsd.options config/afs.options.sample; then
    echo Removing no-longer needed afsd.options file
    rm -f config/afsd.options
  fi
fi

if [ -f /Library/StartupItems/OpenAFS/OpenAFS ]; then
  /Library/StartupItems/OpenAFS/OpenAFS stop
fi
