2 # Copyright (C) 2016 Ian Kelling
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 # Note, sometimes shutting down the existing demohost vm
20 # fails. Just run again if that happens.
22 # Deploy fai configuration to faiserver,
23 # then start a virtual machine to test the config.
27 trap 'cleanup; echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
28 script_dir
=$
(dirname $
(readlink
-f "$BASH_SOURCE"))
30 e
() { echo "$*"; "$@"; }
32 # I had this set false as default before, can't remember why. oh well.
34 if [[ $1 == -r ]]; then
41 if [[ $script_dir == /a
/bin
/* ]]; then
42 # Copy our script elsewhere so we can develop it
43 # and save it at the same time it's running
46 cp -ar /a
/bin
/fai
/tmp
/faifreeze
47 exec /tmp
/faifreeze
/${BASH_SOURCE##*/} "$@"
53 [[ ${0##*/} == arch-revm
]]
57 [[ ! $1 ]] || new_disk
=true
59 cleanup
() { .
/pxe-server
:; }
63 # via osinfo-query os. guessing arch is closest to latest fedora.
80 for ((i
=1; i
<= disk_count
; i
++)); do
81 f
=/var
/lib
/libvirt
/images
/${name}$i
82 disk_arg
+=("--disk path=$f")
83 if $new_disk ||
[[ ! -e $f ]]; then
85 e s qemu-img create
-o preallocation
=metadata
-f qcow2
$f 20G
89 if [[ $SSH_CLIENT ]]; then
90 console_arg
=--noautoconsole
93 # --cpu host: this causes mkfs.btrfs to fail with a stack trace which began
95 # init_module+0x108/0x1000 [raid6_pq]
97 # uniq is to stop gtk-warning spam
98 e s virt-install
--os-variant $variant -n $name --pxe -r 2048 --vcpus 1 \
99 ${disk_arg[*]} -w bridge
=br0
,mac
=52:54:00:9c
:ef
:ad \
100 --graphics spice
,listen
=0.0.0.0 $console_arg |
& grep -v '^ *$' |
uniq &
102 if [[ $SSH_CLIENT ]]; then
107 while ! timeout
-s 9 10 ssh root@
$name /bin
/true
; do sleep 5; done
110 if is_arch_revm
; then
111 .
/arch-init-remote
$name