various fixes
[automated-distro-installer] / lk
1 #!/bin/bash
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
18 usage() {
19 cat <<EOF
20 Usage: ${0##*/} [-h|--help]
21 fai kexec from upstream live cds, i.e. curl|bash
22
23 You can copy this to a http server, then wget -O- url|sudo bash
24 curl is sometimes not preinstalled on a live cd.
25
26 This has been tested on trisquel belenos and ubuntu xenial.
27
28 If the screen just sits in a weird color inverted, corrupted looking state,
29 it's probably nothing wrong with the computer, but a problem
30 with the fai server. If you can do this from a virtual terminal,
31 it will print out more info (I know from running it on a vm).
32 EOF
33 exit $1
34 }
35 case $1 in
36 -h|--help) usage ;;
37 esac
38
39
40 set -ex
41 if grep -q ID=ubuntu /etc/os-release; then
42 # add universe, pxe-kexec is there
43 sed -ri '/^\s*deb/{/universe/!s/$/ universe/}' /etc/apt/sources.list
44 fi
45 if ! type -p pxe-kexec &>/dev/null; then
46 apt-get update
47 apt-get install -y debconf
48 debconf-set-selections <<EOF
49 kexec-tools kexec-tools/load_kexec boolean false
50 EOF
51 apt-get install -y pxe-kexec
52 fi
53 # running this piped to bash on belenos, the apt-get goes
54 # into the background while it's still installing, and pxe-kexec
55 # just exits right away. sleep calls are strangely ignored.
56 # I don't know whats going on, but just running the same
57 # command again once it finishes works, and this is only
58 # rarely used and done manually anyways, so whatever.
59 pxe-kexec -n --ignore-whitelist -l fai-generated faiserver