2008-11-05 11:37:35 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# test the case of directory being cp -r'ed and touched. lsyncd 1.0 doesn't handle this case well.
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
WORKSOURCE=$(mktemp -d)
|
2010-08-03 14:26:57 +00:00
|
|
|
WORKSOURCE="/tmp/src"
|
|
|
|
WORKTARGET="/tmp/trg"
|
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
|
|
|
|
echo -e "$CON* make a lot of copies$OFF"
|
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
|
|
|
|
|
2010-08-03 14:24:46 +00:00
|
|
|
echo -e "$CON* mkdir double path$OFF"
|
2008-11-05 11:37:35 +00:00
|
|
|
mkdir -p "${WORKSOURCE}"/c/a
|
|
|
|
echo 'test3' > "${WORKSOURCE}"/c/a/file
|
2010-08-03 14:24:46 +00:00
|
|
|
echo -e "$CON* copy the other dir a few times$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}"/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"
|
|
|
|
sleep 15s
|
2008-11-05 11:37:35 +00:00
|
|
|
|
2010-08-03 14:24:46 +00:00
|
|
|
echo -e "$CON*killing lsyncd"
|
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 14:24:46 +00:00
|
|
|
#rm "${PIDFILE}"
|
|
|
|
#rm "${LOGFILE}"
|
|
|
|
#rm -rf "${WORKTARGET}"
|
|
|
|
#rm -rf "${WORKSOURCE}"
|