Enhancing onos-run-karaf to run clean installation when tar.gz changes.
Change-Id: Ie25bbb58fa48d7711308346cfc41f1b4c94394e7
Showing
2 changed files
with
23 additions
and
4 deletions
| ... | @@ -10,17 +10,32 @@ cd /tmp | ... | @@ -10,17 +10,32 @@ cd /tmp |
| 10 | # Kill any running instances | 10 | # Kill any running instances |
| 11 | [ -f /tmp/onos.pid ] && kill -9 $(cat /tmp/onos.pid) &>/dev/null | 11 | [ -f /tmp/onos.pid ] && kill -9 $(cat /tmp/onos.pid) &>/dev/null |
| 12 | 12 | ||
| 13 | -set -e | ||
| 14 | - | ||
| 15 | ONOS_DIR=$(tar tf $ONOS_TAR | head -n 1 | cut -d/ -f1) | 13 | ONOS_DIR=$(tar tf $ONOS_TAR | head -n 1 | cut -d/ -f1) |
| 14 | +ONOS_MD5=$ONOS_DIR/CHECKSUM | ||
| 15 | + | ||
| 16 | +# Extract MD5 of the ONOS tar file and of the previous installation, if one exists | ||
| 17 | +oldMD5=$(cat $ONOS_MD5 2>/dev/null) | ||
| 18 | +newMD5=$(md5 -q $ONOS_TAR) | ||
| 19 | + | ||
| 20 | +# Search for the "clean" argument anywhere on the command-line | ||
| 21 | +echo "$@" | egrep -q "\bclean\b" && clean=true || unset clean | ||
| 22 | + | ||
| 23 | +set -e # Do not tolerate any errors from this point onward | ||
| 24 | + | ||
| 25 | +# If the previous installation does not exist, or if the ONOS tar changed, | ||
| 26 | +# or if the user asked for clean run, start from scratch. | ||
| 27 | +if [ ! -d $ONOS_DIR -o $oldMD5 != $newMD5 -o -d $ONOS_DIR -a -n "$clean" ]; then | ||
| 28 | + echo "Running clean installation..." | ||
| 16 | 29 | ||
| 17 | -if [ -d $ONOS_DIR -a "$1" = "clean" -o ! -d $ONOS_DIR ]; then | ||
| 18 | # Blitz previously unrolled onos- directory | 30 | # Blitz previously unrolled onos- directory |
| 19 | rm -fr $ONOS_DIR | 31 | rm -fr $ONOS_DIR |
| 20 | 32 | ||
| 21 | # Unroll new image from the specified tar file | 33 | # Unroll new image from the specified tar file |
| 22 | [ -f $ONOS_TAR ] && tar zxf $ONOS_TAR | 34 | [ -f $ONOS_TAR ] && tar zxf $ONOS_TAR |
| 23 | 35 | ||
| 36 | + # Write out this installation's MD5 checksum | ||
| 37 | + echo "$newMD5" > $ONOS_MD5 | ||
| 38 | + | ||
| 24 | # Change into the ONOS home directory | 39 | # Change into the ONOS home directory |
| 25 | cd $ONOS_DIR | 40 | cd $ONOS_DIR |
| 26 | export ONOS_HOME=$PWD | 41 | export ONOS_HOME=$PWD |
| ... | @@ -39,7 +54,11 @@ if [ -d $ONOS_DIR -a "$1" = "clean" -o ! -d $ONOS_DIR ]; then | ... | @@ -39,7 +54,11 @@ if [ -d $ONOS_DIR -a "$1" = "clean" -o ! -d $ONOS_DIR ]; then |
| 39 | "partitions": [ { "id": 1, "members": [ "$IP" ] } ] | 54 | "partitions": [ { "id": 1, "members": [ "$IP" ] } ] |
| 40 | } | 55 | } |
| 41 | EOF | 56 | EOF |
| 57 | + | ||
| 42 | else | 58 | else |
| 59 | + # Otherwise, run using the previous installation | ||
| 60 | + echo "Running previous installation..." | ||
| 61 | + | ||
| 43 | # Change into the ONOS home directory | 62 | # Change into the ONOS home directory |
| 44 | cd $ONOS_DIR | 63 | cd $ONOS_DIR |
| 45 | export ONOS_HOME=$PWD | 64 | export ONOS_HOME=$PWD | ... | ... |
| ... | @@ -35,5 +35,5 @@ scenario=${1:-smoke} | ... | @@ -35,5 +35,5 @@ scenario=${1:-smoke} |
| 35 | 35 | ||
| 36 | # Run stc | 36 | # Run stc |
| 37 | [ -z "$stcDebug" ] && DEBUG_OPTS="" | 37 | [ -z "$stcDebug" ] && DEBUG_OPTS="" |
| 38 | -stcColor=${stcColor:-$interactive} stcDumpLogs=${stcDumpLogs:-$notInteractive} \ | 38 | +stcTitle=${stcTitle:-} stcColor=${stcColor:-$interactive} stcDumpLogs=${stcDumpLogs:-$notInteractive} \ |
| 39 | java $DEBUG_OPTS -jar $JAR $scenario "$@" | 39 | java $DEBUG_OPTS -jar $JAR $scenario "$@" | ... | ... |
-
Please register or login to post a comment