Skip to content

Commit

Permalink
feat: patch for older setups with wrong cron format
Browse files Browse the repository at this point in the history
  • Loading branch information
abhishekbalam committed Sep 8, 2020
1 parent 7dcd5f9 commit 097879e
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions bench/patches/v5/fix_letsencrypt_renew_frequency.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from bench.config.common_site_config import get_config
from crontab import CronTab


def execute(bench_path):
"""
This patch fixes a cron job that would renew letsencrypt certificate
"""

job_command = '/opt/certbot-auto renew --force-renewal -a nginx --post-hook "systemctl reload nginx"'
system_crontab = CronTab(user='root')
job_comment = "Renew lets-encrypt every month"

for job in system_crontab.find_comment(job_comment)
system_crontab.remove(job)
job = system_crontab.new(command=job_command, comment=job_comment)
job.setall('0 0 1 * *') # Run at 00:00 on every day-of-month 1
system_crontab.write()
break

0 comments on commit 097879e

Please sign in to comment.