Package: webalizer Version: 2.23.08-1+b1 Severity: wishlist Tags: patch
The webalizer daily cron job can be easily modified to remove any generated "usage" files older than MAX_DAY_AGE in order to prevent perpetual growth without other intervention of the output directory. If MAX_DAY_AGE is not set or is set to 0, then no files are deleted. I also suggest using the linked variable name OUTPUT_DIR rather than OUTDIR to match the parameer name in the configuration file, and also to use sed with an exact match, rather than the heavier awk pattern matching, to extract the value from the configuration file. ------------------<snip><start of patch><snip>-------------------------------- --- webalizer.ORIG 2014-03-01 16:47:08.000000000 +0100 +++ webalizer 2014-03-01 16:47:08.000000000 +0100 @@ -9,6 +9,8 @@ WEBALIZER=/usr/bin/webalizer WEBALIZER_CONFDIR=/etc/webalizer +MAX_DAY_AGE=32 + [ -x ${WEBALIZER} ] || exit 0; [ -d ${WEBALIZER_CONFDIR} ] || exit 0; @@ -25,13 +27,15 @@ [ -r "${LOGFILE}" ] || continue; # there was a output ? - OUTDIR=`awk '$1 ~ /^OutputDir$/ {print $2}' $i`; + + OUTPUT_DIR=$(sed -ne 's|OutputDir[[:space:]]*||p' "${i}") + # exists something ? - [ "${OUTDIR}" != "" ] || continue; + [ "${OUTPUT_DIR}" != "" ] || continue; # its a directory ? - [ -d ${OUTDIR} ] || continue; + [ -d ${OUTPUT_DIR} ] || continue; # its writable ? - [ -w ${OUTDIR} ] || continue; + [ -w ${OUTPUT_DIR} ] || continue; # Run Really quietly, exit with status code if !0 ${WEBALIZER} -c ${i} -Q || continue; @@ -50,6 +54,14 @@ ${WEBALIZER} -c ${i} -Q ${NLOGFILE}; RET=$?; fi; + + if [ -n "${MAX_DAY_AGE}" ] + then + test ${MAX_DAY_AGE} -gt 0 && \ + find "${OUTPUT_DIR}" -maxdepth 1 -type f -mtime +${MAX_DAY_AGE} \ + -name \*usage_\* -exec rm -f {} \; + fi + done; # exit with webalizer's exit code ---------------------------<snip><End of patch><snip>---------------------