Browse Source

Add interactive dns

bryan 3 years ago
parent
commit
e92c6c2fef
2 changed files with 22 additions and 2 deletions
  1. 1 1
      README.md
  2. 21 1
      acme-cpanel.sh

+ 1 - 1
README.md

@@ -18,7 +18,7 @@ RewriteRule ^\.well-known/.+ - [END]
 Command-line (Linux):
 
 * Move script to user home directory on the server: `scp ./* username@ip:port:~`
-* Login to server: `ssh user@ip -p port`
+* Log in to server: `ssh user@ip -p port`
 * Make script executable: `chmod +x $HOME/acme-cpanel.sh`
 * Run script (ex. `$HOME/acme-cpanel.sh -s multisites`)
 * Follow prompts to enter credentials, issue certificates, and deploy them

+ 21 - 1
acme-cpanel.sh

@@ -20,7 +20,7 @@
 # Certificates will automatically be issued and deployed for DOMAIN and www.DOMAIN using the webroot method
 #
 # NOTE: The webroot method does NOT support wildcard domains, Let's Encrypt requires wildcard domains to
-# use DNS challenges, which the CPANEL uapi does not support (use dns_cpaneldns plugin instead)
+# use DNS challenges, which the cPanel uapi does not support (use dns method instead)
 
 unset SITES_DIR USEREMAIL DOMAIN_FILES DOMAIN_GROUPS DEPLOY_CMD_PREFIX ISSUE_CMD_PREFIX DEBUG GROUP
 
@@ -86,6 +86,25 @@ parse_input() {
 }
 
 
+interactive_dns() {
+    local conf="$HOME/.acme.sh/account.conf"
+    if [[ -f "$conf" ]] && grep -q "CPANELDNS_AUTH_PASSWORD" "$conf"; then
+        echo "cPanel credentials already present, skipping configuration..."
+        echo "To rerun the configuration, first run 'rm $conf'"
+    else
+        read -rp 'Enter your cPanel username: ' CPANELDNS_AUTH_ID
+        echo
+        export CPANELDNS_AUTH_ID
+        read -rp 'Enter your cPanel password: ' CPANELDNS_AUTH_PASSWORD
+        echo
+        export CPANELDNS_AUTH_PASSWORD
+        read -rp 'Enter your cPanel address and port number (example: "https://www.example.com:2083/"): ' CPANELDNS_API
+        echo
+        export CPANELDNS_API
+    fi
+}
+
+
 get_acme() {
     curl https://get.acme.sh | sh
     source "$HOME/.bashrc"
@@ -205,6 +224,7 @@ main() {
     update_email
     command_prefixes
     load_domains
+    [[ "$METHOD" == "dns" ]] && interactive_dns
     issue_and_deploy_certs
 }