2022-01-20 19:05:27 +05:30
|
|
|
#!/bin/sh
|
2022-05-21 19:13:12 +05:30
|
|
|
# shellcheck disable=SC1090
|
2022-01-20 19:05:27 +05:30
|
|
|
set -x
|
|
|
|
|
|
|
|
if [ x"${srcdir}" = x ]; then
|
|
|
|
srcdir=.
|
|
|
|
fi
|
|
|
|
. ${srcdir}/lib.sh
|
|
|
|
|
2022-03-12 22:16:47 +05:30
|
|
|
[ -x ../src/logger ] || SKIP 'logger missing'
|
|
|
|
command -v zgrep >/dev/null 2>&1 || SKIP 'zgrep(1) missing'
|
|
|
|
|
2022-01-20 19:05:27 +05:30
|
|
|
NOT1=${DIR}/${NM}-1.sh
|
|
|
|
NOT1STAMP=${DIR}/${NM}-1.stamp
|
|
|
|
NOT2=${DIR}/${NM}-2.sh
|
|
|
|
NOT2STAMP=${DIR}/${NM}-2.stamp
|
|
|
|
|
2022-03-12 22:16:47 +05:30
|
|
|
printf '#!/bin/sh -\necho script 1: $* >> '${NOT1STAMP}'\n' > ${NOT1}
|
2022-01-20 19:05:27 +05:30
|
|
|
chmod 0755 ${NOT1}
|
|
|
|
|
2022-03-12 22:16:47 +05:30
|
|
|
cat <<EOF > ${CONFD}/rotate_all.conf
|
2022-01-20 19:05:27 +05:30
|
|
|
notify ${NOT1}
|
|
|
|
*.* -${LOG} ;rotate=10k:2,RFC5424
|
|
|
|
*.* -${LOG}X ;rotate=10k:2,RFC5424
|
|
|
|
EOF
|
|
|
|
|
2022-03-12 22:16:47 +05:30
|
|
|
setup
|
2022-01-20 19:05:27 +05:30
|
|
|
|
2022-03-12 22:16:47 +05:30
|
|
|
rm -f ${NOT1STAMP}
|
2022-05-21 19:13:12 +05:30
|
|
|
logger notrotall-1
|
2022-01-20 19:05:27 +05:30
|
|
|
|
2022-03-12 22:16:47 +05:30
|
|
|
kill -USR2 `cat ${PID}`
|
|
|
|
sleep 3
|
2022-01-20 19:05:27 +05:30
|
|
|
if [ -f ${LOG}.0 ] && [ -f ${LOG}X.0 ] &&
|
|
|
|
grep notrotall-1 ${LOG}.0 &&
|
|
|
|
grep notrotall-1 ${LOG}X.0; then
|
|
|
|
:
|
|
|
|
else
|
2022-03-12 22:16:47 +05:30
|
|
|
FAIL 'Missing log entries, I.'
|
|
|
|
fi
|
|
|
|
if [ -f ${NOT1STAMP} ] && grep 'script 1' ${NOT1STAMP} &&
|
|
|
|
grep ${LOG} ${NOT1STAMP} && grep ${LOG}X ${NOT1STAMP}; then
|
|
|
|
:
|
|
|
|
else
|
|
|
|
FAIL 'Notifier did not run, I.'
|
2022-01-20 19:05:27 +05:30
|
|
|
fi
|
|
|
|
|
|
|
|
rm -f ${NOT1STAMP}
|
2022-05-21 19:13:12 +05:30
|
|
|
logger notrotall-2
|
2022-03-12 22:16:47 +05:30
|
|
|
|
|
|
|
kill -USR2 `cat ${PID}`
|
|
|
|
sleep 3
|
2022-01-20 19:05:27 +05:30
|
|
|
if [ -f ${LOG}.0 ] && [ -f ${LOG}X.0 ] &&
|
|
|
|
[ -f ${LOG}.1.gz ] && [ -f ${LOG}X.1.gz ] &&
|
|
|
|
grep notrotall-2 ${LOG}.0 &&
|
|
|
|
grep notrotall-2 ${LOG}X.0 &&
|
|
|
|
zgrep notrotall-1 ${LOG}.1.gz &&
|
|
|
|
zgrep notrotall-1 ${LOG}X.1.gz; then
|
|
|
|
:
|
|
|
|
else
|
2022-03-12 22:16:47 +05:30
|
|
|
FAIL 'Missing log entries, II.'
|
|
|
|
fi
|
|
|
|
if [ -f ${NOT1STAMP} ] && grep 'script 1' ${NOT1STAMP} &&
|
|
|
|
grep ${LOG} ${NOT1STAMP} && grep ${LOG}X ${NOT1STAMP}; then
|
|
|
|
:
|
|
|
|
else
|
|
|
|
FAIL 'Notifier did not run, II.'
|
2022-01-20 19:05:27 +05:30
|
|
|
fi
|
|
|
|
|
2022-03-12 22:16:47 +05:30
|
|
|
cp $NOT1STAMP /tmp/
|
2022-01-20 19:05:27 +05:30
|
|
|
rm -f ${NOT1STAMP}
|
2022-05-21 19:13:12 +05:30
|
|
|
logger notrotall-3
|
2022-03-12 22:16:47 +05:30
|
|
|
|
|
|
|
kill -USR2 `cat ${PID}`
|
|
|
|
sleep 3
|
2022-01-20 19:05:27 +05:30
|
|
|
if [ -f ${LOG}.0 ] && [ -f ${LOG}X.0 ] &&
|
|
|
|
[ -f ${LOG}.1.gz ] && [ -f ${LOG}X.1.gz ] &&
|
|
|
|
[ -f ${LOG}.2.gz ] && [ -f ${LOG}X.2.gz ] &&
|
|
|
|
grep notrotall-3 ${LOG}.0 &&
|
|
|
|
grep notrotall-3 ${LOG}X.0 &&
|
|
|
|
zgrep notrotall-2 ${LOG}.1.gz &&
|
|
|
|
zgrep notrotall-2 ${LOG}X.1.gz &&
|
|
|
|
zgrep notrotall-1 ${LOG}.2.gz &&
|
|
|
|
zgrep notrotall-1 ${LOG}X.2.gz; then
|
|
|
|
:
|
|
|
|
else
|
2022-03-12 22:16:47 +05:30
|
|
|
FAIL 'Missing log entries, III.'
|
2022-01-20 19:05:27 +05:30
|
|
|
fi
|
2022-03-12 22:16:47 +05:30
|
|
|
if [ -f ${NOT1STAMP} ] && grep 'script 1' ${NOT1STAMP} &&
|
|
|
|
grep ${LOG} ${NOT1STAMP} && grep ${LOG}X ${NOT1STAMP}; then
|
2022-01-20 19:05:27 +05:30
|
|
|
:
|
|
|
|
else
|
2022-03-12 22:16:47 +05:30
|
|
|
FAIL 'Notifier did not run, III.'
|
2022-01-20 19:05:27 +05:30
|
|
|
fi
|
2022-03-12 22:16:47 +05:30
|
|
|
|
|
|
|
OK
|