scripts from https://iankelling.org/git, and of course there are some
hostnames that are specific to my network.
+
+# Per-host/install configuration
+
Before doing a fai install, you will need to populate a class file. I
-use one called 5-multi-boot, which you can see example of in
+use one called 51-multi-boot, which you can see example of in
fai/config/class/50-host-classes.
+
+
Before doing a fai install, you will need to populate /q/root/luks and
/q/root/shadow, see their references. You might also want to copy
existing /etc/ssh/*host* to
/p/c/machine_specific/HOST/filesystem/etc/ssh.
+host-* luks keyfiles generated like:
+head -c 2048 /dev/urandom | od | s dd of=/q/root/luks/host-demohost
+Configuration of which luks key to use is in
+fai/config/hooks/partition.DEFAULT
-All scripts meant to be used directly are listed here:
+Configuration of which (if any) shadow file to use is in
+fai/config/distro-install-common/end
+and which shadow file / luks file(s) to copy into the new machine depends
+on fai-redep arguments.
+# Scripts (meant to be used directly):
-# Scripts to setup the environment for the install
+# Setup the environment for the install
# create tiny autodiscover cd
fai-redep && sudo fai-cd -g $PWD/grub.cfg.autodiscover -f -A $BASEFILE_DIR/autodiscover.iso
# create normal fai cd (replace TARGET_HOST)
fai-redep -t TARGET_HOST && sudo fai-cd -M -g $PWD/grub.cfg.netinst -f $BASEFILE_DIR/netinst.iso
-note, may need to set hostname in something like LAST.var
-also, may need to unset proxy.
+note, may need to set hostname, depending on config,
+and some other things for environment not on your lan
+for example see fai/config/class/LINODE.var. See linode notes below.
+
mymk-basefile # Create basefiles for various distros
archlike-pxe # Setup pxe boot server from an archlike base image
fai-redep # Deploy fai configuration to host "faiserver"
Operation failed: No such file or directory
+# linode notes
+
+* create 2 disks, installer (3000 mb, raw), boot (remaining, raw)
+* create 2 profiles w direct boot, no helpers:
+ * installer (sda=boot, sdb=installer, boot dev=sdb)
+ * boot (sda=boot)
+* Boot into rescue mode, ssh in with lish,
+ curl url_to_some_fai_cd_created_image | dd of=/dev/sda
+ poweroff
+* boot into installer.
+* Lish shows console, at the end of install, it gives prompt because
+ logs failed to save remotely, check the logs, then reboot into boot
+ profile if all is well. If that doesn't happen, turn off lassie in
+ settings.
+
+
+
# TODO
Change arch to archlike and to support arch and parabola
# these files are not available.
if [[ $target ]]; then
+ if [[ -e /q/root/shadow/$target ]]; then
+ shadowfile=shadow/$target # empty otherwise
+ fi
sudo rsync -lpt --files-from=- /q/root root@$faiserver_host:/srv/fai/config/distro-install-common <<EOF
luks/$target
luks/host-$target
-shadow/$target
+$shadowfile
EOF
else
sudo rsync -rlpt /q/root/shadow /q/root/luks root@$faiserver_host:/srv/fai/config/distro-install-common
#!/bin/bash
-# Copyright (C) 2016 Ian Kelling
-
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+# Copyright (C) 2019 Ian Kelling
+# SPDX-License-Identifier: AGPL-3.0-or-later
# For using some fai commands outside of fai.
# Usually this is sourced from another script. Note this has
# paths specific to Ian's machine.
# to set fai classes, export CLASS_CLASSNAME=true
+# This wrapper can be detected by using this var:
+export FAI_WRAPPER=true
+
ifclass() {
local var=${1/#/CLASS_}
[[ $HOSTNAME == $1 || ${!var} ]]
#
# The apt sources files we want, STRETCH_FREE, STRETCH_NONFREE,
# BUSTER_FREE, BUSTER_NONFREE, TESTING_FREE, TESTING_NONFREE,
-# XENIAL_FREE, FLIDAS, ETIONA, STRETCH_LINODE, BUSTER_LINODE.
+# XENIAL_FREE, FLIDAS, ETIONA, STRETCH_LINODE.
#
# It's all a little redundant in some cases, but it keeps things
# simpler.
#
# RAID0: Use raid 0 even if there are >= 4 disks with boot partititions.
#
-#
+# LINODE: For running a vm on linode, especially one created with fai-cd.
###### begin Template for 51-multi-boot ######
#
+++ /dev/null
-HOSTNAME=li
-APTPROXY=
\ No newline at end of file
--- /dev/null
+APTPROXY=
+linode_ip=1.2.3.4
+linode_gw=1.2.3.1
+# this is the same at least in 2 regions
+linode_if=enp0s3
+LOGSERVER=b8.nz
+HOSTNAME=l2
if ifclass ziva; then
ROOTPW=/q/root/shadow/ziva
else
+ # if doesn't exist, we dont set one
ROOTPW=/q/root/shadow/standard
fi
+++ /dev/null
-deb http://mirrors.linode.com/debian/ buster main
-deb-src http://mirrors.linode.com/debian/ buster main
-
-deb http://security.debian.org/ buster/updates main
-deb-src http://security.debian.org/ buster/updates main
-
-deb http://mirrors.linode.com/debian/ buster-updates main
-deb-src http://mirrors.linode.com/debian/ buster-updates main
-
-deb http://mirrors.linode.com/debian/ buster-backports main
-deb-src http://mirrors.linode.com/debian/ buster-backports main
-
-deb http://http.us.debian.org/debian unstable main contrib non-free
-deb-src http://http.us.debian.org/debian unstable main contrib non-free
+++ /dev/null
-deb http://mirrors.linode.com/debian/ stretch main
-deb-src http://mirrors.linode.com/debian/ stretch main
-
-deb http://security.debian.org/ stretch/updates main
-deb-src http://security.debian.org/ stretch/updates main
-
-deb http://mirrors.linode.com/debian/ stretch-updates main
-deb-src http://mirrors.linode.com/debian/ stretch-updates main
-
-deb http://mirrors.linode.com/debian/ stretch-backports main
-deb-src http://mirrors.linode.com/debian/ stretch-backports main
}
-# keyfiles generated like:
-# head -c 2048 /dev/urandom | od | s dd of=/q/root/luks/host-demohost
+# see README for docs about how to create these
luks_dir=${LUKS_DIR:-/var/lib/fai/config/distro-install-common/luks}
# # note, corresponding changes in /b/ds/keyscript-{on,off}
if ifclass tpnew; then
lukspw=$(cat $luks_dir/traci)
-elif ifclass BUSTER_LINODE; then
- lukspw=$(cat $luks_dir/li)
elif ifclass ziva; then
lukspw=$(cat $luks_dir/ziva)
elif ifclass demohost; then
lukspw=x
+elif [[ -e $luks_dir/$HOSTNAME ]]; then
+ lukspw=$(cat $luks_dir/$HOSTNAME)
else
lukspw=$(cat $luks_dir/iank)
fi
elif [ -d $target/etc/network/interfaces.d ]; then
# ifupdown >= 0.7.41 (Debian >= 8, Ubuntu >= 14.04)
- if ifclass VM || ifclass BUSTER_LINODE; then
+ if ifclass VM || ifclass LINODE; then
# note, this condition would apply to the elif below too,
# but I don't specify a static ip in fai, so not bothering
cat > $target/etc/network/interfaces <<-EOF
iface $NIC1 inet dhcp
iface $NIC1 inet6 auto
EOF
+
+
else
cat > $target/etc/network/interfaces <<EOF
# generated by FAI
bridge_maxwait 0
EOF
fi
+
+ if ifclass LINODE; then
+ mkdir -p /etc/initramfs-tools/conf.d
+ cat >/etc/initramfs-tools/conf.d/mine <<EOF
+# dhcp in initramfs doesn't work on linode. i dunno why, whatever.
+# man 5 initramfs.conf
+# /usr/share/doc/klibc-utils/README.ipconfig.gz
+# /usr/share/initramfs-tools/scripts/functions
+IP=$linode_ip::$linode_gw:255.255.255.0::$linode_if:off
+EOF
+ fi
+
else
(
iface_stanza lo loopback
fi
;;
- if ifclass BUSTER_LINODE; then
- f=/etc/initramfs-tools/initramfs.conf
- ainsl $f
- fi
-
esac
# here fcopy is mostly used, when installing a client for running in a
# E: Could not get lock /var/lib/apt/lists/lock - open (11: Resource temporarily unavailable)
# so add a sleep. 1 sec is probably way more than needed.
sleep 1
-$ROOTCMD apt-get update
+f=$FAI_ROOT/var/cache/apt/pkgcache.bin
+if [[ ! -r $f ]] || (( $(( $(date +%s) - $(stat -c %Y $f ) )) > 60*60*2 )); then
+ $ROOTCMD apt-get update
+fi
chroot $FAI_ROOT bash <<'EOF'
if [[ $FAI_ACTION != dirinstall ]]; then
- if ifclass BUSTER_LINODE; then
+ if ifclass LINODE; then
speed=19200
# luks.crypttab=no see man systemd-cryptsetup-generator
cmdline="luks.crypttab=no console=ttyS0,${speed}n8"
EOF
-
chroot $FAI_ROOT bash <<EOF
set -eE -o pipefail
# https://askubuntu.com/questions/33416/how-do-i-disable-the-boot-splash-screen-and-only-show-kernel-and-boot-text-inst
# we remove quiet and splash, and all thats left is what we want
-sed -ri 's/^ *GRUB_CMDLINE_LINUX_DEFAULT=.*"/GRUB_CMDLINE_LINUX_DEFAULT="$cmdline"/' /etc/default/grub
+if grep -qF "$cmdline" /etc/default/grub; then
+ # already set things, exit
+ exit 0
+fi
+sed -ri 's/^ *GRUB_CMDLINE_LINUX_DEFAULT=.*/GRUB_CMDLINE_LINUX_DEFAULT="$cmdline"/' /etc/default/grub
# on xenial, no grub is displayed at all. fix that.
# found just by noticing this in the config file, and a
# warning about it in error.log
sed -i '/^ *GRUB_HIDDEN_TIMEOUT/d' /etc/default/grub
update-grub2
+EOF
+ if [[ ! FAI_WRAPPER ]]; then
+ chroot $FAI_ROOT bash <<EOF
# Just include all of them for now incase we are creating
# an install for a different machine.. in distro-begin, we
# slim it down to whats used.
find /lib/modules/*/kernel/drivers/net /lib/modules/*/kernel/net -type f -name '*.ko' -printf "%f\n" | sed 's/.ko$//' | sort -u >/etc/initramfs-tools/modules
update-initramfs -u -k all
EOF
+ fi
fi