4 # Deploy fai configuration to faiserver,
5 # then start a virtual machine to test the config.
8 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
10 cd $
(dirname $
(readlink
-f "$BASH_SOURCE"))
13 faiserver_host
=faiserver
14 # i use faiserver as a dns alias, but ssh key is associated with
15 # a canonical hostname and we will have ssh warning spam unless we
16 # use it, so look it up.
17 if addr
=$
(host faiserver
); then
19 if h
=$
(host $addr); then
21 faiserver_host
=${h%%.*}
23 echo "$0: warning: host \$addr($addr) failed"
26 echo "$0: warning: host faiserver failed"
30 ssh root@
$faiserver_host rm -rf /srv
/fai
/config
31 scp
-r fai
/config root@
$faiserver_host:/srv
/fai
32 # fai example pass: fai
33 #ROOTPW='$1$kBnWcO.E$djxB128U7dMkrltJHPf6d1'
35 # generating a hashed password:
36 # under debian, you can do
37 # echo "yoursecrectpassword" | mkpasswd -m sha-512 -s
38 # On arch, best seems to be copy your shadow file to a temp location,
39 # then passwd, get out the new pass, then copy the shadow file back.
41 f
=/q
/root
/shadow
/standard
43 ssh root@
$faiserver_host tee -a /srv
/fai
/config
/class
/DEFAULT.var
<<EOF
48 tpvar
="$(s cat /q/root/shadow/traci-simple)"
49 ssh root@
$faiserver_host tee -a /srv
/fai
/config
/class
/tp.var
<<EOF
53 scp ~
/.ssh
/id_rsa.pub \
54 root@
$faiserver_host:/srv
/fai
/config
/files
/home
/ian
/.ssh
/authorized_keys
/GRUB_PC
55 # todo: automatically disable faiserver after a period so
56 # these files are not exposed.
57 s scp
-r /q
/root
/luks
/q
/root
/shadow
/traci
{,-simple} \
58 root@
$faiserver_host:/srv
/fai
/config
/distro-install-common
59 scp
/a
/bin
/devbyid root@
$faiserver_host:/srv
/fai
/nfsroot
/usr
/local
/bin
60 ssh root@
$faiserver_host bash
<<'EOF'
62 chmod 644 /srv/fai/config/files/home/ian/.ssh/authorized_keys/GRUB_PC
63 chmod -R a+rX /srv/fai/config/distro-install-common