|
@ -46,6 +46,8 @@ MODE_STATELESS="stateless" |
|
|
STATE_VERIFIED="verified_ok" |
|
|
STATE_VERIFIED="verified_ok" |
|
|
|
|
|
|
|
|
NGINX="nginx:" |
|
|
NGINX="nginx:" |
|
|
|
|
|
NGINX_START="#ACME_NGINX_START" |
|
|
|
|
|
NGINX_END="#ACME_NGINX_END" |
|
|
|
|
|
|
|
|
BEGIN_CSR="-----BEGIN CERTIFICATE REQUEST-----" |
|
|
BEGIN_CSR="-----BEGIN CERTIFICATE REQUEST-----" |
|
|
END_CSR="-----END CERTIFICATE REQUEST-----" |
|
|
END_CSR="-----END CERTIFICATE REQUEST-----" |
|
@ -2312,13 +2314,26 @@ _setNginx() { |
|
|
fi |
|
|
fi |
|
|
_start_f="$NGINX_CONF" |
|
|
_start_f="$NGINX_CONF" |
|
|
fi |
|
|
fi |
|
|
_info "Start detect nginx conf for $_d from:$_start_f" |
|
|
|
|
|
|
|
|
_debug "Start detect nginx conf for $_d from:$_start_f" |
|
|
if ! _checkConf "$_d" "$_start_f"; then |
|
|
if ! _checkConf "$_d" "$_start_f"; then |
|
|
"Can not find conf file for domain $d" |
|
|
"Can not find conf file for domain $d" |
|
|
return 1 |
|
|
return 1 |
|
|
fi |
|
|
fi |
|
|
_info "Found conf file: $FOUND_REAL_NGINX_CONF" |
|
|
_info "Found conf file: $FOUND_REAL_NGINX_CONF" |
|
|
|
|
|
|
|
|
|
|
|
_ln=$(grep -n "^ *server_name.* $_d" "$FOUND_REAL_NGINX_CONF" | cut -d : -f 1 | tr -d "\n") |
|
|
|
|
|
_debug "_ln" "$_ln" |
|
|
|
|
|
|
|
|
|
|
|
_lnn=$(_math $_ln + 1) |
|
|
|
|
|
_debug _lnn "$_lnn" |
|
|
|
|
|
_start_tag="$(sed -n "$_lnn,${_lnn}p" "$FOUND_REAL_NGINX_CONF")" |
|
|
|
|
|
_debug "_start_tag" "$_start_tag" |
|
|
|
|
|
if [ "$_start_tag" = "$NGINX_START" ]; then |
|
|
|
|
|
_info "The domain $_d is already configured, skip" |
|
|
|
|
|
FOUND_REAL_NGINX_CONF="" |
|
|
|
|
|
return 0 |
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
mkdir -p "$DOMAIN_BACKUP_PATH" |
|
|
mkdir -p "$DOMAIN_BACKUP_PATH" |
|
|
_backup_conf="$DOMAIN_BACKUP_PATH/$_d.nginx.conf" |
|
|
_backup_conf="$DOMAIN_BACKUP_PATH/$_d.nginx.conf" |
|
|
_debug _backup_conf "$_backup_conf" |
|
|
_debug _backup_conf "$_backup_conf" |
|
@ -2337,8 +2352,6 @@ _setNginx() { |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
_info "OK, Set up nginx config file" |
|
|
_info "OK, Set up nginx config file" |
|
|
_ln=$(grep -n "^ *server_name.* $_d" "$_backup_conf" | cut -d : -f 1 | tr -d "\n") |
|
|
|
|
|
_debug "_ln" "$_ln" |
|
|
|
|
|
|
|
|
|
|
|
if ! sed -n "1,${_ln}p" "$_backup_conf" > "$FOUND_REAL_NGINX_CONF"; then |
|
|
if ! sed -n "1,${_ln}p" "$_backup_conf" > "$FOUND_REAL_NGINX_CONF"; then |
|
|
cat "$_backup_conf" >"$FOUND_REAL_NGINX_CONF" |
|
|
cat "$_backup_conf" >"$FOUND_REAL_NGINX_CONF" |
|
@ -2346,15 +2359,15 @@ _setNginx() { |
|
|
return 1 |
|
|
return 1 |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
echo " |
|
|
|
|
|
|
|
|
echo "$NGINX_START |
|
|
location ~ \"^/\.well-known/acme-challenge/([-_a-zA-Z0-9]+)\$\" { |
|
|
location ~ \"^/\.well-known/acme-challenge/([-_a-zA-Z0-9]+)\$\" { |
|
|
default_type text/plain; |
|
|
default_type text/plain; |
|
|
return 200 \"\$1.$_thumbpt\"; |
|
|
return 200 \"\$1.$_thumbpt\"; |
|
|
} |
|
|
} |
|
|
|
|
|
#NGINX_START |
|
|
" >>"$FOUND_REAL_NGINX_CONF" |
|
|
" >>"$FOUND_REAL_NGINX_CONF" |
|
|
|
|
|
|
|
|
_ln=$(_math $_ln + 1) |
|
|
|
|
|
if ! sed -n "${_ln},99999p" "$_backup_conf" >> "$FOUND_REAL_NGINX_CONF"; then |
|
|
|
|
|
|
|
|
if ! sed -n "${_lnn},99999p" "$_backup_conf" >>"$FOUND_REAL_NGINX_CONF"; then |
|
|
cat "$_backup_conf" >"$FOUND_REAL_NGINX_CONF" |
|
|
cat "$_backup_conf" >"$FOUND_REAL_NGINX_CONF" |
|
|
_err "write nginx conf error, but don't worry, the file is restored." |
|
|
_err "write nginx conf error, but don't worry, the file is restored." |
|
|
return 1 |
|
|
return 1 |
|
@ -3201,7 +3214,9 @@ issue() { |
|
|
_clearup |
|
|
_clearup |
|
|
_on_issue_err |
|
|
_on_issue_err |
|
|
return 1 |
|
|
return 1 |
|
|
else |
|
|
|
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
if [ "$FOUND_REAL_NGINX_CONF" ]; then |
|
|
_realConf="$FOUND_REAL_NGINX_CONF" |
|
|
_realConf="$FOUND_REAL_NGINX_CONF" |
|
|
_backup="$BACKUP_NGINX_CONF" |
|
|
_backup="$BACKUP_NGINX_CONF" |
|
|
_debug _realConf "$_realConf" |
|
|
_debug _realConf "$_realConf" |
|
|