Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- WEBSITE="${1}"
- [ "${#}" = 1 ] || { echo "Usage ${0} vhost (dir in /logging)"; exit 1; }
- echo -e "\
- LogFile /logging/${WEBSITE}/access.log.1
- LogType clf\n
- OutputDir /var/www/stats/${WEBSITE}\n
- HistoryName ${WEBSITE}.hist\n
- ReportTitle Usage statistics for
- HostName ${WEBSITE}
- HTMLExtension html\n
- PageType htm*
- PageType cgi
- PageType php3
- PageType php\n
- UseHTTPS no\n
- Quiet no
- ReallyQuiet no
- CountryGraph yes\n
- DailyGraph yes
- DailyStats yes
- HourlyGraph yes
- HourlyStats yes
- GraphLegend yes
- IgnoreSite localhost
- IgnoreReferrer localhost\n
- SearchEngine yahoo.com p=
- SearchEngine altavista.com q=
- SearchEngine google.com q=
- SearchEngine eureka.com q=
- SearchEngine lycos.com query=
- SearchEngine hotbot.com MT=
- SearchEngine msn.com MT=
- SearchEngine infoseek.com qt=
- SearchEngine webcrawler searchText=
- SearchEngine excite search=
- SearchEngine netscape.com search=
- SearchEngine mamma.com query=
- SearchEngine alltheweb.com query=
- SearchEngine northernlight.com qr=
- SearchEngine sensis.com.au find=
- SearchEngine google.nl q=
- SearchEngine google.fr q=
- SearchEngine google.ch q=
- SearchEngine google.ca q=
- SearchEngine google.be q=\n
- " > /etc/webalizer/${WEBSITE}-webalizer.conf
- echo -e "\
- #!/bin/sh
- WEBALIZER=/usr/bin/webalizer
- WEBALIZER_CONFDIR=/etc/webalizer
- [ -x \${WEBALIZER} ] || exit 0;
- [ -d \${WEBALIZER_CONFDIR} ] || exit 0;
- for i in \${WEBALIZER_CONFDIR}/${WEBSITE}-webalizer.conf
- do
- # run agains a rotated or normal logfile
- LOGFILE=\`awk '\$1 ~ /^LogFile$/ {print \$2}' \$i\`;
- # empty ?
- [ -s \"\${LOGFILE}\" ] || continue;
- # readable ?
- [ -r \"\${LOGFILE}\" ] || continue;
- # there was a output ?
- OUTDIR=\`awk '\$1 ~ /^OutputDir$/ {print \$2}' \$i\`;
- # exists something ?
- [ \"\${OUTDIR}\" != \"\" ] || continue;
- # its a directory ?
- [ -d \${OUTDIR} ] || continue;
- # its writable ?
- [ -w \${OUTDIR} ] || continue;
- # Run Really quietly, exit with status code if !0
- \${WEBALIZER} -c \${i} -Q || continue;
- RET=\$?;
- # Non rotated log file
- NLOGFILE=\`awk '\$1 ~ /^LogFile$/ {gsub(/\.[0-9]+(\.gz)?/,\"\"); print \$2}' \$i\`;
- # check current log, if last log is a rotated logfile
- if [ \"\${LOGFILE}\" != \"\${NLOGFILE}\" ]; then
- # empty ?
- [ -s \"\${NLOGFILE}\" ] || continue;
- # readable ?
- [ -r \"\${NLOGFILE}\" ] || continue;
- \${WEBALIZER} -c \${i} -Q \${NLOGFILE};
- RET=\$?;
- fi;
- done;
- # exit with webalizer's exit code
- exit \$RET;
- " > /etc/webalizer/${WEBSITE}-webalizer-cron.sh
- echo "Config is generated and stored in /etc/webalizer/, please move the ${WEBSITE}-webalizer-cron.sh file to /etc/cron.hourly"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement