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
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.
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
sleep 5
done
e btrbk-run -t $host
-e dsremote $host
+ssh $host /a/bin/distro-setup/distro-begin
+#e dsremote $host
--- /dev/null
+#! /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
# 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="$(</q/root/shadow/standard)"
EOF
$sed 's/#LOGUSER/LOGUSER/' /etc/fai/fai.conf
config for all hosts, but leaves nfs server alone. Use faiserver-disable
to disable the nfs server.
+-S sets FAI_ACTION=sysinfo, and remove fai flag reboot.
+ Usefull for doing a system recovery.
+-h|--help Print help and exit.
+
EOF
exit $1
}
host=$(chost faiserver)
-ssh root@$host bash -s "$@" <myfai-chboot-local
+ssh root@$host bash -s -- "$@" <myfai-chboot-local
set -eE -o pipefail
trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&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}" "$@"
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"
# I restrict it to one ip as simple but imperfect access control.
sed -ri --follow-symlinks '\%^/srv/fai/%d' /etc/exports
cat >>/etc/exports <<EOF
-/srv/fai/config $ip/32(async,ro,no_subtree_check)
-/srv/fai/nfsroot $ip/32(async,ro,no_subtree_check,no_root_squash)
+/srv/fai/config $ip(async,ro,no_subtree_check)
+/srv/fai/nfsroot $ip(async,ro,no_subtree_check,no_root_squash)
EOF
exportfs -ra
else
# man page doesn't explain this, but this deletes & thus disables
# all chboot systems.
-e fai-chboot -Iv $std_arg default # set it to default to get a val out of it next
+e fai-chboot -${fai_action_arg}v $std_arg default # set it to default to get a val out of it next
kernel=$(fai-chboot -L '^default$' | awk '{print $3}')
default_k_args=$(fai-chboot -L '^default$' | \
sed -r "s/^(\S+\s+){3}(.*)/\2/")
esac
done
rm -f /srv/tftp/fai/pxelinux.cfg/*
-e fai-chboot -k "${k_args[*]}" -v -f verbose,sshd,createvt,reboot $std_arg $kernel "$host"
+e fai-chboot -k "${k_args[*]}" -v -f verbose,sshd,createvt$fai_reboot_arg $std_arg $kernel "$host"
for os boot. Sometimes on debian, there is a 3rd one shortly
after the 2nd. I can't remember exactly why this caused a
problem, but I'm hoping the sleep will take care of it.
-
+-S Pass -S to fai-chboot.
-w Setup pxe, then wait like -a.
-h|--help Print help and exit
redep=true
acks=2
wait=false
-temp=$(getopt -l help harw "$@") || usage 1
+temp=$(getopt -l help harSw "$@") || usage 1
eval set -- "$temp"
while true; do
case $1 in
-a) wait=true; set=false; shift ;;
-r) redep=false; shift ;;
+ -S) chboot_arg=-S; shift ;;
-w) wait=true; set=true; shift ;;
-h|--help) usage ;;
--) shift; break ;;
;;
esac
-if [[ $host ]]; then
+if [[ $host && $host != default ]]; then
host_tag="tag:$host,"
fi
if $set; then
set-pxe
if [[ $type == fai ]]; then
- e myfai-chboot $host
+ e myfai-chboot $chboot_arg $host
if $redep; then
e fai-redep
fi
dnsmasq_restart=false
v cedit /etc/hosts <<EOF || dnsmasq_restart=true
192.168.1.1 wrt
-192.168.1.2 treetowl mail.iankelling.org $HOME_DOMAIN
-192.168.1.3 frodo faiserver
+192.168.1.2 treetowl mail.iankelling.org $HOME_DOMAIN faiserver
+192.168.1.3 frodo
192.168.1.4 htpc
192.168.1.5 x2
192.168.1.6 demohost