From b08b53aabd895afb16954abef36c4da7e4e24258 Mon Sep 17 00:00:00 2001 From: Ian Kelling Date: Thu, 5 May 2016 21:12:14 -0700 Subject: [PATCH] better option for new system --- myunison | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/myunison b/myunison index fa79b4a..68ec7d4 100755 --- a/myunison +++ b/myunison @@ -1,15 +1,16 @@ -#!/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 @@ -24,12 +25,11 @@ 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 @@ -37,14 +37,22 @@ host=$1 # 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/ -- 2.30.2