bug fix
[automated-distro-installer] / faiserver-revm
1 #!/bin/bash
2 # This file is part of Ian Kelling's automated-distro-installer
3 # Copyright (C) 2024 Ian Kelling
4
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
9
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
19 set -e; . /usr/local/lib/bash-bear; set +e
20
21 usage() {
22 cat <<EOF
23 usage: this-script [-h|--help]
24 Create a vm which is a fai server.
25
26 This assumes you've set the dhcp server to make 52:54:00:56:09:f9 be
27 faiserver. That mac is a randomly generated one in the libvirt range.
28
29 WARNING: has hardcoded IP and name for for my local lan
30 EOF
31 exit $1
32 }
33 case $1 in
34 -h|--help) usage 0 ;;
35 *) usage 1 ;;
36 esac
37
38 err-cleanup() { pxe-server :; }
39 ./debian-pxe-preseed -i 10.0.0.1 -u iank -g vda
40
41 name=faiserver
42 s virshrm $name ||:
43
44 f=/var/lib/libvirt/images/${name}
45 s qemu-img create -o preallocation=metadata -f qcow2 $f 30G
46
47 # uniq because virt-viewer spams me with pointless gtk warnings
48 s virt-install --os-variant debian8 --cpu host -n $name --pxe -r 1024 --vcpus 1 \
49 --disk $f -w bridge=br0,mac=52:54:00:56:09:f9 |& sed "/^ *$/d" | uniq &
50
51 sleep $((60*6)) # takes like 10x as long as a fai install!
52
53 opts="-oStrictHostKeyChecking=false -oUserKnownHostsFile=/dev/null"
54 while ! scp $opts faiserver-setup root@faiserver.b8.nz:; do
55 sleep 5
56 done
57
58 # note: with a vm, pxe boot is turned off in the bios after it's first reboot.
59 err-cleanup() { :; }
60 ./pxe-server
61
62 ssh $opts root@faiserver.b8.nz ./faiserver-setup