add support for trisquel belanos
[automated-distro-installer] / fai-redep
1 #!/bin/bash -l
2 # Copyright (C) 2016 Ian Kelling
3
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 set -x
18
19 # Deploy fai configuration to faiserver,
20 # then start a virtual machine to test the config.
21
22 set -eE -o pipefail
23 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
24
25 cd $(dirname $(readlink -f "$BASH_SOURCE"))
26
27
28 # i use faiserver as a dns alias, but ssh key is associated with
29 # a canonical hostname and we will have ssh warning spam unless we
30 # use it, so look it up just to avoid the warning spam.
31 faiserver_host=$(chost faiserver) || faiserver_host=faiserver
32
33
34 ssh root@$faiserver_host rm -rf /srv/fai/config
35 scp -r fai/config root@$faiserver_host:/srv/fai
36
37
38 scp ~/.ssh/id_rsa.pub \
39 root@$faiserver_host:/srv/fai/config/files/home/ian/.ssh/authorized_keys/GRUB_PC
40 # todo: automatically disable faiserver after a period so
41 # these files are not exposed.
42 s scp -r /q/root/luks /q/root/shadow \
43 root@$faiserver_host:/srv/fai/config/distro-install-common
44 scp /a/bin/devbyid root@$faiserver_host:/srv/fai/nfsroot/usr/local/bin
45 # built this with mk-basefile -J BELENOS64. it's stored in it's own repo which
46 # is published alongside this one called fai-basefiles due
47 # to being a large binary file.
48 scp /a/bin/basefiles/BELENOS64.tar.xz root@$faiserver_host:/srv/fai/config/basefiles
49 ssh root@$faiserver_host bash <<'EOF'
50 set -eE -o pipefail
51 set -x
52 chmod 644 /srv/fai/config/files/home/ian/.ssh/authorized_keys/GRUB_PC
53 chmod -R a+rX /srv/fai/config/distro-install-common
54 cd /srv/fai/config/basefiles
55 u=http://fai-project.org/download/basefiles/XENIAL64.tar.xz
56 wget -nv -N $u
57 EOF