fi
# these are gitignored.
-rsync -atL /home/iank/.ssh/authorized_keys fai/config/files/root/.ssh/authorized_keys/STANDARD
+cat /home/iank/.ssh/{home,work}.pub >fai/config/files/root/.ssh/authorized_keys/STANDARD
# we hssh and ssh_filter_btrbk for the initial btrbk (alternatively, I could open up the
# permissions in authorized_keys, but that just seems lazy)
install --owner=iank --group=iank -d fai/config/files/usr/local/bin/hssh
rsrv -rlpt --delete --relative ${dirs[@]} /fai/config/distro-install-common
fi
-. /a/bin/distro-setup/pkgs
-tmpstr=$(/a/bin/buildscripts/emacs -p && /a/bin/distro-setup/distro-pkgs $distro)
-declare -a pall
-for p in $tmpstr; do
- pall+=($p)
-done
-
-printf "%s\n%s\n" "PACKAGES install" ${pall[*]} | \
- $faiserver_shell dd of=/srv/fai/config/package_config/DESKTOP status=none ||: # broken pipe
-
+# historical notes: once I tried installing all generic packages using
+# the DESKTOP class, and populated the package list here, but it had
+# some problem and figured it was easier to debug if we let fai just
+# handle some basic initial things.
+# I also tried speeding up an initial install by making basefile with
+# lots of packages installed in a script called mk-basefile-big. Many
+# packages fail to install by having debootstrap install extra
+# packages. I tried instead to do a fai dirinstall (fancy chroot) to
+# install packages, then turn that into a new basefile. It had some
+# problem and once again, did not seem worth debugging.
rsrv -rplt --include '/*.zst' --exclude '/**' --delete-excluded $BASEFILE_DIR/ /fai/config/basefiles/
# change this to test different disk counts.
-disk_count=3
disk_count=1
+disk_count=3
rm -f /tmp/fai-revm-did-pxe
#! /bin/bash
-_
+
# do only execute if this is called on the client being installed. Do not use during fai-diskimage
if [ X$FAI_ACTION = Xinstall -a $do_init_tasks -eq 0 ]; then
exit 0
# the main root fs in /tmp/fai. Must run with env var, eg export DISTRO=trisquelaramo.
#
# Example use in a bootstrap distro:
-# scp /a/bin/fai/fai/config/{distro-install-common/devbyid,hooks/partition.DEFAULT} root@HOST:
+# scp /b/fai/fai-wrapper /a/bin/fai/fai/config/{distro-install-common/devbyid,hooks/partition.DEFAULT} root@HOST:
# sl HOST
-# export DISTRO=trisquelnabia; ./partition.DEFAULT mktab
+# . fai-wrapper # ignore error that FAI is not set, it is not needed for SPECIAL_DISK purposes.
+# fai-setclass FSF
+# export SPECIAL_DISK=/dev/sde
+# export DISTRO=trisquelecne # not actually used
+# ./partition.DEFAULT
+#
# ## cryptsetup wont take within a pipeline
# mapfile -t lines < <(awk '! /swap/ {print $2,$1}' /tmp/fai/crypttab )
# for l in "${lines[@]}"; do cryptsetup luksOpen $l; done
ssds=()
# this excludes "usb". vda disk has empty tran (transport). This may need adjustment
# for some new type we come across. cdrom has type "rom"
-for disk in $(lsblk -ndo name,type,tran | awk '$3 ~ "^(sata|nvme|)$" && $2 == "disk" { print $1 }'); do
+for disk in $(lsblk -ndo name,type,tran | awk '$3 ~ "^(sata|nvme|sas|)$" && $2 == "disk" { print $1 }'); do
if [[ ${disk_excludes[$disk]} ]]; then
continue
fi
fi
-# 1.5 x based on https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Installation_Guide/sect-disk-partitioning-setup-x86.html#sect-custom-partitioning-x86
-swap_mib=$(( $(grep ^MemTotal: /proc/meminfo | \
- awk '{print $2}') * 3/(${#devs[@]} * 2 ) / 1024 ))
+#
+# for servers, 4gb min based on https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/9/html/managing_storage_devices/getting-started-with-swap_managing-storage-devices#recommended-system-swap-space_getting-started-with-swap
+# meh, i'll just do that * drives for machines with lots of ram.
+mem_kb=$(awk '$1 == "MemTotal:" {print $2}' /proc/meminfo)
+mem_gb=$(( mem_kb / 1024 / 1024 ))
+if (( mem_gb < 64 )); then
+ # enable hibernate with 1.5x of ram, split per disk
+ swap_mib=$(( mem_gb * 3 / ${#devs[@]} ))
+else
+ swap_mib=4096
+fi
shopt -s nullglob
##### end variable setup
exit 0
else
mktab
- if ! fsf; then
+ if ! fsf && [[ ! $SPECIAL_DISK ]]; then
getluks
fi
fi
zstd
# for detecting wireless
iw
+# for the fai partitioning script
+parted dosfstools
# iank, copied from DEBIAN so it goes into ubuntu too
PACKAGES install GRUB_PC
+++ /dev/null
-#!/bin/bash
-# Copyright (C) 2018 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.
-
-
-[[ $EUID == 0 ]] || exec sudo -E "${BASH_SOURCE[0]}" "$@"
-
-set -e; . /usr/local/lib/bash-bear; set +e
-
-this_file="$(readlink -f -- "${BASH_SOURCE[0]}")"
-readonly this_file this_dir="${this_file%/*}"
-PATH="$this_dir:$PATH" # directory of this file
-
-usage() {
- cat <<EOF
-Usage: ${0##*/} DISTRO_CODENAME
-Make basefile with desktop packages preinstalled
-
-The longest amount of time when doing a new install is installing
-packages. We can make that faster by preinstalling them in a
-basefile. When a basefile is created, debootstrap allows you to
-specify extra packages, but in trisquel, most packages don't install
-that way. Not sure exactly why. So, we can do a fai dirinstall (fancy
-chroot) to install packages, then turn that into a new basefile.
-
-The script depnds on being in a directory with other scripts from it's repo.
-
-Warning: uses paths specific to author's machine.
-
--h|--help Print help and exit.
-
-Note: Uses GNU getopt options parsing style
-EOF
- exit $1
-}
-
-read -r distver <<<"$@"
-
-if [[ $# != 1 ]]; then
- echo "$0: error: expected one argument"
- usage 1
-fi
-
-
-case $distver in
- flidas)
- distro=trisquel
- classes="UBUNTU FLIDAS64 VOL_FLIDAS FLIDAS DESKTOP"
- ;;
- stretch)
- classes="DEBIAN STRETCH64 VOL_STRETCH STRETCH DESKTOP"
-;;
- *)
- echo "$0: error: unknown DISTRO_CODENAME"
- usage 1
- ;;
-esac
-
-distro=trisquel
-
-# background: i tried using a tmpfs for this. it had minimal effect, like 17 mins vs 18 mins
-t=/tmp/dirinstall
-
-
-err-cleanup() {
- sed -i 's/^#LOGUSER=/LOGUSER=/' /etc/fai/fai.conf
- for d in proc var/lib/dpkg var/cache; do
- umount -R $t/$d ||:
- done
- rm -rf $t
-}
-
-
-myfai-chboot default
-sed -i 's/^LOGUSER=/#LOGUSER=/' /etc/fai/fai.conf
-# config umount required after a failed run, proc umount always required
-umount /var/lib/fai/config ||: ; umount -R $t/proc ||:
-
-fai-redep faiserver.b8.nz $distro
-echo "echo $classes" > /srv/fai/config/class/51-multi-boot
-
-rm -rf $t; mkdir -p $t
-
-# shellcheck disable=SC1007 # intentional
-LANG= fai -N -u hostname_does_not_matter dirinstall $t
-
-# Turn a dirinstall into a basefile. taken from mk-basefile
-chroot $t apt-get clean
-rm -f $t/etc/hostname $t/etc/resolv.conf \
- $t/var/lib/apt/lists/*_* $t/usr/bin/qemu-*-static \
- $t/etc/udev/rules.d/70-persistent-net.rules
-echo | dd of=$t/etc/machine-id
-tar --one-file-system -C $t -cf - . | zstd -9 > /a/bin/fai-basefiles/basefiles/${distver^^}64BIG.tar.zst
-
-
-cleanup
-exit 0
We could probably also set FAI_FLAGS the same way we set FAI_ACTION,
but I haven't tried it.
+Debugging notes: I had nfs communication problems due to misconfiguration,
+tcpdump showed small packets, many size 4, but I couldn't figure out what
+the hell they actually meant. -vv does nfs decoding, but output nothing
+useful. This seems to generally output all nfs operations into syslog
+with kernel: prepended "for module in nfsd rpc nlm; do s rpcdebug -m $module -s all; done" disable with "for module in nfsd rpc nlm; do s rpcdebug -m $module -c; done"
+i read the nfstrace man page and tried running it, it seemed totally useless,
+just outputing some statistics of valid commands.
+
HOSTNAME|IP|default Sets the host to enable it for. No argument
disables pxe config for all hosts, but leaves nfs
server alone. Use faiserver-disable to disable the
- nfs server.
+ nfs server. Hostnames are simply converted to ip address
+ for nfs and pxe.
-S sets FAI_ACTION=sysinfo, and remove fai flag reboot.
Usefull for doing a system recovery. It reboots automatically anyways :(
[[ $EUID == 0 ]] || exec sudo -E "${BASH_SOURCE[0]}" "$@"
-set -x
-
set -eE -o pipefail
trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
read -r host <<<"$@"
readonly host
-
rm -f /srv/tftp/fai/pxelinux.cfg/*
-if [[ ! $1 ]]; then
+if [[ ! $host ]]; then
echo "$0: clearing pxe config and exiting"
exit 0
fi
# somewhat duplicated in brc hostip()
-case $host in
- default) : ;;
- [0-9:])
- hostip=$host
- ;;
- *)
- hostip=$(getent ahostsv4 "$host" | awk '{ print $1 }' | head -n1)
- ;;
-esac
-
-if [[ $hostip ]]; then
-
- # assuming ipv4, or else we might need to deal with multiple addresses
- # in an ipv4 + ipv6 network.
- #
- # t11 has via. presumably, older os had src
- my_ip=$(ip -4 route get $hostip | head -n1 | sed -nr 's,^.*(src|via)\s+(\S+).*,\1,p' || [[ $? == 141 ]] )
+
+nonip_regex='[^0-9:.]'
+if [[ $host == default ]]; then
+ ip_arg=8.8.8.8
else
- my_ip=$(ip -4 r show default | head -n1 | sed -r 's/.*(src|via) ([^ ]*).*/\1/' || [[ $? == 141 ]] )
+ if [[ $host =~ $nonip_regex ]]; then
+ ip_arg="$(getent ahostsv4 "$host" | awk '{ print $1 }' | head -n1)"
+ else
+ ip_arg="$host"
+ fi
fi
-if [[ ! $my_ip || $my_ip =~ [[:space:]] ]]; then
+my_ip=$(ip -r -j r get $ip_arg|jq -r '.[0].prefsrc' )
+
+if [[ ! $my_ip || $my_ip =~ $nonip_regex ]]; then
echo "$0: error: failed to get \$my_ip, got: $my_ip"
exit 1
fi
-
if [[ $host == default ]]; then
ip='*'
elif [[ $host == [0-9]*.[0-9]*.[0-9]*.[0-9]* ]]; then
else
type -t host &>/dev/null || apt-get -y install dnsutils
ip=$(host $host | sed -rn 's/^\S+ has address //p;T;q' ||:)
- if [[ ! $ip || $ip =~ [[:space:]] ]]; then
+ if [[ ! $ip || $ip =~ $nonip_regex ]]; then
echo "$0: error: failed to get \$ip, got: $ip"
exit 1
fi
# man page doesn't explain this, but this deletes & thus disables
# all chboot systems.
-m fai-chboot -iv $std_arg default # set it to default to get a val out of it next
+# We want to set to default to get a val out of it next.
+# If needing to debug, normal output from this command looks like this:
+# Booting kernel vmlinuz-6.1.0-23-amd64
+# append initrd=initrd.img-6.1.0-23-amd64 ip=dhcp
+# FAI_CONFIG_SRC=nfs://faiserver.b8.nz/srv/fai/config
+#
+# default has no IP in hex default
+# Writing file /srv/tftp/fai/pxelinux.cfg/default for default
+fai-chboot -iv default &>/dev/null
+
kernel=$(fai-chboot -L '^default$' | awk '{print $3}')
default_k_args=$(fai-chboot -L '^default$' | \
sed -r "s/^(\S+\s+){3}(.*)/\2/")