Skip to content

Commit 37ceae0

Browse files
author
thomas
committed
解决配置文件制表符导致程序无响应问题
1 parent 3be9228 commit 37ceae0

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

httpsok.sh

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ _initparams() {
163163
# again to verify
164164
$nginx_bin -V > /dev/null 2>&1
165165
if [ $? -ne 0 ]; then
166-
_no_nginx_here
166+
_no_nginx_here
167167
else
168168
echo "Nginx executable path: $nginx_bin"
169169
fi
@@ -337,6 +337,7 @@ _check_token() {
337337
exit 4
338338
fi
339339
status=$(_get "/status")
340+
# _info "status >> $status"
340341
if [ "$status" != "ok" ]; then
341342
# echo -e "\033[1;36mTraceID: $TRACE_ID\033[0m"
342343
_err "Invalid token: \033[1;36m$HTTPSOK_TOKEN\033[0m"
@@ -355,13 +356,16 @@ _include_global_count=0
355356

356357
__process_include() {
357358

358-
if [ $_include_global_count -ge $_include_max_calls ]; then
359-
# echo "Maximum recursion limit reached."
359+
# echo "-_include_global_count: $_include_global_count --------------------------------------------------"
360+
# echo Recursive call, degree incremented by one
361+
((_include_global_count++))
362+
363+
if [ $_include_global_count -gt $_include_max_calls ]; then
364+
echo "#######################################################"
365+
echo "##### warning: Maximum recursion limit reached."
366+
echo "#######################################################"
360367
cat /dev/stdin
361368
return 0
362-
else
363-
# Recursive call, degree incremented by one
364-
((global_count++))
365369
fi
366370

367371
tmp=$(cat /dev/stdin | awk -v NGINX_CONFIG=">$NGINX_CONFIG:" -v NGINX_CONFIG_HOME="$NGINX_CONFIG_HOME" '{
@@ -370,6 +374,7 @@ __process_include() {
370374
371375
# Remove leading and trailing whitespace characters from each line
372376
gsub(/^[[:space:]]+|[[:space:]]+$/, "")
377+
sub(/^[\t ]*|[\t ]*$/,"")
373378
374379
# Ignore the lines at the beginning of the file
375380
if ($0 ~ /^>/) {
@@ -478,18 +483,18 @@ __process_include() {
478483
fi
479484
}
480485

481-
__process_format(){
482-
cat /dev/stdin | awk -v NGINX_CONFIG="$NGINX_CONFIG:" '{
483-
# gsub("import", "include")
484-
# print NGINX_CONFIG $0
485-
print $0
486-
}'
487-
}
486+
# __process_format(){
487+
# cat /dev/stdin | awk -v NGINX_CONFIG="$NGINX_CONFIG:" '{
488+
# # gsub("import", "include")
489+
# # print NGINX_CONFIG $0
490+
# print $0
491+
# }'
492+
# }
488493

489494
_preparse() {
490495
_initparams
491-
492-
config_text=$(cat $NGINX_CONFIG | __process_include | __process_format)
496+
# config_text=$(cat $NGINX_CONFIG | __process_include | __process_format)
497+
config_text=$(cat $NGINX_CONFIG | __process_include )
493498
# exit
494499
# config_text=$(grep -E "ssl|server_name|server|include|listen" -r "$NGINX_CONFIG_HOME" | cat | grep -v 'SERVER_')
495500
preparse=$(_post "/preparse" "$config_text")

0 commit comments

Comments
 (0)