]> Frank Brehm's Git Trees - profitbricks/jenkins-build-scripts.git/commitdiff
storage_deploy.sh: tested and functional
authorThilo Fromm <thilo.fromm@profitbricks.com>
Thu, 25 Apr 2013 13:17:12 +0000 (15:17 +0200)
committerThilo Fromm <thilo.fromm@profitbricks.com>
Thu, 25 Apr 2013 13:17:12 +0000 (15:17 +0200)
Signed-off-by: Thilo Fromm <thilo.fromm@profitbricks.com>
storage_deploy.sh

index 2de46e41b5b49978673f51edece4497a2b8cea19..6007f37bab79f508c8cedf012cec65d125fda6d9 100755 (executable)
@@ -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 <remote-ip>"
+        echo "    USAGE: $0 <remote-ip> <remote-ipmi-ip>"
         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."