2 # Copyright (C) 2016 Ian Kelling
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.
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.
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.
22 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
24 x
="$(readlink -f "$BASH_SOURCE")"; cd ${x%/*}
28 usage: ${0##*/} [-h|--help]
29 Deploy fai configuration to host "faiserver"
38 # i use faiserver as a dns alias, but ssh key is associated with
39 # a canonical hostname and we will have ssh warning spam unless we
40 # use it, so look it up just to avoid the warning spam.
41 faiserver_host
=$
(chost faiserver
) || faiserver_host
=faiserver
44 ssh root@
$faiserver_host rm -rf /srv
/fai
/config
/!(basefiles
)
45 scp
-qr fai
/config root@
$faiserver_host:/srv
/fai
48 scp
-q ~
/.ssh
/id_rsa.pub \
49 root@
$faiserver_host:/srv
/fai
/config
/files
/root
/.ssh
/authorized_keys
/GRUB_PC
50 # todo: automatically disable faiserver after a period so
51 # these files are not exposed.
52 s scp
-qr /q
/root
/luks
/q
/root
/shadow \
53 root@
$faiserver_host:/srv
/fai
/config
/distro-install-common
55 # should tar ssh all the files, but these ones really justified it
56 tar -cz /p
/c
/machine_specific
/*/filesystem
/etc
/ssh | \
57 ssh root@
$faiserver_host tar -xz -C /srv
/fai
/config
/distro-install-common
58 scp
-q /a
/bin
/fai
/devbyid root@
$faiserver_host:/srv
/fai
/nfsroot
/usr
/local
/bin
61 # built BELANOS basefile with mk-basefile -J BELENOS64. it's stored in
62 # it's own repo which is published alongside this one called
63 # fai-basefiles due to being a large binary file.
64 scp
-q /a
/bin
/fai-basefiles
/*.
tar.xz root@
$faiserver_host:/srv
/fai
/config
/basefiles
65 ssh root@
$faiserver_host bash
<<'EOF'
68 # make it the root because pxe-kexec only looks there.
69 # It wouldn't be too hard to change if we needed.
70 # We could also just dump things in /srv/tftp, but fai
71 # has some defaults, which I don't even use, which expect
72 # the other directory, so it's kind of a tossup, whatever.
73 sed -ri 's,^ *(TFTP_DIRECTORY=).*,\1"/srv/tftp/fai",' /etc/default/tftpd-hpa
74 systemctl restart tftpd-hpa
75 chmod 644 /srv/fai/config/files/root/.ssh/authorized_keys/GRUB_PC
76 chmod -R a+rX /srv/fai/config/distro-install-common
77 # this basefile has tar acls bug, so I'm using my own
79 #cd /srv/fai/config/basefiles
80 #u=http://fai-project.org/download/basefiles/XENIAL64.tar.xz