mostly working
[distro-setup] / myunison
1 #!/bin/bash -l
2
3 set -eE -o pipefail
4 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
5
6 gen_args=()
7 do_snapshot=true
8 while [[ $1 == -* ]]; do
9 case $1 in
10 -n) do_snapshot=false; shift ;;
11 --) shift; break ;;
12 -*) gen_args+=($1) ; shift ;;
13 esac
14 done
15
16
17 # arch and debian don't play nice with unison.
18 # "connection lost" on unison-gtk, with bignum errs in term,
19 # and simply freezing on cli, all means compiled under
20 # different ocaml versions.
21 # I had the great realization that unison is a self contained
22 # binary with no special runtime dependencies.
23 # However, I got a gtk error running the ui version.
24 # todo: I should test pushing my unison version instead
25 # of pulling it.
26 /p/c/subdir_files/.unison/gen ${gen_args[@]}
27 if [[ ! $1 ]]; then
28 echo "$0: error: expected argument for hostname"
29 exit 1
30 fi
31
32 host=$1
33
34 # todo: this doesn't deal with if the host is running arch too
35
36 # note, without bash, it prints some crap about tty
37 # on an uncustomized jessie install.
38 scp /usr/bin/unison root@$host:/usr/local/bin
39
40 if $do_snapshot; then
41 unison-snapshot
42 ssh root@$host unison-snapshot
43 fi
44
45 f=unison-gtk
46 type -t $f &>/dev/null || f=unison-gtk2 # for arch
47 if s $f "$@"; then
48 if [[ $host == frodo ]]; then
49 # only send data to the machine i do full backups to
50 p=/p/c/machine_specific/$HOSTNAME/.unison/
51 s rsync -rlptgohi $p root@$host:$p
52 fi
53 p=/p/c/machine_specific/$host/.unison/
54 s rsync -rlptgohvi root@$host:$p $p
55 fi