Last active
August 28, 2023 19:34
-
-
Save Razuuu/86debde46122acc1750dae4b787db687 to your computer and use it in GitHub Desktop.
Create wildcard letsencrypt certificate with rfc2136 - Custom nameservers
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
#!/bin/bash | |
# ------------------------------------------------------ | |
# Functions - Common | |
# ------------------------------------------------------ | |
DOMAIN=$1 | |
SUBDOMAIN=$2 | |
# See https://certbot-dns-rfc2136.readthedocs.io/en/stable/ for certbot.ini | |
COMMAND="certbot certonly --dns-rfc2136 --dns-rfc2136-credentials /root/.secrets/certbot.ini" | |
# Request a ssl certificate for $DOMAIN | |
function request_ssl_certificate() { | |
if [ -z $SUBDOMAIN ]; then | |
$COMMAND -d *.${DOMAIN} -d $DOMAIN | |
else | |
$COMMAND -d *.${DOMAIN} -d $DOMAIN -d *.${SUBDOMAIN}.${DOMAIN} | |
fi | |
} | |
# Checks if $DOMAIN is empty | |
function check_var_empty() { | |
if [ -z $DOMAIN ]; then | |
echo "bash `basename $0` <Domain> <Subdomain (optional)>" | |
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