From 368a9c36e09fe30b5175f4fc1400e664285a07f9 Mon Sep 17 00:00:00 2001 From: Samuel Huang Date: Tue, 1 Oct 2024 08:20:43 +1000 Subject: [PATCH] Codacy compliant --- run.sh | 6 +++--- server-lgp.sh | 2 +- server-lgr.sh | 2 +- server-lgt.sh | 2 +- server-lsp.sh | 2 +- server-lst.sh | 2 +- server-ltr.sh | 2 +- server-ltt.sh | 2 +- server-lwp.sh | 2 +- server-lwt.sh | 2 +- server-mtt.sh | 2 +- server-mwp.sh | 2 +- server-mwt.sh | 2 +- server-nginx.sh | 26 +++++++++++++------------- server-ttt.sh | 2 +- server-twp.sh | 2 +- server-twt.sh | 2 +- 17 files changed, 31 insertions(+), 31 deletions(-) diff --git a/run.sh b/run.sh index 6a2ab71..1211044 100755 --- a/run.sh +++ b/run.sh @@ -78,13 +78,13 @@ while true ; do ;; --lgp|--lgr|--lgt|--lsp|--lst|--ltr|--ltt|--lwp|--lwt|--mtt|--mwp|--mwt|--ttt|--twp|--twt) # Alias options - SVC=$(echo $1|tr -d '\-\-') + SVC=$(echo "$1"|tr -d "\-\-") SVCMD+=("${DIR}/server-${SVC}.sh $2") shift 2 ;; --ltrx|--lttx) # Alias options - SVC=$(echo $1|tr -d '\-\-'|tr -d x) + SVC=$(echo "$1"|tr -d "\-\-"|tr -d "x") SVCMD+=("${DIR}/server-${SVC}.sh $2,xtls") shift 2 ;; @@ -156,7 +156,7 @@ if [ "${#CERTDOMAIN[@]}" -gt 0 ]; then do echo "Requesting TLS cert for ${DOMAIN} ..." echo "/root/acme.sh/acme.sh --cert-home ${CERTHOME} --issue --standalone -d ${DOMAIN} --debug" - /root/acme.sh/acme.sh --cert-home "${CERTHOME}" --issue --standalone -d ${DOMAIN} --debug + /root/acme.sh/acme.sh --cert-home "${CERTHOME}" --issue --standalone -d "${DOMAIN}" --debug ((TRY++)) if [ "${TRY}" -ge 3 ]; then echo "Requesting TLS cert for ${DOMAIN} failed. Check log please." diff --git a/server-lgp.sh b/server-lgp.sh index c96b246..77af127 100755 --- a/server-lgp.sh +++ b/server-lgp.sh @@ -89,7 +89,7 @@ inbound=$(echo $inbound| jq -c '.streamSettings += {"security":"none"}') # Fallback settings for fb in "${fallback[@]}" do - IFS=':'; fopt=(${fb}); fopt=(${fopt[@]}) + IFS=':'; fopt=("${fb}"); fopt=("${fopt[@]}") fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}" unset IFS if [ -z "${fport}" ]; then >&2 echo -e "Incorrect fallback format: $fb\n"; usage; exit 1; fi diff --git a/server-lgr.sh b/server-lgr.sh index f3503cb..13be555 100755 --- a/server-lgr.sh +++ b/server-lgr.sh @@ -126,7 +126,7 @@ inbound=$(echo $inbound| jq -c --argjson JshortIds "${JshortIds}" '.streamSettin # Fallback settings for fb in "${fallback[@]}" do - IFS=':'; fopt=(${fb}); fopt=(${fopt[@]}) + IFS=':'; fopt=("${fb}"); fopt=("${fopt[@]}") fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}" unset IFS if [ -z "${fport}" ]; then >&2 echo -e "Incorrect fallback format: $fb\n"; usage; exit 1; fi diff --git a/server-lgt.sh b/server-lgt.sh index a2dd55c..fffbcdb 100755 --- a/server-lgt.sh +++ b/server-lgt.sh @@ -107,7 +107,7 @@ inbound=$(echo $inbound| jq -c --arg fullchain "${fullchain}" --arg prvkey "${pr # Fallback settings for fb in "${fallback[@]}" do - IFS=':'; fopt=(${fb}); fopt=(${fopt[@]}) + IFS=':'; fopt=("${fb}"); fopt=("${fopt[@]}") fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}" unset IFS if [ -z "${fport}" ]; then >&2 echo -e "Incorrect fallback format: $fb\n"; usage; exit 1; fi diff --git a/server-lsp.sh b/server-lsp.sh index ccb3dee..03e9271 100755 --- a/server-lsp.sh +++ b/server-lsp.sh @@ -89,7 +89,7 @@ inbound=$(echo $inbound| jq -c '.streamSettings += {"security":"none"}') # Fallback settings for fb in "${fallback[@]}" do - IFS=':'; fopt=(${fb}); fopt=(${fopt[@]}) + IFS=':'; fopt=("${fb}"); fopt=("${fopt[@]}") fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}" unset IFS if [ -z "${fport}" ]; then >&2 echo -e "Incorrect fallback format: $fb\n"; usage; exit 1; fi diff --git a/server-lst.sh b/server-lst.sh index 7434a54..a6eff34 100755 --- a/server-lst.sh +++ b/server-lst.sh @@ -107,7 +107,7 @@ inbound=$(echo $inbound| jq -c --arg fullchain "${fullchain}" --arg prvkey "${pr # Fallback settings for fb in "${fallback[@]}" do - IFS=':'; fopt=(${fb}); fopt=(${fopt[@]}) + IFS=':'; fopt=("${fb}"); fopt=("${fopt[@]}") fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}" unset IFS if [ -z "${fport}" ]; then >&2 echo -e "Incorrect fallback format: $fb\n"; usage; exit 1; fi diff --git a/server-ltr.sh b/server-ltr.sh index 9a007fa..33fb250 100755 --- a/server-ltr.sh +++ b/server-ltr.sh @@ -118,7 +118,7 @@ inbound=$(echo $inbound| jq -c --argjson JshortIds "${JshortIds}" '.streamSettin # Fallback settings for fb in "${fallback[@]}" do - IFS=':'; fopt=(${fb}); fopt=(${fopt[@]}) + IFS=':'; fopt=("${fb}"); fopt=("${fopt[@]}") fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}" unset IFS if [ -z "${fport}" ]; then >&2 echo -e "Incorrect fallback format: $fb\n"; usage; exit 1; fi diff --git a/server-ltt.sh b/server-ltt.sh index 0d20fcb..d8b7a73 100755 --- a/server-ltt.sh +++ b/server-ltt.sh @@ -99,7 +99,7 @@ inbound=$(echo $inbound| jq -c --arg fullchain "${fullchain}" --arg prvkey "${pr # Fallback settings for fb in "${fallback[@]}" do - IFS=':'; fopt=(${fb}); fopt=(${fopt[@]}) + IFS=':'; fopt=("${fb}"); fopt=("${fopt[@]}") fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}" unset IFS if [ -z "${fport}" ]; then >&2 echo -e "Incorrect fallback format: $fb\n"; usage; exit 1; fi diff --git a/server-lwp.sh b/server-lwp.sh index 93920af..1e921c7 100755 --- a/server-lwp.sh +++ b/server-lwp.sh @@ -89,7 +89,7 @@ inbound=$(echo $inbound| jq -c '.streamSettings += {"security":"none"}') # Fallback settings for fb in "${fallback[@]}" do - IFS=':'; fopt=(${fb}); fopt=(${fopt[@]}) + IFS=':'; fopt=("${fb}"); fopt=("${fopt[@]}") fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}" unset IFS if [ -z "${fport}" ]; then >&2 echo -e "Incorrect fallback format: $fb\n"; usage; exit 1; fi diff --git a/server-lwt.sh b/server-lwt.sh index a5e001a..f8d8296 100755 --- a/server-lwt.sh +++ b/server-lwt.sh @@ -107,7 +107,7 @@ inbound=$(echo $inbound| jq -c --arg fullchain "${fullchain}" --arg prvkey "${pr # Fallback settings for fb in "${fallback[@]}" do - IFS=':'; fopt=(${fb}); fopt=(${fopt[@]}) + IFS=':'; fopt=("${fb}"); fopt=("${fopt[@]}") fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}" unset IFS if [ -z "${fport}" ]; then >&2 echo -e "Incorrect fallback format: $fb\n"; usage; exit 1; fi diff --git a/server-mtt.sh b/server-mtt.sh index 190096b..1522b28 100755 --- a/server-mtt.sh +++ b/server-mtt.sh @@ -99,7 +99,7 @@ inbound=$(echo $inbound| jq -c --arg fullchain "${fullchain}" --arg prvkey "${pr # Fallback settings for fb in "${fallback[@]}" do - IFS=':'; fopt=(${fb}); fopt=(${fopt[@]}) + IFS=':'; fopt=("${fb}"); fopt=("${fopt[@]}") fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}" unset IFS if [ -z "${fport}" ]; then >&2 echo -e "Incorrect fallback format: $fb\n"; usage; exit 1; fi diff --git a/server-mwp.sh b/server-mwp.sh index 45e4db2..b093605 100755 --- a/server-mwp.sh +++ b/server-mwp.sh @@ -89,7 +89,7 @@ inbound=$(echo $inbound| jq -c '.streamSettings += {"security":"none"}') # Fallback settings for fb in "${fallback[@]}" do - IFS=':'; fopt=(${fb}); fopt=(${fopt[@]}) + IFS=':'; fopt=("${fb}"); fopt=("${fopt[@]}") fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}" unset IFS if [ -z "${fport}" ]; then diff --git a/server-mwt.sh b/server-mwt.sh index 107672e..3c6a930 100755 --- a/server-mwt.sh +++ b/server-mwt.sh @@ -107,7 +107,7 @@ inbound=$(echo $inbound| jq -c --arg fullchain "${fullchain}" --arg prvkey "${pr # Fallback settings for fb in "${fallback[@]}" do - IFS=':'; fopt=(${fb}); fopt=(${fopt[@]}) + IFS=':'; fopt=("${fb}"); fopt=("${fopt[@]}") fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}" unset IFS if [ -z "${fport}" ]; then diff --git a/server-nginx.sh b/server-nginx.sh index fcebb51..51ed325 100755 --- a/server-nginx.sh +++ b/server-nginx.sh @@ -114,18 +114,18 @@ if [ -n "${STSVR}" ]; then done # Adding map.conf down to #XMAP_TAG tag - sed -i '/#XMAP_TAG/r /tmp/stmap.conf' $NGCONF + sed -i '/#XMAP_TAG/r /tmp/stmap.conf' "$NGCONF" # Adding ups.conf down to #XUPSTREAM_TAG tag - sed -i '/#XUPSTREAM_TAG/r /tmp/stups.conf' $NGCONF - sed -i "s/STPORT/${STPORT}/g" $NGCONF + sed -i '/#XUPSTREAM_TAG/r /tmp/stups.conf' "$NGCONF" + sed -i "s/STPORT/${STPORT}/g" "$NGCONF" # Adding "proxy_protocol=on" down to #STPROXY_PASS_TAG tag if [ -n "${STPROXY_PASS}" ]; then echo " proxy_protocol on;" >/tmp/stproxy.conf - sed -i '/#STPROXY_PASS_TAG/r /tmp/stproxy.conf' $NGCONF + sed -i '/#STPROXY_PASS_TAG/r /tmp/stproxy.conf' "$NGCONF" fi rm -rf /tmp/stmap.conf; rm -rf /tmp/stups.conf; rm -rf /tmp/stproxy.conf echo "Generated $NGCONF ====>" - cat $NGCONF + cat "$NGCONF" fi # Generating Nginx site server configurations. @@ -194,7 +194,7 @@ do sed -i 's/proxy_add_x_forwarded_for/proxy_protocol_addr/g' "${site_domain}.conf" fi echo "Generated /etc/nginx/conf.d/${site_domain}.conf ====>" - cat /etc/nginx/conf.d/${site_domain}.conf + cat "/etc/nginx/conf.d/${site_domain}.conf" done done @@ -239,19 +239,19 @@ do # Add tpl file content down to #LOCATION tag case "${xnetwork}" in ws|websocket) - sed -i '/#XLOCATION_TAG/r nginx-ws.tpl' ${xdomain}.conf + sed -i '/#XLOCATION_TAG/r nginx-ws.tpl' "${xdomain}.conf" ;; grpc) - sed -i '/#XLOCATION_TAG/r nginx-grpc.tpl' ${xdomain}.conf + sed -i '/#XLOCATION_TAG/r nginx-grpc.tpl' "${xdomain}.conf" ;; splt|proxy) - sed -i '/#XLOCATION_TAG/r nginx-proxy.tpl' ${xdomain}.conf + sed -i '/#XLOCATION_TAG/r nginx-proxy.tpl' "${xdomain}.conf" ;; esac ESC_LOCATION=$(printf '%s\n' "${xlocation}" | sed -e 's/[]\/$*.^[]/\\&/g') - sed -i "s/HOST/${xhost}/g" ${xdomain}.conf - sed -i "s/PORT/${xport}/g" ${xdomain}.conf - sed -i "s/WEBPATH/${ESC_LOCATION}/g" ${xdomain}.conf + sed -i "s/HOST/${xhost}/g" "${xdomain}.conf" + sed -i "s/PORT/${xport}/g" "${xdomain}.conf" + sed -i "s/WEBPATH/${ESC_LOCATION}/g" "${xdomain}.conf" # Applying proxy log format instead of main format when --ng-server proxy_pass was set if [ -n "${NGPROTOCOL}" ]; then sed -i '/access_log/s/main/proxy/' "${xdomain}.conf" @@ -259,7 +259,7 @@ do sed -i 's/proxy_add_x_forwarded_for/proxy_protocol_addr/g' "${xdomain}.conf" fi echo "Generated /etc/nginx/conf.d/${xdomain}.conf ====>" - cat /etc/nginx/conf.d/${xdomain}.conf + cat "/etc/nginx/conf.d/${xdomain}.conf" done done exit 0 diff --git a/server-ttt.sh b/server-ttt.sh index df04c1f..58d3451 100755 --- a/server-ttt.sh +++ b/server-ttt.sh @@ -99,7 +99,7 @@ inbound=$(echo $inbound| jq -c --arg fullchain "${fullchain}" --arg prvkey "${pr # Fallback settings for fb in "${fallback[@]}" do - IFS=':'; fopt=(${fb}); fopt=(${fopt[@]}) + IFS=':'; fopt=("${fb}"); fopt=("${fopt[@]}") fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}" unset IFS if [ -z "${fport}" ]; then >&2 echo -e "Incorrect fallback format: $fb\n"; usage; exit 1; fi diff --git a/server-twp.sh b/server-twp.sh index 2f47265..b0dcb96 100755 --- a/server-twp.sh +++ b/server-twp.sh @@ -89,7 +89,7 @@ inbound=$(echo $inbound| jq -c '.streamSettings += {"security":"none"}') # Fallback settings for fb in "${fallback[@]}" do - IFS=':'; fopt=(${fb}); fopt=(${fopt[@]}) + IFS=':'; fopt=("${fb}"); fopt=("${fopt[@]}") fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}" unset IFS if [ -z "${fport}" ]; then diff --git a/server-twt.sh b/server-twt.sh index adda0cf..1140014 100755 --- a/server-twt.sh +++ b/server-twt.sh @@ -107,7 +107,7 @@ inbound=$(echo $inbound| jq -c --arg fullchain "${fullchain}" --arg prvkey "${pr # Fallback settings for fb in "${fallback[@]}" do - IFS=':'; fopt=(${fb}); fopt=(${fopt[@]}) + IFS=':'; fopt=("${fb}"); fopt=("${fopt[@]}") fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}" unset IFS if [ -z "${fport}" ]; then