change webalizer cron to systemd timer
This commit is contained in:
parent
e300369ab0
commit
070f07635a
|
@ -131,9 +131,12 @@ fi
|
|||
apt -y install webalizer
|
||||
cp etc/logrotate.d/apache2 /etc/logrotate.d/apache2
|
||||
chmod 644 /etc/logrotate.d/apache2
|
||||
cp etc/cron.daily/webalizer /etc/cron.daily/webalizer
|
||||
chmod 755 /etc/cron.daily/webalizer
|
||||
rm /etc/cron.daily/webalizer
|
||||
rmdir /srv/www/webalizer
|
||||
cp systemd/webalizer.* /usr/lib/systemd/system/
|
||||
chmod 644 /usr/lib/systemd/system/webalizer.*
|
||||
systemctl enable webalizer.timer
|
||||
systemctl start webalizer.timer
|
||||
|
||||
# install status.php
|
||||
cp html/status.php /srv/www/html
|
||||
|
|
|
@ -52,6 +52,11 @@ foreach $virtualhost (@dir) {
|
|||
# set spool dir for temporary apache files
|
||||
$spool_dir="/var/spool/apache2";
|
||||
|
||||
# creatre spool dir if it doesn't already exist
|
||||
if (!-d "$spool_dir") {
|
||||
system("mkdir $spool_dir");
|
||||
}
|
||||
|
||||
# remove any previous files from spool dir
|
||||
system("/usr/bin/find $spool_dir -type f -name '*.log' -exec rm {} +");
|
||||
|
||||
|
|
11
systemd/webalizer.service
Normal file
11
systemd/webalizer.service
Normal file
|
@ -0,0 +1,11 @@
|
|||
# vmail-stack
|
||||
# https://git.stack-source.com/msb/vmail-stack
|
||||
# MIT License Copyright (c) 2021 Matthew Saunders Brown
|
||||
#
|
||||
[Unit]
|
||||
Description=Webalizer - generate stats from apache logs
|
||||
After=logrotate.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/usr/local/sbin/webalizer-cron.sh
|
16
systemd/webalizer.timer
Normal file
16
systemd/webalizer.timer
Normal file
|
@ -0,0 +1,16 @@
|
|||
# vmail-stack
|
||||
# https://git.stack-source.com/msb/vmail-stack
|
||||
# MIT License Copyright (c) 2021 Matthew Saunders Brown
|
||||
#
|
||||
[Unit]
|
||||
Description=Webalizer - analyze apache logs once per day
|
||||
After=logrotate.timer
|
||||
|
||||
[Timer]
|
||||
OnCalendar=daily
|
||||
AccuracySec=12h
|
||||
Persistent=true
|
||||
Unit=webalizer.service
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
14
update.sh
14
update.sh
|
@ -75,3 +75,17 @@ if ! diff -q libexec/command-not-found-handle /usr/local/libexec/command-not-fou
|
|||
echo "/usr/local/libexec/command-not-found-handle updated"
|
||||
echo
|
||||
fi
|
||||
|
||||
# check systemd timer for update
|
||||
if ! diff -q systemd/webalizer.service /usr/lib/systemd/system/webalizer.service ; then
|
||||
cp systemd/webalizer.service /usr/lib/systemd/system/webalizer.service
|
||||
chmod 644 /usr/lib/systemd/system/webalizer.service
|
||||
echo "systemd/webalizer.service updated"
|
||||
echo
|
||||
fi
|
||||
if ! diff -q systemd/webalizer.timer /usr/lib/systemd/system/webalizer.timer ; then
|
||||
cp systemd/webalizer.timer /usr/lib/systemd/system/webalizer.timer
|
||||
chmod 644 /usr/lib/systemd/system/webalizer.timer
|
||||
echo "systemd/webalizer.timer updated"
|
||||
echo
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue
Block a user