From 304ba5ca0bafb891c3e373aa4ac5758a9dd5defb Mon Sep 17 00:00:00 2001 From: Lorenzo Tucci Date: Fri, 5 Nov 2021 10:49:28 +0100 Subject: [PATCH] feat: adding certbot renewal service and timer --- etc/systemd/system/certbot-renewal.service | 6 ++++++ etc/systemd/system/certbot-renewal.timer | 10 ++++++++++ usr/local/bin/certbot-restart-nginx | 5 +++++ 3 files changed, 21 insertions(+) create mode 100644 etc/systemd/system/certbot-renewal.service create mode 100644 etc/systemd/system/certbot-renewal.timer create mode 100644 usr/local/bin/certbot-restart-nginx diff --git a/etc/systemd/system/certbot-renewal.service b/etc/systemd/system/certbot-renewal.service new file mode 100644 index 0000000..0d5bc23 --- /dev/null +++ b/etc/systemd/system/certbot-renewal.service @@ -0,0 +1,6 @@ +[Unit] +Description=Automatically renews SSL certificates obtained with certbot + +[Service] +Type=oneshot +ExecStart=/usr/bin/certbot renew -q --post-hook /usr/local/bin/certbot-restart-nginx diff --git a/etc/systemd/system/certbot-renewal.timer b/etc/systemd/system/certbot-renewal.timer new file mode 100644 index 0000000..155226e --- /dev/null +++ b/etc/systemd/system/certbot-renewal.timer @@ -0,0 +1,10 @@ +[Unit] +Description=This is the timer schedule Automatic renewals of SSL certificates obtained with certbot + +[Timer] +OnCalendar=daily +RandomizedDelaySec=6hours +Persistent=true + +[Install] +WantedBy=timers.target diff --git a/usr/local/bin/certbot-restart-nginx b/usr/local/bin/certbot-restart-nginx new file mode 100644 index 0000000..0f70088 --- /dev/null +++ b/usr/local/bin/certbot-restart-nginx @@ -0,0 +1,5 @@ +#!/bin/bash + +PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin + +nginx -tq && systemctl restart nginx