fix keeping non system fses and idempotency
[automated-distro-installer] / fai-redep
1 #!/bin/bash -lx
2
3 # Deploy fai configuration to faiserver,
4 # then start a virtual machine to test the config.
5
6 set -eE -o pipefail
7 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?"' ERR
8
9 ssh root@faiserver rm -rf /srv/fai/config/\*
10 scp -r /a/bin/fai/fai/config root@faiserver:/srv/fai
11 # fai example pass: fai
12 #ROOTPW='$1$kBnWcO.E$djxB128U7dMkrltJHPf6d1'
13
14 # generating a hashed password:
15 # under debian, you can do
16 # echo "yoursecrectpassword" | mkpasswd -m sha-512 -s
17 # On arch, best seems to be copy your shadow file to a temp location,
18 # then passwd, get out the new pass, then copy the shadow file back.
19 ssh root@faiserver tee -a /srv/fai/config/class/DEFAULT.var <<EOF
20 ROOTPW='$(cat /p/shadow/standard)'
21 EOF
22 scp ~/.ssh/id_rsa.pub \
23 root@faiserver:/srv/fai/config/files/home/ian/.ssh/authorized_keys/GRUB_PC
24 s scp -r /q/root/luks root@faiserver:/srv/fai/config/distro-install-common
25 ssh root@faiserver chmod -R a+rX /srv/fai/config/distro-install-common
26
27 s virshrm demohost ||:
28
29 for f in /var/lib/libvirt/images/demohost{,b}; do
30 [[ -e $f ]] || s qemu-img create -o preallocation=metadata -f qcow2 $f 30G
31 done
32 # osinfo-query os | gr jessie
33 s virt-install --os-variant debian8 --cpu host -n demohost --pxe -r 2048 --vcpus 1 \
34 --disk path=/var/lib/libvirt/images/demohost \
35 --disk path=/var/lib/libvirt/images/demohostb -w bridge=br0,mac=52:54:00:9c:ef:ad