-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsshdiff
More file actions
executable file
·48 lines (45 loc) · 1.45 KB
/
Copy pathsshdiff
File metadata and controls
executable file
·48 lines (45 loc) · 1.45 KB
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
#!/bin/bash
DIFFTOOL="meld";
if [ "$(which ${DIFFTOOL})" == "" ]; then
DIFFTOOL="vimdiff";
fi
function Usage {
scriptname=$(basename "$0");
echo "${scriptname}: USAGE:";
echo "${scriptname} SSHORIGIN SSHDEST FILEPATH";
}
if [ "$3" == "" ]; then
Usage;
else
srcHost="$1";
dstHost="$2";
filePath="$3";
fileName="$(basename "${filePath}")";
scp ${srcHost}:${filePath} /tmp/${srcHost}.${fileName};
scp ${dstHost}:${filePath} /tmp/${dstHost}.${fileName};
cp /tmp/${srcHost}.${fileName} /tmp/orig.${srcHost}.${fileName};
cp /tmp/${dstHost}.${fileName} /tmp/orig.${dstHost}.${fileName};
${DIFFTOOL} /tmp/${srcHost}.${fileName} /tmp/${dstHost}.${fileName};
if [ "$(diff /tmp/orig.${srcHost}.${fileName} /tmp/${srcHost}.${fileName})" != "" ]; then
while true; do
read -p "Source file has been modified: reupload in ${srcHost}:${filePath} (y/n)? " yn
case $yn in
[Yy]* ) scp /tmp/${srcHost}.${fileName} ${srcHost}:${filePath}; break;;
[Nn]* ) break;;
esac
done
fi
if [ "$(diff /tmp/orig.${dstHost}.${fileName} /tmp/${dstHost}.${fileName})" != "" ]; then
while true; do
read -p "Destination file has been modified: reupload in ${dstHost}:${filePath} (y/n)? " yn
case $yn in
[Yy]* ) scp /tmp/${dstHost}.${fileName} ${dstHost}:${filePath}; break;;
[Nn]* ) break;;
esac
done
fi
rm -f /tmp/${srcHost}.${fileName};
rm -f /tmp/orig.${srcHost}.${fileName};
rm -f /tmp/${dstHost}.${fileName};
rm -f /tmp/orig.${dstHost}.${fileName};
fi