#! /bin/sh # # $Id: $ # # SDI-104 upgrade script (load new image and packages from tar file) # Copyright 2006, University of Wisconsin Space Science & Engineering Center # Principal maintainer: John Lalande # # # Load env variables . /opt/etc/env.SDI104 # Check for runlevel 3 if [ "$(/sbin/runlevel | awk '{ print $2 }')" != "3" ] then echo "" echo "********** System must be at runlevel 3 to continue." echo "********** Please switch to runlevel 3 (init 3)" exit 5 fi # Display warning and obtain consent to continue. echo "" echo "####################################################################" echo " SDI-104 Upgrade Script" echo "" echo "This script will upgrade the SSEC SDI-104 satellite ingestor with new" echo "software from a tar file. The script will replace the onboard compact" echo "flash card's file system image with an upgraded one from the tar file." echo "Before continuing, make sure that you have copied the new file system" echo "tar file (should be in /tmp/upgrade-YYYYMMDD.tar.gz)." echo "" echo "If you are ready to continue, please type yes to continue." read answer if [ ! $answer = "yes" ] then echo "You must type yes." exit 0 fi # Remount CF read-write, Confirm that CF card is mounted mount $CFD -o remount,rw touch $CFD/test.txt if [ -f $CFD/test.txt ] then rm $CFD/test.txt else echo "Compact flash could not be mounted read-write. Cannot continue." exit 5 fi # Sanity checks -- check for presence of tar file in /tmp if [ ! -f /tmp/upgrade-????????.tar.gz ] then echo "ERROR: Knoppix image (upgrade-YYYYMMDD.tar.gz) is not present in /tmp." echo "Upgrade cannot continue." exit 5 fi # Copy new KNOPPIX image from tar file to Compact Flash echo "" echo "** Copying new filesystem image (upgrade-YYYYMMDD.tar.gz) to CF card. **" # create backups of base system image mkdir -p $CFD/backups mkdir -p $CFD/knoppix mv $CFD/knoppix/knoppix* $CFD/backups/ mv $CFD/linux* $CFD/backups/ mv $CFD/minirt*.gz $CFD/backups/ mv $CFD/syslinux.cfg* $CFD/backups/ [ -f $CFD/memtest ] && mv $CFD/memtest $CFD/backups/ # copy base ISO filesystem image which is loopback mounted # Delete current packages from CF card, then copy new packages from tar file echo "" echo " ** Copying packages from tar file to compact flash card. **" echo "" rm -fr $CFD/packages.1 # Backup packages to $CFD/packages.1 mkdir $CFD/packages.1 mv $CFD/packages/sib-driver-????????.tar.gz $CFD/packages.1/ tar zxvf /tmp/upgrade-????????.tar.gz -C $CFD # Remount compact flash read-only echo "" echo "** Remounting compact flash card read-only. **" mount $CFD -o remount,ro # Run syslinux on CF echo "" echo "** Re-running syslinux on compact flash card. **" echo "mtools_skip_check=1" > $HOME/.mtoolsrc syslinux -s $CF_DEVICE # Exit echo "" echo "**** Upgrade completed successfully. Exiting." echo "" exit 0