use disk/by-id if possibe, other small fixes
[automated-distro-installer] / fai-redep
1 #!/bin/bash -l
2 set -x
3
4 # Deploy fai configuration to faiserver,
5 # then start a virtual machine to test the config.
6
7 set -eE -o pipefail
8 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?"' ERR
9
10 cd $(dirname $(readlink -f "$BASH_SOURCE"))
11
12 ssh root@faiserver rm -rf /srv/fai/config
13 scp -r fai/config root@faiserver:/srv/fai
14 # fai example pass: fai
15 #ROOTPW='$1$kBnWcO.E$djxB128U7dMkrltJHPf6d1'
16
17 # generating a hashed password:
18 # under debian, you can do
19 # echo "yoursecrectpassword" | mkpasswd -m sha-512 -s
20 # On arch, best seems to be copy your shadow file to a temp location,
21 # then passwd, get out the new pass, then copy the shadow file back.
22
23 if [[ -e /q/root/shadow/standard ]]; then
24 # note, it would be best to have some kind of security on this file
25 ssh root@faiserver tee -a /srv/fai/config/class/DEFAULT.var <<EOF
26 ROOTPW='$(cat /q/root/shadow/standard)'
27 EOF
28 fi
29
30 tpvar="$(s cat /q/root/shadow/traci-simple)"
31 ssh root@faiserver tee -a /srv/fai/config/class/tp.var <<EOF
32 ROOTPW='$tpvar'
33 EOF
34
35 scp ~/.ssh/id_rsa.pub \
36 root@faiserver:/srv/fai/config/files/home/ian/.ssh/authorized_keys/GRUB_PC
37 s scp -r /q/root/luks /q/root/shadow/traci{,-simple} \
38 root@faiserver:/srv/fai/config/distro-install-common
39 scp /a/bin/devbyid root@faiserver:/srv/fai/nfsroot/usr/local/bin
40 ssh root@faiserver chmod -R a+rX /srv/fai/config/distro-install-common