set -eE -o pipefail
trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
-x=$(readlink -f "$BASH_SOURCE"); cd ${x%/*}
+this_file="$(readlink -f -- "${BASH_SOURCE[0]}")"
+readonly this_file this_dir="${this_file%/*}"
+cd "$this_dir"
usage() {
- cat <<EOF
-usage: ${0##*/} [OPTIONS] [HOSTNAME|IP|default]
+ cat <<'EOF'
+usage: myfai-chboot [OPTIONS] [HOSTNAME|IP|default]
-Sets up tftp pxe config and nfs server on host "faiserver".
+Sets up tftp pxe config and nfs server on host "faiserver.b8.nz".
If our kernel has no nfs support, uses apache intead of nfs, and depends
on another repo of Ian Kelling, basic-https-conf, where the file is at
-h|--help Print help and exit.
EOF
- exit $1
+ exit 0
}
case $1 in
-h|--help) usage ;;
esac
-faiserver_addr=$(host faiserver | sed -rn 's/^\S+ has address //p;T;q' ||:)
-host=$(./chost faiserver)
+faiserver_addr=$(host faiserver.b8.nz | sed -rn 's/^\S+ has address //p;T;q' ||:)
+host=$(./chost faiserver.b8.nz)
if ip a | grep "^ *inet.\? $faiserver_addr" &>/dev/null; then
./myfai-chboot-local "$@"
else