beautified scripts

This commit is contained in:
Axel Kittenberger 2010-08-03 15:03:42 +00:00
parent cf47587b9b
commit 3e8050172f
3 changed files with 41 additions and 34 deletions

View File

@ -1,13 +1,15 @@
#!/bin/bash
# test the case of directory being cp -r'ed and touched. lsyncd 1.0 doesn't handle this case well.
set -e
CON="\E[47;34m"
COFF="\033[0m"
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"
WORKSOURCE=$(mktemp -d)
WORKSOURCE="/tmp/src"
WORKTARGET="/tmp/trg"
WORKTARGET=$(mktemp -d)
PIDFILE=$(mktemp)
LOGFILE=$(mktemp)
@ -22,7 +24,7 @@ echo -e "$CON* waiting for lsyncd to start$COFF"
sleep 4s
# cp -r the directory
echo -e "$CON* make a lot of data$OFF"
echo -e "$CON* making a lot of data$COFF"
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
@ -35,7 +37,7 @@ for A in 1 2 3 4 5 6 7 8 9 10; do
done
echo -e "$CON*waiting until lsyncd does the job.$COFF"
sleep 60s
sleep 20s
echo -e "$CON*killing lsyncd$COFF"
LSYNCPID=$(cat "${PIDFILE}")
@ -54,7 +56,7 @@ sleep 1s
echo -e "$CON*differences$COFF"
diff -urN "${WORKSOURCE}" "${WORKTARGET}"
#rm "${PIDFILE}"
#rm "${LOGFILE}"
#rm -rf "${WORKTARGET}"
#rm -rf "${WORKSOURCE}"
rm "${PIDFILE}"
rm "${LOGFILE}"
rm -rf "${WORKTARGET}"
rm -rf "${WORKSOURCE}"

View File

@ -1,7 +1,11 @@
#!/bin/bash
# test the case of directory being mv'ed and rm'ed. lsyncd 1.0 didn't handle this case well.
set -e
CON="\E[47;34m"
COFF="\033[0m"
echo -e "$CON************************************************************$COFF"
echo -e "$CON** Testing the case of directory being moved and removed. **$COFF"
echo -e "$CON************************************************************$COFF"
WORKSOURCE=$(mktemp -d)
WORKTARGET=$(mktemp -d)
@ -12,34 +16,33 @@ echo $WORKSOURCE
echo $WORKTARGET
echo $PIDFILE
# populate the filesystem.
echo -e "$CON* populating the filesystem.$COFF"
mkdir "${WORKSOURCE}"/a
mkdir "${WORKSOURCE}"/b
touch "${WORKSOURCE}"/a/f
touch "${WORKSOURCE}"/b/g
echo ./lsyncd --logfile "${LOGFILE}" --pidfile "${PIDFILE}" "${WORKSOURCE}" "${WORKTARGET}"
echo -e "$CON* starting lsyncd.$COFF"
./lsyncd --logfile "${LOGFILE}" --pidfile "${PIDFILE}" "${WORKSOURCE}" "${WORKTARGET}"
LSYNCPID=$(cat "${PIDFILE}")
# try to wait until lsyncd starts and rsyncs initial file, hope 2s is enough.
sleep 2s
echo -e "$CON* waiting for lsyncd to start.$COFF"
sleep 4s
# move a file
echo "moving a directory"
echo -e "$CON* moving a directory$COFF"
mv "${WORKSOURCE}"/a "${WORKSOURCE}"/c
echo "create a file there"
echo -e "$CON* creating a file there$COFF"
touch "${WORKSOURCE}"/c/h
echo "and delete a directory"
#lsyncd 1.0 dies here
echo -e "$CON* and deleting a directory$COFF"
rm -r "${WORKSOURCE}"/b
echo "wait for events to trigger"
# try to wait until lsyncd does the job.
echo -e "$CON* waiting for lsyncd to do the job.$COFF"
sleep 10s
echo "killing daemon"
echo -e "$CON* killing daemon$COFF"
if ! kill "${LSYNCPID}"; then
cat "${LOGFILE}"
diff -ur "${WORKSOURCE}" "${WORKTARGET}" || true
@ -48,14 +51,13 @@ if ! kill "${LSYNCPID}"; then
fi
sleep 1s
echo "log file contents"
echo -e "$CON* log file contents$COFF"
cat "${LOGFILE}"
#this should be grep.
echo -e "$CON* differences$COFF"
diff -ur "${WORKSOURCE}" "${WORKTARGET}"
#rm "${PIDFILE}"
#rm "${LOGFILE}"
#rm -rf "${WORKTARGET}"
#rm -rf "${WORKSOURCE}"
rm "${PIDFILE}"
rm "${LOGFILE}"
rm -rf "${WORKTARGET}"
rm -rf "${WORKSOURCE}"

View File

@ -1,11 +1,14 @@
#!/bin/bash
# copyright 2008 Junichi Uekawa <dancer@debian.org>
# licensed under GPLv2 or later, see the file ../COPYING for details.
set -e
CON="\E[47;34m"
COFF="\033[0m"
# test that --help outputs help message and exit code of 0
set -e
echo -e "$CON*****************************************************************$COFF"
echo -e "$CON* Testing that --help outputs help message and exit code of 0. **$COFF"
echo -e "$CON*****************************************************************$COFF"
set -o pipefail
# assume that USAGE being in output is good enough.
./lsyncd --help | grep '^USAGE:'
./lsyncd --help | grep '^USAGE:'