2008-11-05 11:37:35 +00:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
2010-08-03 14:24:46 +00:00
|
|
|
CON="\E[47;34m"
|
|
|
|
COFF="\033[0m"
|
2008-11-05 11:37:35 +00:00
|
|
|
|
2010-08-03 15:03:42 +00:00
|
|
|
echo -e "$CON***************************************************************$COFF"
|
|
|
|
echo -e "$CON** Testing the case of directory being cp -r'ed and touched. **$COFF"
|
|
|
|
echo -e "$CON** With default delay **$COFF"
|
|
|
|
echo -e "$CON***************************************************************$COFF"
|
|
|
|
|
2008-11-05 11:37:35 +00:00
|
|
|
WORKSOURCE=$(mktemp -d)
|
2010-08-03 15:03:42 +00:00
|
|
|
WORKTARGET=$(mktemp -d)
|
2008-11-05 11:37:35 +00:00
|
|
|
PIDFILE=$(mktemp)
|
|
|
|
LOGFILE=$(mktemp)
|
|
|
|
|
2010-08-03 14:24:46 +00:00
|
|
|
echo -e "$CON* populating the filesystem$COFF"
|
2008-11-05 11:37:35 +00:00
|
|
|
mkdir -p "${WORKSOURCE}"/a/a
|
|
|
|
echo 'test' > "${WORKSOURCE}"/a/a/file
|
|
|
|
|
2010-08-03 14:24:46 +00:00
|
|
|
echo -e "$CON* starting lsyncd$COFF"
|
|
|
|
./lsyncd --logfile "${LOGFILE}" --pidfile "${PIDFILE}" --no-daemon "${WORKSOURCE}" "${WORKTARGET}"&
|
2008-11-05 11:37:35 +00:00
|
|
|
|
2010-08-03 14:24:46 +00:00
|
|
|
echo -e "$CON* waiting for lsyncd to start$COFF"
|
2008-11-20 21:38:58 +00:00
|
|
|
sleep 4s
|
2008-11-05 11:37:35 +00:00
|
|
|
|
2010-08-03 14:24:46 +00:00
|
|
|
# cp -r the directory
|
2010-08-03 15:03:42 +00:00
|
|
|
echo -e "$CON* making a lot of data$COFF"
|
2008-11-05 11:37:35 +00:00
|
|
|
for A in 1 2 3 4 5 6 7 8 9 10; do
|
|
|
|
cp -r "${WORKSOURCE}"/a "${WORKSOURCE}"/b${A}
|
|
|
|
echo 'test2' > "${WORKSOURCE}"/b${A}/a/another
|
|
|
|
done
|
|
|
|
mkdir -p "${WORKSOURCE}"/c/a
|
|
|
|
echo 'test3' > "${WORKSOURCE}"/c/a/file
|
|
|
|
for A in 1 2 3 4 5 6 7 8 9 10; do
|
|
|
|
cp -r "${WORKSOURCE}"/c "${WORKSOURCE}"/d${A}
|
|
|
|
echo 'test2' > "${WORKSOURCE}"/d${A}/a/another
|
|
|
|
done
|
|
|
|
|
2010-08-03 14:24:46 +00:00
|
|
|
echo -e "$CON*waiting until lsyncd does the job.$COFF"
|
2010-08-03 15:03:42 +00:00
|
|
|
sleep 20s
|
2008-11-05 11:37:35 +00:00
|
|
|
|
2010-08-03 14:49:53 +00:00
|
|
|
echo -e "$CON*killing lsyncd$COFF"
|
2008-11-05 11:37:35 +00:00
|
|
|
LSYNCPID=$(cat "${PIDFILE}")
|
|
|
|
if ! kill "${LSYNCPID}"; then
|
|
|
|
cat "${LOGFILE}"
|
|
|
|
diff -urN "${WORKSOURCE}" "${WORKTARGET}" || true
|
|
|
|
echo "kill failed"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
sleep 1s
|
|
|
|
|
2010-08-03 14:24:46 +00:00
|
|
|
#echo "log file contents"
|
|
|
|
#cat "${LOGFILE}"
|
|
|
|
##this should be grep.
|
2008-11-05 11:37:35 +00:00
|
|
|
|
2010-08-03 14:24:46 +00:00
|
|
|
echo -e "$CON*differences$COFF"
|
2008-11-05 11:37:35 +00:00
|
|
|
diff -urN "${WORKSOURCE}" "${WORKTARGET}"
|
|
|
|
|
2010-08-03 15:03:42 +00:00
|
|
|
rm "${PIDFILE}"
|
|
|
|
rm "${LOGFILE}"
|
|
|
|
rm -rf "${WORKTARGET}"
|
|
|
|
rm -rf "${WORKSOURCE}"
|