mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-04 16:34:52 +03:00
825f3c77a5
Discover eligible local IPv6 addresses with explicit interactive consent and preserve unattended IPv4 defaults. Embed shared helpers in both standalone scripts, verify dual-stack listeners and IP SAN/key identity, and preserve live certificates and prior panel state on failure. Add rootless regression coverage, CI checks, and SSL documentation.
30 lines
1.0 KiB
Bash
30 lines
1.0 KiB
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
ROOT=$(cd "$(dirname "$0")/.." && pwd)
|
|
mode='write'
|
|
if [[ "${1:-}" == --check ]]; then mode=check; shift; fi
|
|
targets=("$@")
|
|
if (($# == 0)); then targets=(x-ui.sh install.sh); fi
|
|
temp=$(mktemp)
|
|
trap 'rm -f "$temp"' EXIT
|
|
for target in "${targets[@]}"; do
|
|
case "$target" in x-ui.sh|install.sh) ;; *) printf 'Unknown standalone script: %s\n' "$target" >&2; exit 1;; esac
|
|
awk -v helper="$ROOT/scripts/lib/ip-ssl.sh" '
|
|
{sub(/\r$/, "")}
|
|
/^# BEGIN GENERATED IP SSL HELPERS$/ {
|
|
found++; print; while ((getline line < helper) > 0) print line; close(helper); block=1; next
|
|
}
|
|
/^# END GENERATED IP SSL HELPERS$/ {block=0}
|
|
!block {print}
|
|
END {if(found!=1 || block) exit 1}
|
|
' "$ROOT/$target" > "$temp"
|
|
if [[ "$mode" == check ]]; then
|
|
if ! cmp -s "$temp" "$ROOT/$target"; then
|
|
printf 'Stale IP SSL helpers in %s; run bash scripts/sync-ip-ssl-helpers.sh\n' "$target" >&2
|
|
exit 1
|
|
fi
|
|
else
|
|
cat "$temp" > "$ROOT/$target"
|
|
fi
|
|
done
|