From efcfb463ceda4de1d9953da31a2c0737471e5cf8 Mon Sep 17 00:00:00 2001 From: Ian Kelling Date: Fri, 2 Jun 2017 00:16:24 -0700 Subject: [PATCH] add rescue, fix default pxe, ubuntu locale --- README | 18 ++++++++------ dsfull | 6 +++-- fai/config/scripts/UBUNTU/90-apt | 10 ++++++++ faiserver-setup | 2 ++ myfai-chboot | 6 ++++- myfai-chboot-local | 41 ++++++++++++++++++++++++++------ pxe-server | 9 +++---- wrt-setup | 4 ++-- 8 files changed, 73 insertions(+), 23 deletions(-) create mode 100644 fai/config/scripts/UBUNTU/90-apt diff --git a/README b/README index 5745f03..72669bb 100644 --- a/README +++ b/README @@ -60,14 +60,18 @@ pxe-server # disable/enable pxe dhcp, tfp, and nfs wrt-setup-remote # setup my router in general: dhcp, dns, etc. -# Scripts to do a distro install +# Script to do a distro install -arch-init-remote # install arch after it's been booted into it's setup env dsfull # install & post-install a new fai distro +arch-init-remote # install arch after it's been booted into it's setup env fai-kexec # Kexec this or a remote machine using host faiserver +live-kexec # fai kexec from upstream live cds, e.g. curl live-kexec|bash + + +# Test scripts + arch-revm # test arch install on a fresh vm fai-revm # test fai install on a fresh vm -live-kexec # fai kexec from upstream live cds, e.g. curl live-kexec|bash # Scripts to call after a distro install for various reasons @@ -81,7 +85,7 @@ fresize # resize swap or boot partitions in a host License stuff: -The license for the project is GPLv2 or later, mostly because fai is -and I periodically rebase off their example setup for debian. Also, -there is a modified encrypt.upstream, which is from the cryptsetup -package in arch, which is under the same license. +The license for the project is GPLv2 or later, mostly because fai is and +I periodically rebase off their example config, which contains small +scripts. Also, there is a modified encrypt.upstream, which is from the +cryptsetup package in arch, which is under the same license. diff --git a/dsfull b/dsfull index 40c933c..4176350 100755 --- a/dsfull +++ b/dsfull @@ -32,8 +32,9 @@ Note: relies on other repos and paths specific to Ian's system. Note: disables btrbk.timer. If it was active before, it should be manual reenabled after completion. ---no-r Don't ssh to host and reboot. -k ssh to host and kexec, don't use pxe. implies --no-r +--no-r Don't ssh to host and reboot. Use this for when you are + booting or rebooting from some other means. -h|--help Print help and exit. Note: Uses GNU getopt options parsing style @@ -101,4 +102,5 @@ while [[ $(ser is-active btrbk.service) == active ]]; do sleep 5 done e btrbk-run -t $host -e dsremote $host +ssh $host /a/bin/distro-setup/distro-begin +#e dsremote $host diff --git a/fai/config/scripts/UBUNTU/90-apt b/fai/config/scripts/UBUNTU/90-apt new file mode 100644 index 0000000..5e2d1e3 --- /dev/null +++ b/fai/config/scripts/UBUNTU/90-apt @@ -0,0 +1,10 @@ +#! /bin/bash + +# note: the name of this scripts doesn't fit it's contents, but it's +# because we are taking just part of the corresponding fai example +# script, and it's easier to keep up with upstream changes if the file +# name is the same. + +ainsl -v /etc/locale.gen '^en_US.UTF-8 UTF-8' +$ROOTCMD locale-gen +$ROOTCMD update-locale LANG=en_US.UTF-8 diff --git a/faiserver-setup b/faiserver-setup index f1ab4ba..f60ec47 100755 --- a/faiserver-setup +++ b/faiserver-setup @@ -154,6 +154,8 @@ s,^( *FAI_DEBOOTSTRAP=).*,\1"$base $r", # disabled for now, since creating fai nfsroot on my arm machine # is not working #/--arch amd64/!s/^(\s*FAI_DEBOOTSTRAP_OPTS=")/\1--arch amd64 / +/^\s*FAI_ROOTPW/d +$ a FAI_ROOTPW="$(&2' ERR +fai_action_arg=I +fai_reboot_arg=,reboot case $1 in -h|--help) echo "see help from myfai-chboot" exit 0 ;; + -S) + fai_action_arg=S + fai_reboot_arg= + shift + ;; esac [[ $EUID == 0 ]] || exec sudo "${BASH_SOURCE}" "$@" @@ -17,9 +24,29 @@ e() { echo "$@"; "$@"; } host=$1 type -t host &>/dev/null || apt-get -y install dnsutils -ip=$(host $host | sed -rn 's/^\S+ has address //p;T;q') -gateway_ip=$(route -n | sed -rn 's/^0\.0\.0\.0\s+(\S+).*/\1/p') -my_ip=$(host faiserver $gateway_ip | sed -rn 's/^\S+ has address //p;T;q') +gateway_if=$(ip route | sed -rn 's/^default via \S+ dev (\S+) .*/\1/p') +if [[ ! $gateway_if ]]; then + echo "$0: failed to find gateway interface" + exit 1 +fi +# assuming ipv4, or else we might need to deal with multiple addresses +# in an ipv4 + ipv6 network. +network=$(ip -4 -o a show dev $gateway_if | sed -rn '/scope.*global/s/^(\S+\s+){3}(\S+)\s.*/\2/p') +if [[ ! $network ]]; then + echo "$0: failed to find network" + exit 1 +fi +my_ip=${network%/*} +if [[ $host == default ]]; then + ip=$network +else + ip=$(host $host | sed -rn 's/^\S+ has address //p;T;q')/32 +fi + + +# alternate way of getting my ip +#gateway_ip=$(ip route | sed -rn 's/^default via (\S+) .*/\1/p') +#my_ip=$(host faiserver $gateway_ip | sed -rn 's/^\S+ has address //p;T;q') if modprobe nfsd &>/dev/null; then std_arg="-u nfs://faiserver/srv/fai/config" @@ -28,8 +55,8 @@ if modprobe nfsd &>/dev/null; then # I restrict it to one ip as simple but imperfect access control. sed -ri --follow-symlinks '\%^/srv/fai/%d' /etc/exports cat >>/etc/exports <