-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcheck_csync2_by_ssh
More file actions
executable file
·37 lines (29 loc) · 901 Bytes
/
check_csync2_by_ssh
File metadata and controls
executable file
·37 lines (29 loc) · 901 Bytes
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
#!/bin/sh
HOSTNAME=$1
if [ -z $HOSTNAME ]; then
echo "No hostname given";
exit -1
fi
TMP_FILE=/tmp/chk_csync2.$$.$HOSTNAME.dat
rm -f ${TMP_FILE}
ssh -oConnectTimeout=3 -oNumberOfPasswordPrompts=0 -oPasswordAuthentication=no -oStrictHostKeyChecking=no root@"$HOSTNAME" which csync2 >/dev/null 2>&1
if [ ! $? -eq 0 ]; then
echo "OK: No csync2 installed | changes=0"
exit 0
fi
ssh -oConnectTimeout=3 -oNumberOfPasswordPrompts=0 -oPasswordAuthentication=no -oStrictHostKeyChecking=no root@"$HOSTNAME" csync2 -xvd > ${TMP_FILE} 2> /dev/null
exitcode=$?
if [ $exitcode == 255 ]; then
echo "SSH exited with non zero exit code: $op";
rm -f ${TMP_FILE}
exit 1
fi
if [ -s ${TMP_FILE} ] ; then
echo -e "WARNING: Changes found:\n`cat $TMP_FILE` | changes=`cat $TMP_FILE|wc -l`"
rm -f ${TMP_FILE}
exit 1
else
echo "OK: No changes found | changes=0"
rm -f ${TMP_FILE}
exit 0
fi