#!/bin/bash
. /etc/disco/client.cfg
SCRIPTROOT=$(dirname $(readlink -f $0))
if [ "$NOOP" != "" ]; then
DISCOROOT=/var/disco/testfs/noop
else
DISCOROOT=/var/disco/testfs/real
fi
cd $DISCOROOT
CREATED=0
DELETED=0
MODIFIED=0
rsync --checksum --times --perms --owner --group -ani ./scratchfs/ ./rootfs/ --out-format "info: File: %i : %f : mode='%B', size='%l', mtime='%M'" |\
sed -e s/"scratchfs"/""/ \
-e s/"\.unionfs\/"/""/ \
-e s/"info: File: .* : \(\/.*\)_HIDDEN~ : mode="/"info: File: *_deleted__ : \1 : mode="/|\
while read LINE
do
FNAME=$(echo $LINE | cut -d : -f 4 | sed s/"^ *"/""/ | sed s/" *$"/""/)
MD5_NEW=$(md5sum ${DISCOROOT}/scratchfs${FNAME} 2>/dev/null| cut -d " " -f 1)
STAT_NEW=$(stat --format "owner='%G:%U', selinux='%C', md5='${MD5_NEW}'" ${DISCOROOT}/scratchfs/${FNAME} 2>/dev/null)
if [ ! -d ${FNAME} ] && [ ! -d ${DISCOROOT}/scratchfs${FNAME} ]; then
diff -N ${FNAME} ${DISCOROOT}/scratchfs${FNAME} 2>/dev/null > /tmp/$$.diff
echo "${LINE}, ${STAT_NEW}"
if [ -f /tmp/$$.diff ]; then
cat /tmp/$$.diff
rm -f /tmp/$$* 2>/dev/null
done
rm -f /tmp/$$*