forked from frappe/bench
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: patch for older setups with wrong cron format
- Loading branch information
1 parent
7dcd5f9
commit 097879e
Showing
1 changed file
with
19 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |