summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2f13039)
raw | patch | inline | side by side (parent: 2f13039)
author | Ian Kelling <ian@iankelling.org> | |
Sun, 22 Jan 2017 01:39:34 +0000 (17:39 -0800) | ||
committer | Ian Kelling <ian@iankelling.org> | |
Mon, 6 Feb 2017 06:21:42 +0000 (22:21 -0800) |
15 files changed:
README | patch | blob | history | |
arch-init | patch | blob | history | |
fai-kexec | patch | blob | history | |
fai-redep | patch | blob | history | |
fai/config/class/50-host-classes | patch | blob | history | |
fai/config/files/etc/systemd/system/fai_check.service/VOL_STABLE_BOOTSTRAP | [moved from fai/config/files/etc/systemd/system/fai_check.service/STABLE_BOOTSTRAP with 100% similarity] | patch | blob | history |
fai/config/files/root/fai-check/VOL_STABLE_BOOTSTRAP | [moved from fai/config/files/root/fai-check/STABLE_BOOTSTRAP with 50% similarity] | patch | blob | history |
fai/config/hooks/instsoft.DEFAULT | patch | blob | history | |
fai/config/scripts/GRUB_PC/11-ian | patch | blob | history | |
faiserver-revm | patch | blob | history | |
install-chboot | patch | blob | history | |
myfai-chboot | patch | blob | history | |
myfai-chboot-local | patch | blob | history | |
pxe-server | patch | blob | history | |
wrt-setup-remote | patch | blob | history |
index 10d52fed129df56318d0a98600007528941ad1a1..5e09791e75d4c320ecb0a752f7090c9fa8e6a475 100644 (file)
--- a/README
+++ b/README
Multi-boot/distro btrfs provisioning
-Some things are specific to my home network. Uses pxe or pxe-kexec (on
-libreboot, I have not addded a pxe rom. I use a minimal debian stable
-subvolume which acts like a pxe rom). I use this for bare metal and vms,
-and two scripts which can run post boot so I use them on vps distributed
-image as well.
+Some things are specific to my home network, and uses files with secrets
+that are not in this repo. Uses pxe or pxe-kexec (on libreboot, I have
+not added a pxe rom, I use a minimal debian stable subvolume which acts
+like a pxe rom). I use this for bare metal and vms, and two scripts
+which can run post boot so I use them on vps distributed image as well.
Features people may find useful: installs encrypted trisquel belanos, ,
debian jessie, debian stretch, ubuntu 16.04, and arch (havne't done
dsfull # install & setup a new fai distro (if data partition already synced)
eboot # reboot without automatic disk decryption
fai-kexec # kexec to fai tftp server that pxe would normally point to
+fai-redep # Deploy fai configuration to host "faiserver"
fai-revm # test fai on a fresh vm
fai-wrapper # Evaluate and use fai classes outside of fai.
faiserver-revm # create a vm which is a fai server using pxe & preseed file
diff --git a/arch-init b/arch-init
index 37fa90b092111e7e829a891fadb6c7e3cef6dfcc..aa26ffdf68ac2a9051d562282c76207645a74613 100755 (executable)
--- a/arch-init
+++ b/arch-init
set -eE -o pipefail
trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
-cd $(dirname $(readlink -f "$BASH_SOURCE"))
+x="$(readlink -f "$BASH_SOURCE")"; cd ${x%/*}
export HOSTNAME="$1"
mirror=$2
diff --git a/fai-kexec b/fai-kexec
index 5e10ac2d1000df9eebadd0bdd2661afe5afcf74b..dbf003be355563b8188b02240e7bae7f61f681f8 100755 (executable)
--- a/fai-kexec
+++ b/fai-kexec
# 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
+
+usage() {
+ cat <<'EOF'
+usage: $0 [-h|--help] [SERVER]
+kexec to SERVER (faiserver by default), pxe boot from it's tftp server
+
+This does what pxe would do, but skipping boot sequence up to and
+including the pxe dhcp.
+
+EOF
+ exit $1
+}
+
+case $1 in
+ -h|--help) usage ;;
+esac
+
+
+
if [[ $1 ]]; then
prefix="ssh root@$1"
fi
diff --git a/fai-redep b/fai-redep
index b035ef55a74283163b544f8d58b78f0b89c0121e..b8fabac4ac14e42da83fd3f6afc6a83cd44ae8ac 100755 (executable)
--- a/fai-redep
+++ b/fai-redep
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
set -x
-# Deploy fai configuration to faiserver,
-# then start a virtual machine to test the config.
+
set -eE -o pipefail
trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
-cd $(dirname $(readlink -f "$BASH_SOURCE"))
+x="$(readlink -f "$BASH_SOURCE")"; cd ${x%/*}
+
+usage() {
+ cat <<EOF
+usage: ${0##*/} [-h|--help]
+Deploy fai configuration to host "faiserver"
+EOF
+ exit $1
+}
+case $1 in
+ -h|--help) usage ;;
+esac
# i use faiserver as a dns alias, but ssh key is associated with
index 9aa05cc16d22b01a6dd0426cf43d934f1be887ca..c6ac9fcbd7c21ad5b96d344dc837a6314407de87 100755 (executable)
# STABLE, STRETCH64, XENIAL64, BELANOS64
# the distro subvol name, we can add as many of these as we want:
# VOL_STABLE, VOL_STABLE_BOOTSTRAP, VOL_STRETCH, VOL_XENIAL, VOL_BELANOS
+# Using VOL_STABLE_BOOTSTRAP sets up the install to act like a pxe rom if
+# grub sets a specific var.
# and the class which defines the apt sources files we want,
# STABLE_FREE, STABLE_NONFREE, TESTING_FREE, TESTING_NONFREE,
# XENIAL_FREE (no XENIAL_NONFREE setup yet), BELANOS, STABLE_LINODE.
fi
fi
-# use a list of classes for our demo machine
echo "FAIBASE"
-#echo "PARTITION_PROMPT"
+echo "PARTITION_PROMPT"
#echo REPARTITION
diff --git a/fai/config/files/etc/systemd/system/fai_check.service/STABLE_BOOTSTRAP b/fai/config/files/etc/systemd/system/fai_check.service/VOL_STABLE_BOOTSTRAP
similarity index 100%
rename from fai/config/files/etc/systemd/system/fai_check.service/STABLE_BOOTSTRAP
rename to fai/config/files/etc/systemd/system/fai_check.service/VOL_STABLE_BOOTSTRAP
rename from fai/config/files/etc/systemd/system/fai_check.service/STABLE_BOOTSTRAP
rename to fai/config/files/etc/systemd/system/fai_check.service/VOL_STABLE_BOOTSTRAP
diff --git a/fai/config/files/root/fai-check/STABLE_BOOTSTRAP b/fai/config/files/root/fai-check/VOL_STABLE_BOOTSTRAP
similarity index 50%
rename from fai/config/files/root/fai-check/STABLE_BOOTSTRAP
rename to fai/config/files/root/fai-check/VOL_STABLE_BOOTSTRAP
index c06702901fd46a1f097da9d51ad569e7e1aae492..7621bdf1a1a2581071ca63a2170fda7a0c1d2dca 100755 (executable)
rename from fai/config/files/root/fai-check/STABLE_BOOTSTRAP
rename to fai/config/files/root/fai-check/VOL_STABLE_BOOTSTRAP
index c06702901fd46a1f097da9d51ad569e7e1aae492..7621bdf1a1a2581071ca63a2170fda7a0c1d2dca 100755 (executable)
set -eE -o pipefail
trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
+
+
+usage() {
+ cat <<EOF
+Usage: ${0##*/} [OPTION]
+If grub var set, act like pxe rom and pxe-kexec to faiserver
+
+-f|--force do kexec if we can reach faiserver
+-h|--help Print help and exit.
+
+Note: Uses GNU getopt options parsing style
+EOF
+ exit $1
+}
+
+
+
# Keep it short so we don't delay too much wnen we don't have networking.
# In practice, on my home network, on an x200, it took 15 seconds, so
# give it an extra 10 seconds, which seems fairly short as I write this.
m() { printf "%s\n" "$*"; "$@"; }
-check-fai() {
- # we could just as well check if last_boot != /debianstable_boostrap
- # the intent with this one is just a little clearer.
- if [[ $did_fai_check == true ]]; then
- grub-editenv /mnt/grubenv set did_fai_check=os_true
- # our service does not wait for network-online.target,
- # because it will wait for too long when we don't have a network
- # connection. So, we wait for 10 seconds.
- # ref: https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget/
- deadline=$(( `date +%s` + NETWORK_TIMOUT_SECS ))
- while ! nc -zu faiserver 69; do
- if (( `date +%s` > deadline )); then
- echo "fai-check: hit $NETWORK_TIMOUT_SECS s tftp server timeout"
- return 0
- fi
- sleep 1
- done
- m pxe-kexec -n --ignore-whitelist -l fai-generated faiserver ||:
- else
- return 0
- fi
+try-kexec() {
+ deadline=$(( `date +%s` + NETWORK_TIMOUT_SECS ))
+ while ! nc -zu faiserver 69; do
+ if (( `date +%s` > deadline )); then
+ echo "fai-check: hit $NETWORK_TIMOUT_SECS s tftp server timeout"
+ return 0
+ fi
+ sleep 1
+ done
+ m pxe-kexec -n --ignore-whitelist -l fai-generated faiserver ||:
}
+case $1 in
+ -f|--force)
+ try-kexec
+ exit
+ ;;
+esac
+
first=true
for dev in $(btrfs fi show / | sed -rn 's#^\s*devid\s.*\s([^0-9 ]+)\S+$#\1#p' \
|sort); do
set +x
fi
first=false
- check-fai
+ # we could just as well check if last_boot != /debianstable_boostrap
+ # the intent with this one is just a little clearer.
+ if [[ $did_fai_check == true ]]; then
+ grub-editenv /mnt/grubenv set did_fai_check=os_true
+ # our service does not wait for network-online.target,
+ # because it will wait for too long when we don't have a network
+ # connection. So, we wait for 10 seconds.
+ # ref: https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget/
+ try-kexec
+ else
+ return 0
+ fi
else
# we make sure there is only 1 grubenv,
# so grub can just find the first one, in whatever order
index 36c0cafd507ac6d1a35ccf3f2bb0a0e62e87f9e0..6d7f4c0222611bfaacd58b4f16b9706525a16fb2 100755 (executable)
#!/bin/bash
# exit for any vm which is not our test vm
-if ifclass VM && ! ifclass demohost || ifclass STABLE_BOOTSTRAP; then
+if ifclass VM && ! ifclass demohost || ifclass VOL_STABLE_BOOTSTRAP; then
exit 0
fi
index 6a55e4406455b436292444cba56a344a7705a23d..0a3bbdb959dd10fd037b537927428305c121aeb6 100755 (executable)
fcopy -riB /boot
# this is also done by FABASE/10-misc by default.
fcopy -riB /root
-if ifclass STABLE_BOOTSTRAP; then
- fcopy -ri /etc/systemd/system
- chroot $FAI_ROOT bash <<'EOFOUTER'
-systemctl enable fai_check.service
-EOFOUTER
- exit 0
-fi
src=$FAI/distro-install-common/shadow
dst=/target/etc/ssh
if [[ -e $src && -e $dst ]]; then
# outside of fai context, we skip this
- cp -rT $src
+ cp -rT $src $dst
fi
+fcopy -riB /etc/ssh
+
+if ifclass VOL_STABLE_BOOTSTRAP; then
+ fcopy -ri /etc/systemd/system
+ chroot $FAI_ROOT bash <<'EOFOUTER'
+systemctl enable fai_check.service
+EOFOUTER
+ exit 0
+fi
+
+
$FAI/distro-install-common/end
# these get copied in an earlier stage by fai, but leaving it here since
sleep 1
$ROOTCMD apt-get update
-fcopy -riB /etc/ssh
chroot $FAI_ROOT bash <<'EOF'
set -eE -o pipefail
diff --git a/faiserver-revm b/faiserver-revm
index 78427231df54960f855e2c15b5738c20488742a8..a0a0bb8b421ecf11ea4b666ec683bff61c386944 100755 (executable)
--- a/faiserver-revm
+++ b/faiserver-revm
cleanup() { :; }
trap 'cleanup; echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
-cd "${BASH_SOURCE%/*}"
+x="$(readlink -f "$BASH_SOURCE")"; cd ${x%/*}
cleanup() { pxe-server :; }
./debian-pxe-preseed -i 192.168.1.1 -u ian -g vda
diff --git a/install-chboot b/install-chboot
index 838c0ae02e63565a37963088f8c65490734dc45d..d066101642454420d7664649dbc1f9fc88d61104 100755 (executable)
--- a/install-chboot
+++ b/install-chboot
# in case there is an issue booting and it is needed.
# Run this when chboot changes.
-cd "${BASH_SOURCE%/*}"
+x=$(readlink -f "$BASH_SOURCE"); cd ${x%/*}
e() { echo "$@"; "$@"; }
diff --git a/myfai-chboot b/myfai-chboot
index 1abead8c5922a7feb7bcc1df6c1adcbf9b4e9841..310969e2708f42015284bc8945d780f405506856 100755 (executable)
--- a/myfai-chboot
+++ b/myfai-chboot
set -eE -o pipefail
trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
+x=$(readlink -f "$BASH_SOURCE"); cd ${x%/*}
usage() {
- cat <<'EOF'
-usage $0 [hostname|ip|default]...
+ cat <<EOF
+usage: ${0##*/} [-h|--help] [hostname|ip|default]...
-Sets up tftp pxe config. No argument disables for all hosts.
+Sets up tftp pxe config on host "faiserver". Argument sets the host to
+enable it for, "default" is for all hosts. No argument disables for all
+hosts.
EOF
exit $1
}
-cd "${BASH_SOURCE%/*}" # directory of the script
+
+case $1 in
+ -h|--help) usage ;;
+esac
+
host=$(chost faiserver)
ssh root@$host bash -s "$@" <myfai-chboot-local
diff --git a/myfai-chboot-local b/myfai-chboot-local
index 9eac43f028325fe87e9d2860955dabde42841e5e..66c496d069afa8dfb4f0b07782364a914c25cb1f 100755 (executable)
--- a/myfai-chboot-local
+++ b/myfai-chboot-local
set -eE -o pipefail
trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
+case $1 in
+ -h|--help)
+ echo "see help from myfai-chboot"
+ exit 0
+ ;;
+esac
+
[[ $EUID == 0 ]] || exec sudo "${BASH_SOURCE}" "$@"
e() { echo "$@"; "$@"; }
diff --git a/pxe-server b/pxe-server
index e59854a85e466be75cbad22733ded83cae6c077e..9e74eeb757a030c9a367fabb3c8440597188d043 100755 (executable)
--- a/pxe-server
+++ b/pxe-server
-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
- exactly why this caused a problem, but I'm hoping the sleep
- will take care of it.
--w Initially setup pxe, then wait like -a.
+
+-a Don't setup pxe, just 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 exactly why this caused a
+ problem, but I'm hoping the sleep will take care of it.
+
+-w Setup pxe, then wait like -a.
-h|--help Print help and exit
diff --git a/wrt-setup-remote b/wrt-setup-remote
index 57e2c599d8b59fb9ae03701b7579f5fffb481ec4..f2948b0e9e171d2d7268d44c4be7ea633d9e8941 100755 (executable)
--- a/wrt-setup-remote
+++ b/wrt-setup-remote
set -eE -o pipefail
trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
-cd "${BASH_SOURCE%/*}"
+x="$(readlink -f "$BASH_SOURCE")"; cd ${x%/*}
h=root@192.168.1.1
scp /a/bin/fai/wrt-setup /a/bin/cedit/cedit $h:/usr/bin