#!/bin/sh # # ======== restore-hdd ======== # # Shell script to install or restore the primary partition of the HDD on a # DaVinci DVEVM. # # # ======== progress ======== # # Simple progress indicator function to give feedback on how much has been # completed. # # Usage: progress num-lines-expected # function progress () { let inc=$1/20 let cnt=0 let percent=5 while read line do let cnt=cnt+1 if test $cnt -eq $inc then echo -n -e "${percent}% \r" if test $percent -lt 100 then let percent=percent+5 fi let cnt=0 fi done } disk=/dev/hda1 primary=/mnt/primary # Add an option from prep-hdd not to ask if test "$1" != "y" then # make sure user really wants to do this echo -n "This will destroy all data on $disk - are you sure? (yes/NO) " read answer if test "$answer" != "yes" then echo "The answer must be "yes" to perform the restore operations" exit 1 fi fi # check to make sure all the needed files are present test -f mvltarget5_0_0801921_update.tar.gz && test -f overlay.tar.gz && test -f data.tar.gz if test $? -ne 0 then echo "One or more of the necessary files are missing - cannot restore" exit 2 fi # save where we started from old=$PWD # make sure the disk is not mounted or we cannot format it dir=$(mount | grep ${disk} | cut -d " " -f 3) if test "$dir" != "" then umount $dir > /dev/null 2>&1 fi echo "Formatting $disk ... " if ! mkfs.ext3 $disk then echo "$0: could not format $disk" exit 2 fi echo "Mounting newly formated partition ... " mkdir $primary > /dev/null 2>&1 mount -t ext3 $disk $primary > /dev/null echo "Creating target root filesystem (be patient) ... " cd $primary tar xzvf $old/mvltarget5_0_0801921_update.tar.gz | progress 63000 # # Install the demo applications and associated data files. Since the # demos can be invoked from the web server, they need to be suid so they # can open the A/V devices. # echo "Installing DVEVM demos ... " cd $primary/opt tar zxf $old/overlay.tar.gz cd $primary/opt/dvsdk tar zxf $old/data.tar.gz chown -R root $primary/opt/dvsdk cd $primary/opt/dvsdk/dm64* chmod u+s interface decode encode encodedecode # # Setup for the auto-start of the demo interface and web server at # system boot. # chmod +x $primary/opt/dvsdk/dm64*/dvevmdemo mv $primary/opt/dvsdk/dm64*/dvevmdemo $primary/etc/rc.d/init.d cd $primary/etc/rc.d/rc3.d ln -s ../init.d/dvevmdemo S88demo # # Install the kernel modules for things like USB mass storage. # if [ -f $old/modules.tar.gz ];then echo "Installing modules ... " cd $primary tar xzf $old/modules.tar.gz chown -R root /lib #depmod -a -r -b $primary depmod -a -r -b $primary $(ls $primary/lib/modules) else echo "Warning $old/modules.tar.gz was not found (depending on LSP, this may be ok)" fi echo "" echo "Restore complete"