arch-init-remote # install arch (after it's been booted into it's setup env)
chboot # Set grub to boot into a different distro (installed earlier)
dsfull # install & setup a new fai distro (if data partition already synced)
+eboot # reboot and keep disks encrypted
+fai-kexec # kexec to fai tftp server that pxe would normally point to
fai-revm # test fai on a fresh vm
faiserver-revm # create a vm which is a fai server using pxe & preseed file
faiserver-uninstall # uninstall fai-server
faiserver-setup # install fai-server on the current machine
fresize # resize swap or boot partitions in a host
+myfai-chboot # Sets up tftp pxe config on fai server
pxe-server # temporarily enable (usually) fai or arch boot server
wrt-setup-remote # setup my router
ubuntu-xenial-live-fai-kexec # do fai install from xenial live cd using kexec
#!/bin/bash -l
# Copyright (C) 2016 Ian Kelling
-# distro setup full using fai. (assuming we already synced data files to the host)
-# Usage: dsfull [-r] HOST
-# -r for no reboot.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+# http://www.apache.org/licenses/LICENSE-2.0
+
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
set -eE -o pipefail
cleanup() { :; }
shift
fi
+usage() {
+ cat <<EOF
+Usage: ${0##*/} [OPTIONS] HOST
+distro setup full using fai. (assuming we already synced data files to the host)
+
+--no-r Don't ssh to host and reboot.
+-k ssh to host and kexec, don't use pxe. implies --no-r
+-h|--help Print help and exit.
+
+Note: Uses GNU getopt options parsing style
+EOF
+ exit $1
+}
+
+##### begin command line parsing ########
+
+reboot=true
+kexec=false
+temp=$(getopt -l help,no-r hk "$@") || usage 1
+eval set -- "$temp"
+while true; do
+ case $1 in
+ --no-r) reboot=false; shift ;;
+ -k) kexec=true; reboot=false; shift ;;
+ -h|--help) usage ;;
+ --) shift; break ;;
+ *) echo "$0: Internal error!" ; exit 1 ;;
+ esac
+done
host=$1
-if [[ ! $host || $host == -h ]]; then
+##### end command line parsing ########
+
+
+if [[ ! $host ]]; then
echo "$0: error: expected 1 arg of hostname"
exit 1
fi
-set -x
-
-cleanup() { pxe-server; }
-pxe-server $host fai
+e() { echo "$@"; "$@"; }
+if $kexec; then
+ e fai-redep
+ e myfai-chboot $host
+ e fai-kexec $host ||:
+else
+ cleanup() { pxe-server; }
+ e pxe-server $host fai
+ if $reboot; then
+ # untested, this caused hang using here doc.
+ ssh $host "touch /tmp/keyscript-off; sudo reboot" ||: &
+ fi
-if $reboot; then
- # untested, this caused hang using here doc.
- ssh $host "touch /tmp/keyscript-off; sudo reboot" ||: &
+ e pxe-server -a
+ cleanup() { :; }
fi
-pxe-server -a
-cleanup() { :; }
-
error=true
for ((i=0; i<240; i++)); do
if timeout -s 9 10 ssh $host :; then
echo "$0: error: timeout"
exit 1
fi
-dsremote $host
+e dsremote $host
--- /dev/null
+#!/bin/bash
+
+# reboot and keep disks encrypted.
+touch /tmp/keyscript-off
+[[ $EUID == 0 ]] || s=sudo
+$s reboot "$@"
--- /dev/null
+#!/bin/bash
+# Copyright (C) 2016 Ian Kelling
+
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+
+# http://www.apache.org/licenses/LICENSE-2.0
+
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+# kexec to fai tftp server that pxe would normally point to
+
+set -eE -o pipefail
+trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
+
+if [[ $1 ]]; then
+ prefix="ssh root@$1"
+fi
+$prefix touch /tmp/keyscript-off
+$prefix pxe-kexec -n --ignore-whitelist -l fai-generated faiserver
TYPE is one of arch, plain, fai.
HOST is a hostname known to the dhcp server, or default for all, or none to disable
--r Don't redeploy fai config.
+-r Don't redeploy fai config. For example, if there is a different host
+ that is mid-install.
-a Wait for 2 dhcp acks, then disable the pxe server after a delay.
First ack is for pxe boot, 2nd ack is for os boot. Sometimes
on debian, there is a 3rd one shortly after the 2nd. I can't remember