Thomas Vachuska

Enhancing onos-run-karaf to run clean installation when tar.gz changes.

Change-Id: Ie25bbb58fa48d7711308346cfc41f1b4c94394e7
......@@ -10,17 +10,32 @@ cd /tmp
# Kill any running instances
[ -f /tmp/onos.pid ] && kill -9 $(cat /tmp/onos.pid) &>/dev/null
set -e
ONOS_DIR=$(tar tf $ONOS_TAR | head -n 1 | cut -d/ -f1)
ONOS_MD5=$ONOS_DIR/CHECKSUM
# Extract MD5 of the ONOS tar file and of the previous installation, if one exists
oldMD5=$(cat $ONOS_MD5 2>/dev/null)
newMD5=$(md5 -q $ONOS_TAR)
# Search for the "clean" argument anywhere on the command-line
echo "$@" | egrep -q "\bclean\b" && clean=true || unset clean
set -e # Do not tolerate any errors from this point onward
# If the previous installation does not exist, or if the ONOS tar changed,
# or if the user asked for clean run, start from scratch.
if [ ! -d $ONOS_DIR -o $oldMD5 != $newMD5 -o -d $ONOS_DIR -a -n "$clean" ]; then
echo "Running clean installation..."
if [ -d $ONOS_DIR -a "$1" = "clean" -o ! -d $ONOS_DIR ]; then
# Blitz previously unrolled onos- directory
rm -fr $ONOS_DIR
# Unroll new image from the specified tar file
[ -f $ONOS_TAR ] && tar zxf $ONOS_TAR
# Write out this installation's MD5 checksum
echo "$newMD5" > $ONOS_MD5
# Change into the ONOS home directory
cd $ONOS_DIR
export ONOS_HOME=$PWD
......@@ -39,7 +54,11 @@ if [ -d $ONOS_DIR -a "$1" = "clean" -o ! -d $ONOS_DIR ]; then
"partitions": [ { "id": 1, "members": [ "$IP" ] } ]
}
EOF
else
# Otherwise, run using the previous installation
echo "Running previous installation..."
# Change into the ONOS home directory
cd $ONOS_DIR
export ONOS_HOME=$PWD
......
......@@ -35,5 +35,5 @@ scenario=${1:-smoke}
# Run stc
[ -z "$stcDebug" ] && DEBUG_OPTS=""
stcColor=${stcColor:-$interactive} stcDumpLogs=${stcDumpLogs:-$notInteractive} \
stcTitle=${stcTitle:-} stcColor=${stcColor:-$interactive} stcDumpLogs=${stcDumpLogs:-$notInteractive} \
java $DEBUG_OPTS -jar $JAR $scenario "$@"
......