various fixes, add emacs wrappers
[distro-setup] / btrbk-run
index 485c7f579a2d5b54a0ee8c438315eb5c65094d94..961208e739bb359500f62c897d9152647bd08195 100755 (executable)
--- a/btrbk-run
+++ b/btrbk-run
@@ -32,15 +32,16 @@ conf_only=false
 dry_run=false # mostly for testing
 resume_arg=
 
-temp=$(getopt -l help hcnrt: "$@") || usage 1
+temp=$(getopt -l help hcnprt: "$@") || usage 1
 eval set -- "$temp"
 while true; do
     case $1 in
         -c) conf_only=true; shift ;;
         -n) dry_run=true; dry_run_arg=-n; shift ;;
+        -p) progress_arg="--progress"; shift ;;
         # btrbk arg: Resume only. Skips snapshot creation.
         -r) resume_arg=-r; shift ;;
-        -t) IFS=, targets=($2); shift 2 ;;
+        -t) IFS=, targets=($2); unset IFS; shift 2 ;;
         -h|--help) usage ;;
         --) shift; break ;;
         *) echo "$0: Internal error!" ; exit 1 ;;
@@ -71,17 +72,13 @@ tg-conf() {
 target send-receive ssh://$tg$vol/btrbk
 EOF
 }
-m() { printf "%s\n" "$*";  "$@"; }
+m() { printf "%s: %s\n" "${0##*/}" "$*";  "$@"; }
 
 
 if ! which btrbk &>/dev/null; then
     echo "$0: error: no btrbk binary found"
 fi
 
-if [[ $- == *i* ]]; then
-    progress_arg=--progress
-fi
-
 cat >/etc/btrbk.conf <<'EOF'
 ssh_identity /root/.ssh/id_rsa
 # Just a guess that local7 is a good facility to pick.
@@ -135,8 +132,17 @@ if [[ ! $targets ]]; then
                 targets=($HOME_DOMAIN)
             fi
             ;;
+        treetowl)
+            targets=(frodo)
+            if timeout -s 9 10 ssh x2 :; then
+                targets+=(x2)
+            fi
+            ;;
+        *)
+            targets=(frodo)
+            ;;
     esac
-    targets=(frodo)
+    echo "targets: ${targets[*]}"
 fi