forked from hnj2/gesichtserkennung-stoppen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
diff.sh
executable file
·51 lines (42 loc) · 1.1 KB
/
diff.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#/bin/bash
rsync=$(rsync --dry-run --delete -rvc html/ df@df.uber.space:html)
#echo "## rsync dry run:"
#echo "$rsync"
#echo
files=$(echo "$rsync" | head --lines=-3 | tail --lines=+2)
onlyhost=$(echo "$files" | grep -E "^deleting .+" | sed "s/deleting \(\)/\1/")
get_diff_files() {
ssh df@df.uber.space "
for file in $@; do
if test -e html/\$file; then
echo \$file
fi
done
"
}
updatefiles=$(echo "$files" | grep -vE "^deleting .+")
differ=$(get_diff_files $updatefiles)
onlylocal=${updatefiles/$differ}
printdiff() {
if ! test -z "$onlylocal"; then
echo "## files only local:"
echo "$onlylocal"
echo
fi
if ! test -z "$onlyhost"; then
echo "## files only on host:"
echo "$onlyhost"
echo
fi
if ! test -z "$differ"; then
echo "## files that differ:"
echo "$differ"
echo
for file in $differ; do
echo "## diff [local]/$file [host]/$file"
diff html/$file <(ssh df@df.uber.space "cat html/$file")
echo
done
fi
}
printdiff | less