fix: update existing https_port in Caddyfile instead of appending a duplicate key
Main / build (push) Waiting to run

This commit is contained in:
2026-07-08 00:57:36 +08:00
parent 88f9422f01
commit 5309bf254b
+5 -2
View File
@@ -161,8 +161,11 @@ update_caddyfile_fallback() {
# 2. Replace any site block headers explicit :443 with :4443
sed -i 's/:443[[:space:]]*{/:4443 {/g' $is_caddyfile
# 3. Add https_port 4443 to global block if not present
if [[ ! $(grep "https_port 4443" $is_caddyfile) ]]; then
# 3. Add or update https_port 4443 in global block
if [[ $(grep "https_port" $is_caddyfile) ]]; then
# Replace existing https_port with 4443
sed -i 's/https_port[[:space:]]\+[0-9]\+/https_port 4443/g' $is_caddyfile
else
# Find first { and insert https_port 4443 on the next line
sed -i '0,/^[[:space:]]*{[[:space:]]*$/s//{\n https_port 4443/' $is_caddyfile
fi