-if [[ -s $default_args_file ]]; then
- echo "$0: warning: default btrbk-run options set in $default_args_file (sleeping 5 seconds):"
- cat $default_args_file
- sleep 5
+# usefull commands are resume and archive
+cmd_arg=${1:-run}
+
+if [[ -v targets && $source ]]; then
+ echo "$0: error: -t and -s are mutually exclusive" >&2
+ exit 1
+fi
+
+# pull_reexec stops us from getting into an infinite loop if there is some
+# kind of weird problem
+if ! $pull_reexec && [[ $source ]]; then
+ tmpf=$(mktemp)
+ scp $source:/a/bin/distro-setup/btrbk-run $tmpf
+ if diff -q $tmpf $BASH_SOURCE; then
+ echo "$0: found newer version on host $source. reexecing"
+ install -T $tmpf /usr/local/bin/btrbk-run
+ /usr/local/bin/btrbk-run --pull-reexec "${orig_args[@]}"
+ fi