linux - fix cron jobs

This commit is contained in:
bunkerity 2021-08-18 16:15:26 +02:00
parent 0938b20eb8
commit fd52bb7c8d
No known key found for this signature in database
GPG Key ID: 3D80806F12602A7C
3 changed files with 14 additions and 7 deletions

View File

@ -886,14 +886,14 @@ do_and_check_cmd chmod 770 /var/lib/letsencrypt
# Install cron
echo "[*] Add jobs to crontab"
if [ "$OS" = "debian" ] || [ "$OS" = "ubuntu" ] ; then
CRON_PATH="/var/spool/cron/crontabs/nginx"
elif [ "$OS" = "centos" ] || [ "$OS" = "fedora" ] ; then
CRON_PATH="/var/spool/cron/nginx"
elif [ "$OS" = "alpine" ] ; then
if [ "$OS" = "alpine" ] ; then
CRON_SRC="/tmp/bunkerized-nginx/misc/cron"
CRON_PATH="/etc/crontabs/nginx"
else
CRON_SRC="/tmp/bunkerized-nginx/misc/cron-linux"
CRON_PATH="/etc/cron.d/nginx"
fi
do_and_check_cmd cp /tmp/bunkerized-nginx/misc/cron "$CRON_PATH"
do_and_check_cmd cp "$CRON_SRC" "$CRON_PATH"
do_and_check_cmd chown root:nginx "$CRON_PATH"
do_and_check_cmd chmod 740 "$CRON_PATH"

View File

@ -48,7 +48,7 @@ class JobManagement() :
return ReloadRet.OK
return ReloadRet.KO
elif self.__local_nginx :
proc = subprocess.run(["/usr/sbin/nginx", "-s", "reload"], capture_output=True)
proc = subprocess.run(["sudo", "/opt/bunkerized-nginx/ui/linux.sh", "reload"], capture_output=True)
if proc.returncode != 0 :
log("reload", "ERROR", "can't reload nginx (status code = " + str(proc.returncode) + ")")
if len(proc.stdout.decode("ascii")) > 1 :

7
misc/cron-linux Normal file
View File

@ -0,0 +1,7 @@
15 0 * * * nginx /opt/bunkerized-nginx/jobs/main.py --reload --name certbot-renew >> /var/log/nginx/jobs.log 2>&1
30 0 * * * nginx /opt/bunkerized-nginx/jobs/main.py --reload --name user-agents >> /var/log/nginx/jobs.log 2>&1
45 0 * * * nginx /opt/bunkerized-nginx/jobs/main.py --reload --name referrers >> /var/log/nginx/jobs.log 2>&1
0 1 * * * nginx /opt/bunkerized-nginx/jobs/main.py --reload --name abusers >> /var/log/nginx/jobs.log 2>&1
0 2 * * * nginx /opt/bunkerized-nginx/jobs/main.py --reload --name proxies >> /var/log/nginx/jobs.log 2>&1
0 */1 * * * nginx /opt/bunkerized-nginx/jobs/main.py --reload --name exit-nodes >> /var/log/nginx/jobs.log 2>&1
0 3 2 * * nginx /opt/bunkerized-nginx/jobs/main.py --reload --name geoip >> /var/log/nginx/jobs.log 2>&1