From 875cea0c266c7802b336f5a8b61b63e109e670fb Mon Sep 17 00:00:00 2001 From: Ian Kelling Date: Sat, 11 Feb 2017 13:20:27 -0800 Subject: [PATCH] ssh key fix, consistent help args --- README | 4 +-- arch-init-remote | 16 ++++++---- eboot | 28 +++++++++++++++- fai-kexec | 1 - fai-revm | 1 - fai/config/distro-install-common/end | 23 +++++++------ fai/config/scripts/GRUB_PC/11-ian | 5 ++- faiserver-revm | 19 ++++++++--- faiserver-setup | 26 ++++++++++----- faiserver-uninstall | 14 +++++++- install-chboot | 19 +++++++++-- live-kexec | 48 +++++++++++++++++++++------- myfai-chboot | 2 -- wrt-setup-remote | 14 ++++++-- 14 files changed, 164 insertions(+), 56 deletions(-) diff --git a/README b/README index fa28fa9..af4c0ba 100644 --- a/README +++ b/README @@ -61,7 +61,7 @@ wrt-setup-remote # setup my router in general: dhcp, dns, etc. # Scripts to do a distro install -arch-init-remote # install arch (after it's been booted into it's setup env) +arch-init-remote # install arch after it's been booted into it's setup env dsfull # install & post-install a new fai distro fai-kexec # kexec to fai tftp server that pxe would normally point to arch-revm # test arch install on a fresh vm @@ -74,7 +74,7 @@ live-kexec # fai kexec from upstream live cds, e.g. curl live-kexec|bash chboot # Set grub to boot into a different distro (installed earlier) install-chboot # reinstall chboot to /boot subvols, for chboot updates. eboot # reboot without automatic disk decryption -fai-wrapper # Evaluate and use fai classes outside of fai. +fai-wrapper # use fai classes outside of fai. sourced, not called. fresize # resize swap or boot partitions in a host diff --git a/arch-init-remote b/arch-init-remote index 6e460a5..76e2cf2 100755 --- a/arch-init-remote +++ b/arch-init-remote @@ -15,17 +15,21 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +set -x + +set -eE -o pipefail +trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR + usage() { cat <&2' ERR +case $1 in + -h|--help) usage ;; +esac if [[ ! $1 ]]; then echo "error: expect a hostname in \$1 " diff --git a/eboot b/eboot index cb487cb..6d5ce5e 100755 --- a/eboot +++ b/eboot @@ -1,6 +1,32 @@ #!/bin/bash +# Copyright (C) 2017 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. + + +usage() { + cat <> $f fi -# ssh host keys -# note, $BASH_SOURCE is not defined here under fai. -src=$(dirname "$0")/p/c/machine_specific/$HOSTNAME/filesystem/etc/ssh -dst=$target/etc/ssh -if [[ -e $src && -e $dst ]]; then - # outside of fai context, we skip this - cp -rT $src $dst -fi - - dir=/p/c/machine_specific/$HOSTNAME/.unison $ROOTCMD mkdir -p $dir if ! $ROOTCMD test -L /root/.unison; then diff --git a/fai/config/scripts/GRUB_PC/11-ian b/fai/config/scripts/GRUB_PC/11-ian index 8cd841f..8df5b13 100755 --- a/fai/config/scripts/GRUB_PC/11-ian +++ b/fai/config/scripts/GRUB_PC/11-ian @@ -40,17 +40,16 @@ if [[ ! -e $dst && -e $src ]]; then mount -o bind $src $dst fi +$FAI/distro-install-common/end if ifclass VOL_STABLE_BOOTSTRAP; then fcopy -ri /etc/systemd/system chroot $FAI_ROOT bash <<'EOFOUTER' systemctl enable fai_check.service EOFOUTER - exit 0 + exit 0 # avoid unnecessary stuff in bootstrap vol fi -$FAI/distro-install-common/end - # these get copied in an earlier stage by fai, but leaving it here since # I run this as a single post-fai script to update things that have changed. fcopy -riB /etc/apt diff --git a/faiserver-revm b/faiserver-revm index a0a0bb8..6d598a6 100755 --- a/faiserver-revm +++ b/faiserver-revm @@ -1,9 +1,4 @@ #!/bin/bash -l -# Usage: faiserver-revm -# Create a vm which is a fai server. -# -# This assumes you've set the dhcp server to make -# 52:54:00:56:09:f9 be faiserver. set -x set -eE -o pipefail @@ -12,6 +7,20 @@ trap 'cleanup; echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR x="$(readlink -f "$BASH_SOURCE")"; cd ${x%/*} +usage() { + cat <&2' ERR [[ $EUID == 0 ]] || exec sudo "${BASH_SOURCE}" "$@" +usage() { + cat <&2' ERR [[ $EUID == 0 ]] || exec sudo "${BASH_SOURCE}" "$@" +usage() { + cat <&2' ERR -# usage install-chboot: isntalls chboot to all /boot subvols, -# in case there is an issue booting and it is needed. -# Run this when chboot changes. x=$(readlink -f "$BASH_SOURCE"); cd ${x%/*} +usage() { + cat <&2' ERR x="$(readlink -f "$BASH_SOURCE")"; cd ${x%/*} +usage() { + cat <