fixup initial faiserver bootstrap & small bugs
[automated-distro-installer] / fai-revm
index aa10dfc8eeb18bc9b3f04f9067c4c43ee4736605..2361ecf662848c825205e65149be54ad96600467 100755 (executable)
--- a/fai-revm
+++ b/fai-revm
@@ -1,7 +1,24 @@
 #!/bin/bash -l
+# Copyright (C) 2016 Ian Kelling
+
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 set -x
 
-# Assumes pxe config for dhcp has been setup.
+# Note, sometimes shutting down the existing demohost vm
+# fails. Just run again if that happens.
+
 # Deploy fai configuration to faiserver,
 # then start a virtual machine to test the config.
 
@@ -19,10 +36,12 @@ disk_count=2
 script_dir=$(dirname $(readlink -f "$BASH_SOURCE"))
 
 if [[ $script_dir == /a/bin/* ]]; then
-    rm -rf /a/tmp/fai2
+    # Copy our script elsewhere so we can develop it
+    # and save it at the same time it's running
+    rm -rf /tmp/faifreeze
     mkdir -p /a/tmp
-    cp -ar /a/bin/fai /a/tmp/fai2
-    exec /a/tmp/fai2/${BASH_SOURCE##*/} "$@"
+    cp -ar /a/bin/fai /tmp/faifreeze
+    exec /tmp/faifreeze/${BASH_SOURCE##*/} "$@"
 fi
 
 cd $script_dir
@@ -40,7 +59,7 @@ if is_arch_revm; then
     # via osinfo-query os. guessing arch is closest to latest fedora.
     variant=fedora22
 else
-    ./pxe-server fai &
+    ./pxe-server -a fai &
     sleep 2
     if $redeploy; then
         ./fai-redep
@@ -74,7 +93,7 @@ fi
 # uniq is to stop gtk-warning spam
 s virt-install --os-variant $variant  -n $name --pxe -r 2048 --vcpus 1 \
   ${disk_arg[*]} -w bridge=br0,mac=52:54:00:9c:ef:ad \
-  --graphics spice,listen=0.0.0.0 $console_arg |& grep -v '^$' | uniq &
+  --graphics spice,listen=0.0.0.0 $console_arg |& grep -v '^ *$' | uniq &
 
 if [[ $SSH_CLIENT ]]; then
     fg
@@ -82,6 +101,6 @@ fi
 
 
 if is_arch_revm; then
-    while ! timeout 10 ssh $name /bin/true; do sleep 1; done
+    while ! timeout -s 9 10 ssh root@$name /bin/true; do sleep 1; done
     ./arch-init-remote $name
 fi