mirror of
https://github.com/octoleo/lsyncd.git
synced 2025-01-07 17:14:03 +00:00
beautified script output
This commit is contained in:
parent
3f31d9596e
commit
55b966b43b
@ -2,41 +2,46 @@
|
|||||||
# test the case of directory being cp -r'ed and touched. lsyncd 1.0 doesn't handle this case well.
|
# test the case of directory being cp -r'ed and touched. lsyncd 1.0 doesn't handle this case well.
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
CON="\E[47;34m"
|
||||||
|
COFF="\033[0m"
|
||||||
|
|
||||||
WORKSOURCE=$(mktemp -d)
|
WORKSOURCE=$(mktemp -d)
|
||||||
WORKTARGET=$(mktemp -d)
|
WORKTARGET=$(mktemp -d)
|
||||||
PIDFILE=$(mktemp)
|
PIDFILE=$(mktemp)
|
||||||
LOGFILE=$(mktemp)
|
LOGFILE=$(mktemp)
|
||||||
|
|
||||||
# populate the filesystem.
|
|
||||||
|
|
||||||
|
echo -e "$CON* populating the filesystem$COFF"
|
||||||
mkdir -p "${WORKSOURCE}"/a/a
|
mkdir -p "${WORKSOURCE}"/a/a
|
||||||
echo 'test' > "${WORKSOURCE}"/a/a/file
|
echo 'test' > "${WORKSOURCE}"/a/a/file
|
||||||
|
|
||||||
./lsyncd --logfile "${LOGFILE}" --pidfile "${PIDFILE}" "${WORKSOURCE}" "${WORKTARGET}"
|
echo -e "$CON* starting lsyncd$COFF"
|
||||||
|
./lsyncd --logfile "${LOGFILE}" --pidfile "${PIDFILE}" --no-daemon "${WORKSOURCE}" "${WORKTARGET}"&
|
||||||
|
|
||||||
# try to wait until lsyncd starts and rsyncs initial file, hope 4s is enough.
|
echo -e "$CON* waiting for lsyncd to start$COFF"
|
||||||
sleep 4s
|
sleep 4s
|
||||||
|
|
||||||
# cp -r the directory, this sometimes succeeds, sometimes fails.
|
# cp -r the directory
|
||||||
|
echo -e "$CON* make a lot of copies$OFF"
|
||||||
for A in 1 2 3 4 5 6 7 8 9 10; do
|
for A in 1 2 3 4 5 6 7 8 9 10; do
|
||||||
cp -r "${WORKSOURCE}"/a "${WORKSOURCE}"/b${A}
|
cp -r "${WORKSOURCE}"/a "${WORKSOURCE}"/b${A}
|
||||||
echo 'test2' > "${WORKSOURCE}"/b${A}/a/another
|
echo 'test2' > "${WORKSOURCE}"/b${A}/a/another
|
||||||
done
|
done
|
||||||
|
|
||||||
# mkdir path while lsyncd is running
|
echo -e "$CON* mkdir double path$OFF"
|
||||||
mkdir -p "${WORKSOURCE}"/c/a
|
mkdir -p "${WORKSOURCE}"/c/a
|
||||||
echo 'test3' > "${WORKSOURCE}"/c/a/file
|
echo 'test3' > "${WORKSOURCE}"/c/a/file
|
||||||
|
echo -e "$CON* copy the other dir a few times$COFF"
|
||||||
# cp the dir while lsyncd is running.
|
|
||||||
# it's a race condition, do it 10 times.
|
|
||||||
for A in 1 2 3 4 5 6 7 8 9 10; do
|
for A in 1 2 3 4 5 6 7 8 9 10; do
|
||||||
cp -r "${WORKSOURCE}"/c "${WORKSOURCE}"/d${A}
|
cp -r "${WORKSOURCE}"/c "${WORKSOURCE}"/d${A}
|
||||||
echo 'test2' > "${WORKSOURCE}"/d${A}/a/another
|
echo 'test2' > "${WORKSOURCE}"/d${A}/a/another
|
||||||
done
|
done
|
||||||
|
|
||||||
# try to wait until lsyncd does the job.
|
echo -e "$CON*waiting until lsyncd does the job.$COFF"
|
||||||
sleep 10s
|
sleep 15s
|
||||||
|
|
||||||
|
echo -e "$CON*killing lsyncd"
|
||||||
LSYNCPID=$(cat "${PIDFILE}")
|
LSYNCPID=$(cat "${PIDFILE}")
|
||||||
if ! kill "${LSYNCPID}"; then
|
if ! kill "${LSYNCPID}"; then
|
||||||
cat "${LOGFILE}"
|
cat "${LOGFILE}"
|
||||||
@ -46,14 +51,14 @@ if ! kill "${LSYNCPID}"; then
|
|||||||
fi
|
fi
|
||||||
sleep 1s
|
sleep 1s
|
||||||
|
|
||||||
|
#echo "log file contents"
|
||||||
|
#cat "${LOGFILE}"
|
||||||
|
##this should be grep.
|
||||||
|
|
||||||
echo "log file contents"
|
echo -e "$CON*differences$COFF"
|
||||||
cat "${LOGFILE}"
|
|
||||||
#this should be grep.
|
|
||||||
|
|
||||||
diff -urN "${WORKSOURCE}" "${WORKTARGET}"
|
diff -urN "${WORKSOURCE}" "${WORKTARGET}"
|
||||||
|
|
||||||
rm "${PIDFILE}"
|
#rm "${PIDFILE}"
|
||||||
rm "${LOGFILE}"
|
#rm "${LOGFILE}"
|
||||||
rm -rf "${WORKTARGET}"
|
#rm -rf "${WORKTARGET}"
|
||||||
rm -rf "${WORKSOURCE}"
|
#rm -rf "${WORKSOURCE}"
|
||||||
|
Loading…
Reference in New Issue
Block a user