exit $1
}
+pre="${0##*/}:"
+m() { printf "$pre %s\n" "$*"; "$@"; }
+e() { printf "$pre %s\n" "$*"; }
+err() { echo "[$(date +'%Y-%m-%d %H:%M:%S%z')]: $pre: $*" >&2; }
+
##### begin command line parsing ########
dhcp=true
fsf=false
case $HOSTNAME in
- x2|x3|kw) fsf=true ;;
+ x3|kw) fsf=true ;;
esac
chboot_args=()
##### end command line parsing ########
-e() {
- echo "$@"
- "$@"
-}
-
archlike() {
cat <<EOF
dhcp-option-force=209,boot/syslinux/${type}iso.cfg
ack-wait() {
if $fsf; then
- wait_cmd="ssh tarantula tail -n0 -f /var/log/syslog"
+ wait_cmd="ssh tarantula.office.fsf.org tail -n0 -f /var/log/syslog"
else
wait_cmd="ssh wrt logread -f"
fi
echo $line
fi
done < <($wait_cmd ||:) # tail returns 2 it seems
- e sleep 20
+ m sleep 20
}
set-pxe() {
$dhcp || return 0
if $fsf; then
if [[ ! $cmd ]]; then
- echo "$0: removing pxe for $host on tarantula"
- ssh tarantula bash -e <<EOF
+ e "removing pxe for $host on tarantula"
+ ssh tarantula.office.fsf.org bash -e <<EOF
sed -ri 's/^( *host +$host *\{).*/\1/' /etc/dhcp3/dhcpd.conf
/etc/init.d/dhcp3-server restart
EOF
elif [[ $cmd == fai ]]; then
- echo "$0: adding pxe for $host on tarantula"
- ssh tarantula bash -e <<EOF
+ e "adding pxe for $host on tarantula"
+ ssh tarantula.office.fsf.org bash -e <<EOF
sed -ri 's/^( *host +$host *\{).*/\1 next-server faiserver.office.fsf.org; filename "pxelinux.0";/' /etc/dhcp3/dhcpd.conf
/etc/init.d/dhcp3-server restart
EOF
fi
else
- echo "$0: updating dnsmasq.conf:"
- $cmd
+ e "updating dnsmasq.conf:"
+ m $cmd
${cmd:-:}|ssh wrt "cedit pxe /etc/dnsmasq.conf || /etc/init.d/dnsmasq restart
$([[ $type == arch || $type == parabola ]] && echo archlike-pxe-mount)"
fi
if $set; then
set-pxe
if [[ $type == fai ]]; then
- e myfai-chboot ${chboot_args[@]} $host
+ m myfai-chboot ${chboot_args[@]} $host
if $redep; then
- e fai-redep
+ m fai-redep
fi
else
# This will fail if faiserver is not setup, so ignore any