Last active
November 19, 2025 19:58
-
-
Save Razuuu/86debde46122acc1750dae4b787db687 to your computer and use it in GitHub Desktop.
Create wildcard letsencrypt certificate with rfc2136 - Custom nameservers
This file contains hidden or 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
| #!/bin/bash | |
| # ------------------------------------------------------ | |
| # Functions - Common | |
| # ------------------------------------------------------ | |
| DOMAIN="$1" | |
| shift | |
| # See https://certbot-dns-rfc2136.readthedocs.io/en/stable/ for certbot.ini | |
| COMMAND="certbot certonly --dns-rfc2136 --dns-rfc2136-propagation-seconds 10 --dns-rfc2136-credentials /root/.secrets/certbot.ini -v" | |
| # Request an SSL certificate for DOMAIN and all subdomains | |
| function request_ssl_certificate() { | |
| # Base domains | |
| DOMAINS="-d *.${DOMAIN} -d ${DOMAIN}" | |
| # Additional subdomains (wildcards) | |
| for SUB in "$@"; do | |
| DOMAINS="$DOMAINS -d *.${SUB}.${DOMAIN}" | |
| done | |
| # Run certbot | |
| eval $COMMAND $DOMAINS | |
| } | |
| # Checks if DOMAIN is empty | |
| function check_var_empty() { | |
| if [ -z "$DOMAIN" ]; then | |
| echo "Usage: bash $(basename $0) <Domain> <Subdomain1> <Subdomain2> ..." | |
| exit 0 | |
| fi | |
| } | |
| # ------------------------------------------------------ | |
| # Script - Start | |
| # ------------------------------------------------------ | |
| check_var_empty | |
| request_ssl_certificate "$@" | |
| # ------------------------------------------------------ | |
| # Script - End | |
| # ------------------------------------------------------ | |
| exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment