From: Thilo Fromm Date: Thu, 25 Apr 2013 13:17:12 +0000 (+0200) Subject: storage_deploy.sh: tested and functional X-Git-Url: https://git.uhu-banane.net/?a=commitdiff_plain;h=e97235c1c7ccbdb81e9b524e4bcc483e8d99ecc8;p=profitbricks%2Fjenkins-build-scripts.git storage_deploy.sh: tested and functional Signed-off-by: Thilo Fromm --- diff --git a/storage_deploy.sh b/storage_deploy.sh index 2de46e4..6007f37 100755 --- a/storage_deploy.sh +++ b/storage_deploy.sh @@ -8,6 +8,7 @@ log() { echo -n "###### `date --rfc-3339=seconds` STORAGE AUTO-DEPLOY " echo $@ } +# ---- rexec() { local srv="$1" ; shift @@ -24,6 +25,12 @@ rexec() { } # ---- +ipmi() { + local host="$1" # hihi + shift + ipmitool -H "$host" -U ADMIN -P ADMIN $@ +} + while_with_timeout() { local timeout="$1" if [ "$2" = "not" ] ; then @@ -91,22 +98,29 @@ wait_for_reboot() { # # M A I N # - +set -x main() { - [ $# -ne 1 ] && { + [ $# -ne 2 ] && { echo - echo " USAGE: $0 " + echo " USAGE: $0 " echo " remote-ip IP address of the remote to be " - echo " converted into a storage server." + echo " converted into a storage server." + echo " remote-ipmi-ip IP address of the remote IPMI " + echo " service." echo exit 1 } local storage_ip="$1" + local storage_ipmi="$2" + + log " Resetting $storage_ip and booting from PXE (via $storage_ipmi)" + ipmi "$storage_ipmi" chassis bootdev pxe || { log " FAILED to set bootdev pxe via ipmi."; return 1; } + ipmi "$storage_ipmi" chassis power reset || { log " FAILED to reset server via ipmi."; return 1; } - wait_until_online 100 "$storage_ip" || return 1 + wait_for_reboot 600 "$storage_ip" || return 1 log " Cloning pb-overlay in initial bootstrap system" rexec "$storage_ip" "cd /tmp && git clone git://git/so/pb-overlay.git" \ @@ -124,9 +138,10 @@ main() { rexec "$storage_ip" "cd /tmp/pb-overlay/scripts && ./install-gentoo-storage" \ || return 1 - log " Rebooting" + log " Setting boot device to 'disk' and rebooting" + ipmi "$storage_ipmi" chassis bootdev disk || { log " FAILED to set bootdev disk via ipmi."; return 1; } rexec "$storage_ip" "reboot" || return 1 - wait_for_reboot 100 $storage_ip || { log " ABORT"; return 1; } + wait_for_reboot 600 $storage_ip || { log " ABORT"; return 1; } log " Cloning pb-overlay in storage root FS" rexec "$storage_ip" "cd /tmp && git clone git://git/so/pb-overlay.git" \ @@ -138,7 +153,7 @@ main() { log " Rebooting" rexec "$storage_ip" "reboot" || return 1 - wait_for_reboot 100 $storage_ip || { log " ABORT"; return 1; } + wait_for_reboot 600 $storage_ip || { log " ABORT"; return 1; } log " S U C C E S S" log " Your storage server is now available at $storage_ip."