-#!/bin/bash -l
+#!/bin/bash -lx
set -eE -o pipefail
trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
gen_args=()
do_snapshot=true
-while [[ $1 == -* ]]; do
+while [[ $1 ]]; do
case $1 in
-n) do_snapshot=false; shift ;;
--) shift; break ;;
-*) gen_args+=($1) ; shift ;;
+ *) host=$1; shift ;;
esac
done
# todo: I should test pushing my unison version instead
# of pulling it.
/p/c/subdir_files/.unison/gen ${gen_args[@]}
-if [[ ! $1 ]]; then
+if [[ ! $host ]]; then
echo "$0: error: expected argument for hostname"
exit 1
fi
-host=$1
# todo: this doesn't deal with if the host is running arch too
# on an uncustomized jessie install.
scp /usr/bin/unison root@$host:/usr/local/bin
+echo "$0: egen args ${gen_args[@]}"
if $do_snapshot; then
unison-snapshot
- ssh root@$host unison-snapshot
+ if ! ssh root@$host unison-snapshot; then
+ if [[ ! ${gen_args[@]} ]]; then
+ # gen_args are all about syncing with new systems where
+ # we could expect the remote snapshot to not be available yet.
+ echo "$0: error: failed remote unison-snapshot"
+ exit 1
+ fi
+ fi
fi
f=unison-gtk
type -t $f &>/dev/null || f=unison-gtk2 # for arch
-if s $f "$@"; then
+if s $f "$host"; then
if [[ $host == frodo ]]; then
# only send data to the machine i do full backups to
p=/p/c/machine_specific/$HOSTNAME/.unison/