# 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 <<EOF
+Usage: ${0##*/} HOSTNAME
+EOF
+ exit $1
+}
+
set -x
set -eE -o pipefail
if [[ ! $1 ]]; then
echo "error: expect a hostname in \$1 "
- exit 1
+ usage 1
fi
host=$1
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-# Set grub to boot into a different distro, and reboot unless -r
-# $0 [DISTRO_NAME]
-# with no argument, print available distros
-
-# DISTRO_NAME is based on the partition names in /boot. eg boot_debianjessie
set -eE -o pipefail
trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
[[ $EUID == 0 ]] || exec sudo "$BASH_SOURCE" "$@"
+usage() {
+ cat <<EOF
+Usage: ${0##*/} [OPTIONS] DISTRO_NAME
+Set grub to boot into a different distro, and reboot unless -r
+
+With no argument, print available distros
+DISTRO_NAME is based on the partition names in /boot.
+For example debianjessie for the partitionn boot_debianjessie.
+
+-r Do not reboot.
+-d Enable debug output.
+-h|--help Print help and exit.
+
+Note: Uses GNU getopt options parsing style
+EOF
+ exit $1
+}
###### begin command line parsing #####
reboot=true
-while [[ $1 == -* ]]; do
+temp=$(getopt -l opt o "$@") || usage 1
+eval set -- "$temp"
+while true; do
case $1 in
-d) set -x; shift ;;
-r) reboot=false; shift ;;
- --) break ;;
+ -h|--help) usage ;;
+ --) shift; break ;;
+ *) echo "$0: Internal error!" ; exit 1 ;;
esac
done
# 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.
+
set -eE -o pipefail
cleanup() { :; }
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-# Note, sometimes shutting down the existing demohost vm
-# fails. Just run again if that happens.
-# Deploy fai configuration to faiserver,
-# then start a virtual machine to test the config.
cleanup() { :; }
set -eE -o pipefail
e() { echo "$*"; "$@"; }
-# I had this set false as default before, can't remember why. oh well.
+
+usage() {
+ cat <<EOF
+# Usage: ${0##*/} [OPTIONS]
+Setup fai or arch pxe (depending on $0 name)
+then start a virtual machine to test the config
+
+Note, sometimes shutting down the existing demohost vm
+fails. Just run again if that happens.
+
+-r Do not reboot.
+-n Create new qcow2(s) for vm
+-h|--help Print help and exit.
+
+Note: Uses GNU getopt options parsing style
+EOF
+ exit $1
+}
+
+
+# not sure why I wanted to have this option before. oh well.
redeploy=true
+
+reboot=true
+temp=$(getopt -l opt o "$@") || usage 1
+eval set -- "$temp"
+while true; do
+ case $1 in
+ -n) new_disk=true; shift ;;
+ -r) reboot=false; shift ;;
+ -h|--help) usage ;;
+ --) shift; break ;;
+ *) echo "$0: Internal error!" ; exit 1 ;;
+ esac
+done
+
+
if [[ $1 == -r ]]; then
redeploy=false
fi
[[ ${0##*/} == arch-revm ]]
}
-new_disk=false
-[[ ! $1 ]] || new_disk=true
-
cleanup() { ./pxe-server :; }
if is_arch_revm; then
./pxe-server arch
#!/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
usage() {
cat <<EOF
-Usage: ${0##*/} [-n] +/-SIZE[g] swap|boot
+Usage: ${0##*/} [OPTIONS] +/-SIZE[g] swap|boot
Assuming Ian Kelling's partition scheme,
Resize swap or boot, expanding or shrinking the root fs and partition to compensate.
-n Dry run
-r Reboot now if it's needed.
--h|--help Print help.
+-h|--help Print help and exit.
SIZE is MiB, or if g is specified, GiB.
If using multiple devices, SIZE is applied to each device, so total change is
SIZE * devices.
-
+Note: Uses GNU getopt options parsing style
EOF
exit $1
}
reboot_not=false
dry_run=false
+
+temp=$(getopt -l opt o "$@") || usage 1
+eval set -- "$temp"
while true; do
case $1 in
-r) reboot_now=true; shift ;;
-n) dry_run=true; shift ;;
-h|--help) usage ;;
- *) break ;;
+ --) shift; break ;;
+ *) echo "$0: Internal error!" ; exit 1 ;;
esac
done
TYPE is one of arch, plain, fai, or : for no pxe server.
HOST makes the pxe server only for that specific host
--h|--help Print help and exit
--- Subsequent arguments are never treated as options
-r Don't redeploy fai config.
-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.
+-h|--help Print help and exit
+
+
+Note: Uses GNU getopt options parsing style
EOF
exit $1
}
redep=true
acks=2
wait=false
-while [[ $1 ]]; do
+temp=$(getopt -l help hra "$@") || usage 1
+eval set -- "$temp"
+while true; do
case $1 in
- --) shift; break ;;
-h|--help) usage ;;
-r) redep=false; shift ;;
-a) wait=true; shift ;;
- *) args+=("$1"); shift ;;
+ --) shift; break ;;
+ *) echo "$0: Internal error!" ; exit 1 ;;
esac
done
-args+=("$@")
-
-read type host <<<"${args[@]}"
+read type host <<<"$@"
if [[ ! $type ]]; then
echo "$0: error: exptected 1 argument of type"
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+# Usage: wrt-setup-remote
+
set -eE -o pipefail
trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR