#!/bin/bash
# go from panther to tiger -
# If you call this with the argument "createzip", it will create the zipfile
# for publishing. About 7-8GB free space needed then.
#
# Search for CISCO to see what's specific to us
# Also, since we change radmind versions with the upgrade, we include
# new fsdiff, ktcheck and lapply binaries in $mydir.
### CISCO
oldflag=/etc/TACSUNS/flags/do-not-radmind
statedir=/var/radmind/state
zipfile=/local/panther2tiger.zip
### CISCO - end
# We put the tiger transcripts on a different radmind with a different port. Set to 6662 if you don't.
port=6664
# We have the prebinding patch installed. Set to m= if you don't.
m=-msha1
radhost=radhost.company.com
libdir=/var/radmind/tmp/lib
applyfile=/var/radmind/tmp/tiger-apply.T
PROG=$0
case "$PROG" in /*) ;; *) PROG="$PWD/$PROG" ;; esac
mydir=`dirname "$PROG"`
updateneg=$mydir/update-negative.T
export PATH=$mydir:/bin:/usr/bin:/sbin:/usr/sbin
if [ ! -e "$updateneg" ]; then
echo "I can't figure out where I live, $mydir doesn't contain update-negative.T"
exit 2
fi
createzip=
if [ "$1" = "createzip" ]; then
createzip=true
echo Will create zipfile $zipfile
fi
die() {
[ -n "$1" ] && echo "$@"
exit 1
}
### CISCO
# turn off radmind updates, wait until radmind stops
touch "$oldflag"
while /etc/operator/sbin/is-radmind-running; do
echo Waiting for the current radmind to stop...
sleep 5
done
# Our tiger install uses /var/radmind/state to know what's specific to the current system
mkdir -p "$statedir"
touch "$statedir"/do-not-radmind
touch "$statedir"/tiger
### CISCO - end
# download new state
echo "Downloading new command files and transcripts"
ktcheck -w2 -h$radhost -p $port
[ "$?" -le 1 ] || die "failed to download updates"
# remove negatives
for i in /var/radmind/client/*.K; do
mv $i $i.old
sed 's/^n/#n/' < $i.old > $i
done
cp $updateneg /var/radmind/client/ || die "failed to apply update negative transcript"
echo n `basename "$updateneg"` >> /var/radmind/client/command.K || die "failed to apply update negative transcript"
# fix case for some files
echo Starting update...
mv /Library/CFMSupport/StuffItEngineShell.cfm /Library/CFMSupport/StuffItEngineshell.cfm
mv /System/Library/QuickTime/QuickTimeFirewireDV.component /System/Library/QuickTime/QuickTimeFireWireDV.component
mv /Developer/ADC Reference Library/documentation/Networking/Conceptual/AFP/Art /Developer/ADC Reference Library/documentation/Networking/Conceptual/AFP/ART
mv /Library/Printers/hp/Utilities/hp printer selector.app /Library/Printers/hp/Utilities/HP Printer Selector.app
mv /Library/Printers/hp/Utilities/hp inkjet toolbox.app /Library/Printers/hp/Utilities/HP Inkjet Toolbox.app
mv /Library/Printers/hp/Utilities/hp inkjet toolbox.app /Library/Printers/hp/Utilities/HP Inkjet Toolbox.app
mv /Library/Printers/hp/Utilities/hp printer selector.app /Library/Printers/hp/Utilities/HP Printer Selector.app
/Developer/Tools/SetFile -a l /System/Library/CoreServices/BootX
if [ -z "$createzip" ]; then
# Copy libraries that we like so much
# Otherwise, the system hangs after we're done
# These libs were found with otool -L
mkdir -p "$libdir" || die "Could not create $libdir"
cp /usr/lib/libSystem.B.dylib "$libdir" || die "Could not copy libSystem"
cp /usr/lib/system/libmathCommon.A.dylib "$libdir" || die "Could not copy libmath"
export DYLD_LIBRARY_PATH="$libdir"
if [ -e "$zipfile" ]; then
echo Unpacking files from $zipfile...
ditto -x -v -k --sequesterRsrc "$zipfile" /
# if this fails, you just need to download more, no problem
else
echo "$zipfile not found! You will have to download the full changeset through radmind"
echo "Sleeping for 10 seconds, just in case you made a mistake."
sleep 10
fi
fi
# find changes
count=3
while [ $count -gt 0 ]; do
count=$(( $count - 1 ))
echo "Finding needed changes"
# create zip file if requested and bail
if [ -n "$createzip" ]; then
fsdiff -A -csha1 $m -v -o $applyfile / || die "failed to find changes"
echo "Creating $zipfile..."
make-tiger-zip.sh $applyfile $zipfile -F -% -w2 -h$radhost -p $port
exit
else
# no checksumming here, takes too long
fsdiff -A $m -v -o $applyfile / || die "failed to find changes"
fi
# apply
echo Applying changes
lapply -F -% -w2 -h$radhost -p $port $applyfile && count=-1
[ $count -gt 0 ] && echo "An error occurred, trying again $count more times"
done
[ $count -eq 0 ] && die "could not update system"
# turn on updates
rm $statedir/do-not-radmind
# reboot
/sbin/reboot