From 561173553084ea02330344a46cab636e8def1781 Mon Sep 17 00:00:00 2001 From: thierry Date: Thu, 21 Jan 2010 13:44:36 +0000 Subject: [PATCH] more features --- scripts/reboot-all.sh | 65 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 59 insertions(+), 6 deletions(-) diff --git a/scripts/reboot-all.sh b/scripts/reboot-all.sh index 1c50590..b814b10 100755 --- a/scripts/reboot-all.sh +++ b/scripts/reboot-all.sh @@ -1,10 +1,63 @@ #!/bin/bash -echo '==================== cleaning trackers on testmaster' -ssh root@testmaster.onelab.eu rm 'tracker*' +# by default : reboot the boxes involved in testing +# with -a : reboot also the build boxes -for h in mirror build build2 build3 testplc testqemu{1,2,3} testqemu32-{1,2,3,4,5}; do - echo "==================== rebooting $h.onelab.eu" - host $h.onelab.eu - ssh root@$h.onelab.eu shutdown -r now +COMMAND=$(basename $0) +function usage () { + echo "$COMMAND [-abn]" + echo -e " -a\tall boxes, not just the test ones" + echo -e " -b\tbuild boxes only" + echo -e " -n\tdry-run" + exit 1 +} + +build_boxes="mirror $(echo build{1,2,3})" +test_boxes="testplc $(echo testqemu{1,2,3} testqemu32-{1,2,3,4,5})" + +while getopts "abnh" opt ; do + case $opt in + a) ALL_BOXES=true ;; + b) BUILD_BOXES_ONLY=true ;; + n) DRY_RUN=true ;; + h|*) usage ;; + esac +done +toshift=$(($OPTIND - 1)) +shift $toshift + +CLEAN_TRACKERS="yes" +if [[ -n "$@" ]] ; then + BOXES="$@" +elif [ -n "$ALL_BOXES" ] ; then + BOXES="$build_boxes $test_boxes" +elif [ -n "$BUILD_BOXES_ONLY" ] ; then + BOXES="$build_boxes" + CLEAN_TRACKERS="" +else + BOXES="$test_boxes" +fi + +if [ -n "$CLEAN_TRACKERS" ] ; then + echo '==================== cleaning trackers on testmaster' + if [ -n "$DRY_RUN" ] ; then + echo DRYRUN: ssh root@testmaster.onelab.eu rm 'tracker*' + else + ssh root@testmaster.onelab.eu rm 'tracker*' + fi +fi + +function host_detail () { + box=$1; shift + host ${box} | tail -1 +} + +for box in $BOXES; do + msg=$(host ${box}.onelab.eu | grep alias) + echo "==================== rebooting ${box}.onelab.eu ($msg)" + if [ -n "$DRY_RUN" ] ; then + echo DRYRUN: echo ssh root@${box}.onelab.eu shutdown -r now + else + echo ssh root@${box}.onelab.eu shutdown -r now + fi done -- 2.45.2