uacme: propagate rc of uacme in issue_cert()
Before this commit, issue_cert always returned 1 no matter if uacme returned 1, 2, 3, ... With this commit, the return code of the uacme binary is propagated. Therefore the caller of issue_cert can differentiate between "no renew necessary" and "an error occurred". Signed-off-by: Leonardo Mörlein <me@irrelefant.net>
This commit is contained in:
parent
4588a61652
commit
9a6c2339b0
1 changed files with 11 additions and 9 deletions
|
@ -250,9 +250,9 @@ issue_cert()
|
||||||
|
|
||||||
if [ -n "$user_setup" ] && [ -f "$user_setup" ]; then
|
if [ -n "$user_setup" ] && [ -f "$user_setup" ]; then
|
||||||
log "Running user-provided setup script from $user_setup."
|
log "Running user-provided setup script from $user_setup."
|
||||||
"$user_setup" "$main_domain" || return 1
|
"$user_setup" "$main_domain" || return 2
|
||||||
else
|
else
|
||||||
[ -n "$webroot" ] || [ -n "$dns" ] || pre_checks "$main_domain" || return 1
|
[ -n "$webroot" ] || [ -n "$dns" ] || pre_checks "$main_domain" || return 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
log "Running $APP for $main_domain"
|
log "Running $APP for $main_domain"
|
||||||
|
@ -266,7 +266,7 @@ issue_cert()
|
||||||
if [ -f "$STATE_DIR/$main_domain/cert.pem" ]; then
|
if [ -f "$STATE_DIR/$main_domain/cert.pem" ]; then
|
||||||
log "Found previous cert config, use staging=$use_staging. Issuing renew."
|
log "Found previous cert config, use staging=$use_staging. Issuing renew."
|
||||||
export CHALLENGE_PATH="$webroot"
|
export CHALLENGE_PATH="$webroot"
|
||||||
$ACME $debug --confdir "$STATE_DIR" $staging --never-create issue $domains --hook=$HPROGRAM && ret=0 || ret=1
|
$ACME $debug --confdir "$STATE_DIR" $staging --never-create issue $domains --hook=$HPROGRAM; ret=$?
|
||||||
post_checks
|
post_checks
|
||||||
return $ret
|
return $ret
|
||||||
fi
|
fi
|
||||||
|
@ -284,7 +284,7 @@ issue_cert()
|
||||||
mv "$STATE_DIR/$main_domain" "$STATE_DIR/$main_domain.staging"
|
mv "$STATE_DIR/$main_domain" "$STATE_DIR/$main_domain.staging"
|
||||||
else
|
else
|
||||||
log "Found previous cert config. Issuing renew."
|
log "Found previous cert config. Issuing renew."
|
||||||
$ACME --home "$STATE_DIR" --renew -d "$main_domain" "$acme_args" && ret=0 || ret=1
|
$ACME --home "$STATE_DIR" --renew -d "$main_domain" "$acme_args"; ret=$?
|
||||||
post_checks
|
post_checks
|
||||||
return $ret
|
return $ret
|
||||||
fi
|
fi
|
||||||
|
@ -304,7 +304,7 @@ issue_cert()
|
||||||
acme_args="$acme_args --dns $dns"
|
acme_args="$acme_args --dns $dns"
|
||||||
else
|
else
|
||||||
log "Using dns mode, dns-01 is not wrapped yet"
|
log "Using dns mode, dns-01 is not wrapped yet"
|
||||||
return 1
|
return 2
|
||||||
# uacme_args="$uacme_args --dns $dns"
|
# uacme_args="$uacme_args --dns $dns"
|
||||||
fi
|
fi
|
||||||
elif [ -z "$webroot" ]; then
|
elif [ -z "$webroot" ]; then
|
||||||
|
@ -313,13 +313,13 @@ issue_cert()
|
||||||
acme_args="$acme_args --standalone --listen-v6"
|
acme_args="$acme_args --standalone --listen-v6"
|
||||||
else
|
else
|
||||||
log "Standalone not supported by $APP"
|
log "Standalone not supported by $APP"
|
||||||
return 1
|
return 2
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if [ ! -d "$webroot" ]; then
|
if [ ! -d "$webroot" ]; then
|
||||||
err "$main_domain: Webroot dir '$webroot' does not exist!"
|
err "$main_domain: Webroot dir '$webroot' does not exist!"
|
||||||
post_checks
|
post_checks
|
||||||
return 1
|
return 2
|
||||||
fi
|
fi
|
||||||
log "Using webroot dir: $webroot"
|
log "Using webroot dir: $webroot"
|
||||||
if [ "$APP" = "uacme" ]; then
|
if [ "$APP" = "uacme" ]; then
|
||||||
|
@ -335,13 +335,15 @@ issue_cert()
|
||||||
else
|
else
|
||||||
workdir="--home"
|
workdir="--home"
|
||||||
fi
|
fi
|
||||||
if ! $ACME $debug $workdir "$STATE_DIR" $staging issue $acme_args $HOOK; then
|
|
||||||
|
$ACME $debug $workdir "$STATE_DIR" $staging issue $acme_args $HOOK; ret=$?
|
||||||
|
if [ "$ret" -ne 0 ]; then
|
||||||
failed_dir="$STATE_DIR/${main_domain}.failed-$(date +%s)"
|
failed_dir="$STATE_DIR/${main_domain}.failed-$(date +%s)"
|
||||||
err "Issuing cert for $main_domain failed. Moving state to $failed_dir"
|
err "Issuing cert for $main_domain failed. Moving state to $failed_dir"
|
||||||
[ -d "$STATE_DIR/$main_domain" ] && mv "$STATE_DIR/$main_domain" "$failed_dir"
|
[ -d "$STATE_DIR/$main_domain" ] && mv "$STATE_DIR/$main_domain" "$failed_dir"
|
||||||
[ -d "$STATE_DIR/private/$main_domain" ] && mv "$STATE_DIR/private/$main_domain" "$failed_dir"
|
[ -d "$STATE_DIR/private/$main_domain" ] && mv "$STATE_DIR/private/$main_domain" "$failed_dir"
|
||||||
post_checks
|
post_checks
|
||||||
return 1
|
return $ret
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -e /etc/init.d/uhttpd ] && [ "$update_uhttpd" -eq "1" ]; then
|
if [ -e /etc/init.d/uhttpd ] && [ "$update_uhttpd" -eq "1" ]; then
|
||||||
|
|
Loading…
Reference in a new issue