+uninstalled-file-die() {
+ die "file $1 is not latest. run install-my-scripts or rerun with -f"
+}
+
+set-location() {
+ case $HOSTNAME in
+ kw)
+ at_work=true
+ ;;
+ kd|frodo)
+ at_home=true
+ ;;
+ x2|x3|sy|so)
+ if [[ $(timeout 1 dig +short @10.2.0.1 -x 10.2.0.2 2>&1 ||:) == kd.b8.nz. ]] \
+ && ip n show 10.2.0.1 | grep . &>/dev/null; then
+ # note: logic duplicated in 11-iank
+ at_home=true
+ elif ping -q -c1 -w1 hal.office.fsf.org &>/dev/null \
+ && ip n show 192.168.0.26 | grep . &>/dev/null; then
+ at_work=true
+ fi
+ ;;
+ esac
+}
+
+exit-if-no-default-targets() {
+ if ! $force && [[ $HOSTNAME != "$MAIL_HOST" ]]; then
+ echo "MAIL_HOST=$MAIL_HOST, nothing to do"
+ mexit 0
+ fi
+ case $HOSTNAME in
+ kw|kd|frodo|x2|x3|sy|so) : ;;
+ *)
+ die "error: no default targets for this host, use -t"
+ ;;
+ esac
+}
+
+add-x3-target() {
+ # main work machine
+ if ping -q -c1 -w1 x3.office.fsf.org &>/dev/null; then
+ targets+=(x3.office.fsf.org)
+ elif ping -q -c1 -w1 x3.b8.nz &>/dev/null; then
+ # in case we took it home
+ targets+=(x3.b8.nz)
+ elif ping -q -c1 -w1 x3w.b8.nz &>/dev/null; then
+ targets+=(x3w.b8.nz)
+ else
+ targets+=(x3wg.b8.nz)
+ fi
+}
+
+add-wireless-target() {
+ local host
+ if [[ ! $1 ]]; then
+ set -- $h
+ fi
+ for host; do
+ # c = cabled, w = wireless
+ if ping -q -c1 -w1 ${host}c.b8.nz &>/dev/null; then
+ targets+=(${host}c.b8.nz)
+ elif ping -q -c1 -w1 $host.b8.nz &>/dev/null; then
+ targets+=($host.b8.nz)
+ elif ping -q -c1 -w1 ${host}w.b8.nz &>/dev/null; then
+ targets+=(${host}w.b8.nz)
+ fi
+ done
+}
+
+qconf() {
+ case $sub in
+ q)
+ # q has sensitive data i dont want to backup for so long
+ cat >>/etc/btrbk$conf_suf.conf <<EOF
+snapshot_preserve $q_preserve
+snapshot_preserve_min 2h
+snapshot_dir btrbk
+target_preserve $q_preserve
+target_preserve_min 2h
+EOF
+ ;;
+ esac
+
+}
+
+