Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F3775905
D3430.id8852.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D3430.id8852.diff
View Options
diff --git a/roles/core/certificates/files/delete-certbot-certificate.sh b/roles/core/certificates/files/delete-certbot-certificate.sh
new file mode 100755
--- /dev/null
+++ b/roles/core/certificates/files/delete-certbot-certificate.sh
@@ -0,0 +1,61 @@
+#!/bin/sh
+
+# -------------------------------------------------------------
+# Remove a Let's Encrypt
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# License: BSD-2-Clause
+# -------------------------------------------------------------
+
+set -e
+
+# -------------------------------------------------------------
+# Ensure user is root
+#
+# Note: POSIX shells don't always define $UID or $EUID.
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+if [ "${EUID:-$(id -u)}" -ne 0 ]; then
+ echo "This command must be run as root." >&2
+ exit 1
+fi
+
+# -------------------------------------------------------------
+# Parse arguments
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+if [ $# -eq 0 ]; then
+ echo "Usage: $(basename "$0") <certificate>" >&2
+ exit 1
+fi
+
+CERTIFICATE=$1
+
+# -------------------------------------------------------------
+# Determine etc directory path
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+. /etc/os-release
+
+if [ "$ID" = "freebsd" ]; then
+ ETC=/usr/local/etc
+else
+ ETC=/etc
+fi
+
+# -------------------------------------------------------------
+# Determine if the certificate exists
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+if [ ! -f "$ETC/letsencrypt/live/$CERTIFICATE/chain.pem" ]; then
+ echo "The certificate cannot be found." >&2
+ exit 2
+fi
+
+# -------------------------------------------------------------
+# Delete certificate and renewal information
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+rm -rf "$ETC/letsencrypt/live/$CERTIFICATE"
+rm -rf "$ETC/letsencrypt/archive/$CERTIFICATE"
+rm "$ETC/letsencrypt/renewal/$CERTIFICATE.conf"
diff --git a/roles/core/certificates/letsencrypt.sls b/roles/core/certificates/letsencrypt.sls
--- a/roles/core/certificates/letsencrypt.sls
+++ b/roles/core/certificates/letsencrypt.sls
@@ -51,6 +51,11 @@
- source: salt://roles/core/certificates/files/edit-acme-dns-accounts.py
- mode: 755
+{{ dirs.bin }}/delete-certbot-certificate:
+ file.managed:
+ - source: salt://roles/core/certificates/files/delete-certbot-certificate.sh
+ - mode: 755
+
# -------------------------------------------------------------
# Check and renew certificates daily
#
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 25, 20:22 (20 h, 46 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2262628
Default Alt Text
D3430.id8852.diff (2 KB)
Attached To
Mode
D3430: Allow to delete Let's Encrypt certificate
Attached
Detach File
Event Timeline
Log In to Comment