Browse Source

More. restore apache on error

master
neil 9 years ago
parent
commit
5ef501c5ec
  1. 17
      acme.sh

17
acme.sh

@ -818,10 +818,12 @@ _restoreApache() {
fi fi
cp -p "$APACHE_CONF_BACKUP_DIR/$httpdconfname" "$httpdconf" cp -p "$APACHE_CONF_BACKUP_DIR/$httpdconfname" "$httpdconf"
_debug "Restored: $httpdconf."
if ! apachectl -t ; then if ! apachectl -t ; then
_err "Sorry, restore apache config error, please contact me." _err "Sorry, restore apache config error, please contact me."
return 1; return 1;
fi fi
_debug "Restored successfully."
rm -f "$APACHE_CONF_BACKUP_DIR/$httpdconfname" rm -f "$APACHE_CONF_BACKUP_DIR/$httpdconfname"
return 0 return 0
} }
@ -886,7 +888,7 @@ Allow from all
return 0 return 0
} }
_clearup () {
_clearup() {
_stopserver $serverproc _stopserver $serverproc
serverproc="" serverproc=""
_restoreApache _restoreApache
@ -977,7 +979,7 @@ issue() {
if [[ "$Le_Webroot" == *"no"* ]] ; then if [[ "$Le_Webroot" == *"no"* ]] ; then
_info "Standalone mode." _info "Standalone mode."
if ! command -v "nc" > /dev/null ; then
if ! _exists "nc" ; then
_err "Please install netcat(nc) tools first." _err "Please install netcat(nc) tools first."
return 1 return 1
fi fi
@ -1009,11 +1011,17 @@ issue() {
if [[ ! -f "$ACCOUNT_KEY_PATH" ]] ; then if [[ ! -f "$ACCOUNT_KEY_PATH" ]] ; then
if ! createAccountKey $Le_Domain $Le_Keylength ; then if ! createAccountKey $Le_Domain $Le_Keylength ; then
_err "Create account key error." _err "Create account key error."
if [[ "$usingApache" ]] ; then
_restoreApache
fi
return 1 return 1
fi fi
fi fi
if ! _calcjwk "$ACCOUNT_KEY_PATH" ; then if ! _calcjwk "$ACCOUNT_KEY_PATH" ; then
if [[ "$usingApache" ]] ; then
_restoreApache
fi
return 1 return 1
fi fi
@ -1049,12 +1057,14 @@ issue() {
if [[ ! -f "$CERT_KEY_PATH" ]] ; then if [[ ! -f "$CERT_KEY_PATH" ]] ; then
if ! createDomainKey $Le_Domain $Le_Keylength ; then if ! createDomainKey $Le_Domain $Le_Keylength ; then
_err "Create domain key error." _err "Create domain key error."
_clearup
return 1 return 1
fi fi
fi fi
if ! createCSR $Le_Domain $Le_Alt ; then if ! createCSR $Le_Domain $Le_Alt ; then
_err "Create CSR error." _err "Create CSR error."
_clearup
return 1 return 1
fi fi
@ -1171,6 +1181,7 @@ issue() {
) )
if [[ "$?" != "0" ]] ; then if [[ "$?" != "0" ]] ; then
_clearup
return 1 return 1
fi fi
dnsadded='1' dnsadded='1'
@ -1181,6 +1192,7 @@ issue() {
_setopt "$DOMAIN_CONF" "Le_Vlist" "=" "\"$vlist\"" _setopt "$DOMAIN_CONF" "Le_Vlist" "=" "\"$vlist\""
_debug "Dns record not added yet, so, save to $DOMAIN_CONF and exit." _debug "Dns record not added yet, so, save to $DOMAIN_CONF and exit."
_err "Please add the TXT records to the domains, and retry again." _err "Please add the TXT records to the domains, and retry again."
_clearup
return 1 return 1
fi fi
@ -1216,6 +1228,7 @@ issue() {
_info "Standalone mode server" _info "Standalone mode server"
_startserver "$keyauthorization" & _startserver "$keyauthorization" &
if [[ "$?" != "0" ]] ; then if [[ "$?" != "0" ]] ; then
_clearup
return 1 return 1
fi fi
serverproc="$!" serverproc="$!"

Loading…
Cancel
Save