Script: softice-osc-run
From SOFTICE
#!/bin/bash
# copyleft Alessio Gaspar, SOFTICE project, 2006/07/17, 2008/04/29
# file: $SOFTICE_ROOT/$TAG/bin/softice-osc-run
# chmod: executable by anyone (should be called by users themselves)
# configuration of our softice installation
SOFTICE_ROOT="/softice"
WHEREWECOMEFROM="`pwd`"
what=$0
#let's first figure out if we're running for osc or elsa labs
TAG="osc"
# Let's configure the environment depending on the lab series
# location of the files in students' home directory
HOMERUN="$HOME/.softice-$TAG"
# uml console
UML_MCONSOLE="/usr/bin/uml_mconsole"
# command line options for the UML virtual machine
UML_OPT="con=null con0=fd:0,fd:1"
UML_ID="`/usr/bin/id -n -u`.$TAG"
UML_EXE="$SOFTICE_ROOT/$TAG/bin/linux-uml"
# title bar for when we're using dialog
DIA="[$TAG Labs] UML VM management script"
#______________________________________________________________________
check_homerun () {
#______________________________________________________________________
if [[ ! -d $HOMERUN ]]
then
dialog --backtitle "$DIA" --yesno \
"Error: Your account doesn't have a SOFTICE $TAG environment (~/.softice-$TAG).\
Do you want to recreate it from scratch?" 10 60
if [[ $? -eq 0 ]]
then
dialog --backtitle "$DIA" --yesno \
"You will loose all modifications done in your virtual machine if you do so!!!!\
Are you sure you want to reinstall your virtual environment?" 10 60
if [[ $? -eq 0 ]]
then
#proceed with reinstalling the whole thing
$SOFTICE_ROOT/$TAG/bin/softice-osc-setup
else
dialog --backtitle "$DIA" --msgbox "Aborting the script, contact your instructor." 6 60
exit 1
fi
else
dialog --backtitle "$DIA" --msgbox "Aborting the script, contact your instructor." 6 60
exit 1
fi
fi
}
#______________________________________________________________________
check_previous_uml () {
#______________________________________________________________________
$UML_MCONSOLE $UML_ID version 2>/dev/null
VAL=$?
if [[ $VAL -eq 0 ]]
then
dialog --backtitle "$DIA" \
--yesno "Error: UML virtual machine \"$UML_ID\" already running.\
Do you want to halt it (loss of data possible)?" 9 60
if [[ $? -eq 0 ]]
then
$UML_MCONSOLE $UML_ID halt
dialog --backtitle "$DIA" --infobox "Waiting for \"$UML_ID\" to shutdown properly..." 6 60
sleep 4
check_previous_uml
else
dialog --backtitle "$DIA" --msgbox "Stop the UML VM by hand before to try to execute another one." 6 60
exit 1
fi
fi
}
check_homerun
check_previous_uml
cd $HOMERUN
# These are the devices that will correspond to (ro) file systems
# containing the source trees
UML_KSRC_COW="$HOMERUN/ks.2.6.16.20.cow"
#BUG why is this 2.6.13???
# causes issues when compiling the module against these sources ant then
# loading it in the 2.6..16.20 kernel of the uml vm
#UML_KSRC_RFS="$SOFTICE_ROOT/$TAG/fs/ks.2.6.13.4.rfs"
UML_KSRC_RFS="$SOFTICE_ROOT/$TAG/fs/ks.2.6.16.20.2xpatched.rfs"
# this is the core image (debian)
UML_CORE_COW="$HOMERUN/core-debian.cow"
UML_CORE_RFS="$SOFTICE_ROOT/$TAG/fs/core-debian.rfs"
# this is our configuration device
UML_CFG="$HOMERUN/config.rfs"
# this is our vfat tiny disk for lab #07
UML_VFAT="$HOMERUN/07-vfatdisk.rfs"
UML_CMD_LINE="$UML_EXE \
ubd0=$UML_CORE_COW,$UML_CORE_RFS \
ubd1=$UML_KSRC_COW,$UML_KSRC_RFS \
ubd6=$UML_CFG \
ubd5=$UML_VFAT \
$UML_OPT \
# mem=512M \
umid=$UML_ID"
$UML_CMD_LINE
#return where we were at the beginning of this script
cd $WHEREWECOMEFROM

