Update e-mail function
This commit is contained in:
@@ -26,6 +26,8 @@ unset SITES_DIR USEREMAIL DOMAIN_FILES DOMAIN_GROUPS DEPLOY_CMD_PREFIX ISSUE_CMD
|
|||||||
|
|
||||||
DEBUG="true" # quote this line to stop DEBUG mode and issue certificates for real, or use --force in user options
|
DEBUG="true" # quote this line to stop DEBUG mode and issue certificates for real, or use --force in user options
|
||||||
METHOD="dns" # set the default method
|
METHOD="dns" # set the default method
|
||||||
|
CONF="$HOME/.acme.sh/account.conf"
|
||||||
|
ACME_SH="$HOME/.acme.sh/acme.sh"
|
||||||
|
|
||||||
parse_input() {
|
parse_input() {
|
||||||
|
|
||||||
@@ -41,10 +43,6 @@ parse_input() {
|
|||||||
shift
|
shift
|
||||||
METHOD="${1,,}"
|
METHOD="${1,,}"
|
||||||
;;
|
;;
|
||||||
--email|-e)
|
|
||||||
shift
|
|
||||||
USEREMAIL="$1"
|
|
||||||
;;
|
|
||||||
--force|-f)
|
--force|-f)
|
||||||
unset DEBUG
|
unset DEBUG
|
||||||
;;
|
;;
|
||||||
@@ -87,10 +85,9 @@ parse_input() {
|
|||||||
|
|
||||||
|
|
||||||
interactive_dns() {
|
interactive_dns() {
|
||||||
local conf="$HOME/.acme.sh/account.conf"
|
if [[ -f "$CONF" ]] && grep -q "CPANELDNS_AUTH_PASSWORD" "$CONF"; then
|
||||||
if [[ -f "$conf" ]] && grep -q "CPANELDNS_AUTH_PASSWORD" "$conf"; then
|
|
||||||
echo "cPanel credentials already present, skipping configuration..."
|
echo "cPanel credentials already present, skipping configuration..."
|
||||||
echo "To rerun the configuration, first run 'rm $conf'"
|
echo "To rerun the configuration, first run 'rm $CONF'"
|
||||||
else
|
else
|
||||||
read -rp 'Enter your cPanel username: ' CPANELDNS_AUTH_ID
|
read -rp 'Enter your cPanel username: ' CPANELDNS_AUTH_ID
|
||||||
echo
|
echo
|
||||||
@@ -107,22 +104,32 @@ interactive_dns() {
|
|||||||
|
|
||||||
get_acme() {
|
get_acme() {
|
||||||
curl https://get.acme.sh | sh
|
curl https://get.acme.sh | sh
|
||||||
|
# shellcheck disable=SC1090
|
||||||
source "$HOME/.bashrc"
|
source "$HOME/.bashrc"
|
||||||
"$HOME/.acme.sh/acme.sh" --upgrade --auto-upgrade
|
"$ACME_SH" --upgrade --auto-upgrade
|
||||||
[[ "$METHOD" == "dns" ]] && \
|
[[ "$METHOD" == "dns" ]] && \
|
||||||
curl -o "$HOME/.acme.sh/dnsapi/dns_cpaneldns.sh" https://raw.githubusercontent.com/cryobry/dns_cpaneldns/master/dns_cpaneldns.sh
|
curl -o "$HOME/.acme.sh/dnsapi/dns_cpaneldns.sh" https://raw.githubusercontent.com/cryobry/dns_cpaneldns/master/dns_cpaneldns.sh
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
update_email() { [[ -v USEREMAIL ]] && "$HOME/.acme.sh/acme.sh" --update-account --accountemail "${USEREMAIL}"; }
|
update_email() {
|
||||||
|
if [[ ! -v USEREMAIL ]]; then
|
||||||
|
if [[ -f "$CONF" ]] && line=$(grep -q "ACCOUNT_EMAIL" "$CONF"); then
|
||||||
|
echo "Reusing existing contact e-mail: ${line#ACCOUNT_EMAIL=}"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
read -rp 'Enter your contact e-mail (in case of renewal failures): ' USEREMAIL
|
||||||
|
fi
|
||||||
|
"$ACME_SH" --update-account --accountemail "${USEREMAIL}"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
command_prefixes() {
|
command_prefixes() {
|
||||||
declare -ag ISSUE_CMD_PREFIX DEPLOY_CMD_PREFIX
|
declare -ag ISSUE_CMD_PREFIX DEPLOY_CMD_PREFIX
|
||||||
ISSUE_CMD_PREFIX=("$HOME/.acme.sh/acme.sh" "--issue")
|
ISSUE_CMD_PREFIX=("$ACME_SH" "--issue")
|
||||||
[[ "$METHOD" == "dns" ]] && ISSUE_CMD_PREFIX=("${ISSUE_CMD_PREFIX[@]}" "--dns" "dns_cpaneldns")
|
[[ "$METHOD" == "dns" ]] && ISSUE_CMD_PREFIX=("${ISSUE_CMD_PREFIX[@]}" "--dns" "dns_cpaneldns")
|
||||||
[[ -v DEBUG ]] && ISSUE_CMD_PREFIX=("${ISSUE_CMD_PREFIX[@]}" "--staging") || ISSUE_CMD_PREFIX=("${ISSUE_CMD_PREFIX[@]}" "--force")
|
[[ -v DEBUG ]] && ISSUE_CMD_PREFIX=("${ISSUE_CMD_PREFIX[@]}" "--staging") || ISSUE_CMD_PREFIX=("${ISSUE_CMD_PREFIX[@]}" "--force")
|
||||||
DEPLOY_CMD_PREFIX=("$HOME/.acme.sh/acme.sh" "--deploy" "--deploy-hook" "cpanel_uapi")
|
DEPLOY_CMD_PREFIX=("$ACME_SH" "--deploy" "--deploy-hook" "cpanel_uapi")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -225,6 +232,7 @@ main() {
|
|||||||
command_prefixes
|
command_prefixes
|
||||||
load_domains
|
load_domains
|
||||||
[[ "$METHOD" == "dns" ]] && interactive_dns
|
[[ "$METHOD" == "dns" ]] && interactive_dns
|
||||||
|
sanity_check
|
||||||
issue_and_deploy_certs
|
issue_and_deploy_certs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user