diff --git a/bin/vhost-del.sh b/bin/vhost-del.sh index 099e152..4fc0503 100755 --- a/bin/vhost-del.sh +++ b/bin/vhost-del.sh @@ -83,3 +83,8 @@ if [[ -d /srv/www/$domain ]]; then rm -r /srv/www/$domain fi +# remove webalizer stats +if [[ -d /var/lib/webalizer/$domain ]]; then + rm -r /var/lib/webalizer/$domain +fi + diff --git a/bin/vhost-exp.sh b/bin/vhost-exp.sh index af44c4d..9e512ab 100755 --- a/bin/vhost-exp.sh +++ b/bin/vhost-exp.sh @@ -81,6 +81,11 @@ if [[ -d /srv/www/$domain ]]; then done fi + # webalizer stats + if [[ -d /var/lib/webalizer/$domain ]]; then + cp --archive /var/lib/webalizer/$domain /srv/www/$domain/.exp/webalizer + fi + # output instructions for sycning website to new server, if verbose option was enabled. if [[ -n $verbose ]]; then @@ -125,11 +130,16 @@ if [[ -d /srv/www/$domain ]]; then echo "rsync -v --archive --exclude='.passwd' --rsh=/usr/bin/ssh root@$servername:/home/$username/ /home/$username/" echo "rsync -v --archive --exclude='.my.cnf' --rsh=/usr/bin/ssh root@$servername:/srv/www/$domain/ /srv/www/$domain/" - #db import + # db import if [[ -f /srv/www/$domain/.exp/mysql/$database.sql ]]; then echo "mysql $database < /srv/www/$domain/.exp/mysql/$database.sql" fi + # webalizer stats + if [[ -d /var/lib/webalizer/$domain ]]; then + echo "cp --archive /srv/www/$domain/.exp/webalizer /var/lib/webalizer/$domain" + fi + # /etc/ configs if [[ -d /srv/www/$domain/.exp/etc ]]; then echo "cp -a /srv/www/$domain/.exp/etc/* /etc/" diff --git a/etc/apache2/mods-available/macro.conf b/etc/apache2/mods-available/macro.conf index f67ce09..be93bbb 100644 --- a/etc/apache2/mods-available/macro.conf +++ b/etc/apache2/mods-available/macro.conf @@ -97,7 +97,7 @@ SSLEngine on SSLCertificateFile /etc/ssl/letsencrypt/$vhost.pem - Alias /stats /srv/www/$vhost/stats + Alias /stats /var/lib/webalizer/$vhost AddExternalAuth pwauth /usr/sbin/pwauth SetExternalAuthMethod pwauth pipe diff --git a/install.sh b/install.sh index 9078fd4..3828d94 100755 --- a/install.sh +++ b/install.sh @@ -166,6 +166,7 @@ cp etc/logrotate.d/apache2 /etc/logrotate.d/apache2 chmod 644 /etc/logrotate.d/apache2 rm /etc/cron.daily/webalizer rmdir /srv/www/webalizer +install --owner=root --group=root --mode=755 --directory /var/lib/webalizer systemctl enable --now webalizer.timer # install status.php diff --git a/sbin/webalizer-cron.sh b/sbin/webalizer-cron.sh index 7298453..aa0ddb9 100755 --- a/sbin/webalizer-cron.sh +++ b/sbin/webalizer-cron.sh @@ -19,12 +19,15 @@ if [ ${#virtualhosts[@]} -gt 0 ]; then do if [[ -f /var/spool/apache2/$virtualhost.log ]]; then user=$(stat -c '%U' /srv/www/$virtualhost) - if [[ ! -d /srv/www/$virtualhost/stats ]]; then - install --owner=$user --group=$user --mode=755 --directory /srv/www/$virtualhost/stats + if [[ ! -d /var/lib/webalizer/$virtualhost ]]; then + if [[ ! -d /var/lib/webalizer ]]; then + install --owner=root --group=root --mode=755 --directory /var/lib/webalizer + fi + install --owner=$user --group=$user --mode=755 --directory /var/lib/webalizer/$virtualhost fi - /usr/bin/webazolver -Q -N 20 -D /var/lib/webalizer_dns_cache.db -o /srv/www/$virtualhost/stats /var/spool/apache2/$virtualhost.log + /usr/bin/webazolver -Q -N 20 -D /var/lib/webalizer_dns_cache.db -o /var/lib/webalizer/$virtualhost /var/spool/apache2/$virtualhost.log /usr/bin/logger Running Webalizer for $virtualhost as user $user - su --shell=/bin/bash -c "/usr/bin/webalizer -Q -D /var/lib/webalizer_dns_cache.db -N 0 -p -f -n $virtualhost -o /srv/www/$virtualhost/stats /var/spool/apache2/$virtualhost.log" $user + su --shell=/bin/bash -c "/usr/bin/webalizer -Q -D /var/lib/webalizer_dns_cache.db -N 0 -p -f -n $virtualhost -o /var/lib/webalizer/$virtualhost /var/spool/apache2/$virtualhost.log" $user /usr/bin/rm /var/spool/apache2/$virtualhost.log fi done