Ok, short one today. This is a straightforward script that simplifies comparing directories on different servers. There is no magic in it, it just rsyncs the directories to a local temp directory and runs diff against them (then deletes the directory afterwards). Mainly intended for config files, I wouldn’t recommend trying to diff gigabytes of binaries with it.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#!/bin/bash
set -o nounset
if [[ -z ${1:-} || -z ${2:-} || -z ${3:-} ]] ; then
echo "Usage: ${0##*/} <file|directory> <server1> <server2>"
echo
echo "e.g. ./${0##*/} '/etc/pam.d/' 10.0.0.1 10.0.0.2"
echo
exit 0
fi
Dir="${1}"
IP1="${2}"
IP2="${3}"
tmpdir=$(mktemp -d)
trap 'rm -rf "${tmpdir}"' INT TERM EXIT
for ip in ${IP1} ${IP2}
do
rsync -az "${ip}:${Dir}" "${tmpdir}/${ip}"
done
diff -BZEburN "${tmpdir}/${IP1}" "${tmpdir}/${IP2}" | colordiff --difftype=diffu
|