X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=fai-revm;h=2ce01027a58e63c2e3baa23de76f1c8ea9cf6d11;hb=HEAD;hp=050ecdaf90d1523891398ed4094396c1057fd934;hpb=936324619541130f4ab07bd4633f48eb81812613;p=automated-distro-installer diff --git a/fai-revm b/fai-revm index 050ecda..6bada5e 100755 --- a/fai-revm +++ b/fai-revm @@ -18,12 +18,12 @@ [[ $EUID == 0 ]] || exec sudo -E "${BASH_SOURCE[0]}" "$@" +set -e; . /usr/local/lib/bash-bear; set +e + +this_file="$(readlink -f -- "${BASH_SOURCE[0]}")" +readonly this_file this_dir="${this_file%/*}" +cd "$this_dir" -readonly this_file="$(readlink -f -- "${BASH_SOURCE[0]}")" -script_dir="${this_file%/*}" -# shellcheck source=./bash-trace -source "${script_dir}/bash-trace" -cd $script_dir PATH="$PATH:$PWD" e() { echo "$*"; "$@"; } @@ -88,19 +88,24 @@ disk_count=1 rm -f /tmp/fai-revm-did-pxe -if ! ip l show br0 &>/dev/null; then - cat <<'EOF' -fai-rvm error: no bridge detected. add one to interfaces like this: -iface eth0 inet manual -iface br0 inet dhcp - bridge_ports eth0 - bridge_stp off - bridge_maxwait 0 -EOF - exit 1 +if ip l show br0 &>/dev/null; then + net_arg="-w bridge=br0,mac=52:54:00:9c:ef:ad" +else + # if this computer has ethernet, we could setup a br0 like so: + # cat <<'EOF' + # fai-rvm error: no bridge detected. add one to interfaces like this: + # iface eth0 inet manual + # iface br0 inet dhcp + # bridge_ports eth0 + # bridge_stp off + # bridge_maxwait 0 + # EOF + + # if we only have wifi, cant use eth0 + net_arg="-w network=default,mac=52:54:00:9c:ef:ad" fi -if [[ $script_dir == /a/bin/* ]]; then +if [[ $this_dir == /a/bin/* ]]; then # Copy our script elsewhere so we can develop it # and save it at the same time it's running rm -rf /tmp/faifreeze @@ -140,13 +145,13 @@ else BASEFILE_DIR=/tmp fi isopath=$BASEFILE_DIR/$iso - isosrc=$BASEFILE_DIR/BOOKWORM64.tar.gz + isosrc=$BASEFILE_DIR/BOOKWORM64.tar.zst if [[ ! -e $isopath || $(stat -c %Y $isopath) -lt $(stat -c %Y $isosrc) ]]; then e fai-cd -g $(readlink -f grub.cfg.${iso%%.*}) -f -A $isopath fi boot_arg="--cdrom $isopath" e fai-redep - cat ~/.ssh/demo.pub | /a/exe/cedit -s /srv/fai/nfsroot/root/.ssh/authorized_keys + /a/exe/cedit -s /srv/fai/nfsroot/root/.ssh/authorized_keys <~/.ssh/demo.pub e myfai-chboot default fi # I don't think these variants actually make a diff for us, but I @@ -165,7 +170,7 @@ e virsh destroy $name ||: e virsh undefine $name ||: sleep 1 - +## begin virtual disk creation ## disk_arg=() for ((i=1; i <= disk_count; i++)); do f=/var/lib/libvirt/images/${name}$i @@ -178,6 +183,7 @@ for ((i=1; i <= disk_count; i++)); do e qemu-img create -o preallocation=metadata -f qcow2 $f 50G fi done +## end virtual disk creation ## if [[ $SSH_CLIENT ]]; then console_arg=--noautoconsole @@ -202,7 +208,7 @@ fi e systemctl start libvirtd e virt-install --rng /dev/urandom --os-variant $variant -n $name $boot_arg -r 2048 --vcpus $cpus \ - ${disk_arg[*]} -w bridge=br0,mac=52:54:00:9c:ef:ad $reboot_arg \ + ${disk_arg[*]} $net_arg $reboot_arg \ --graphics spice,listen=0.0.0.0 $console_arg |& grep -v '^ *$' | uniq &