From 40bbac95ab4346932f1db389da6571e8e7f8af0f Mon Sep 17 00:00:00 2001 From: Whispering Wind <151555003+ReturnFI@users.noreply.github.com> Date: Fri, 28 Feb 2025 21:14:56 +0330 Subject: [PATCH] Add SUBPATH to normalsub.env if missing --- upgrade.sh | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/upgrade.sh b/upgrade.sh index 4fa7502..b5c291e 100644 --- a/upgrade.sh +++ b/upgrade.sh @@ -52,7 +52,7 @@ echo "Removing /etc/hysteria directory" rm -rf /etc/hysteria/ echo "Cloning Hysteria2 repository" -git clone https://github.com/ReturnFI/Hysteria2 /etc/hysteria +git clone -b beta https://github.com/ReturnFI/Hysteria2 /etc/hysteria echo "Downloading geosite.dat and geoip.dat" wget -O /etc/hysteria/geosite.dat https://raw.githubusercontent.com/Chocolate4U/Iran-v2ray-rules/release/geosite.dat >/dev/null 2>&1 @@ -101,6 +101,22 @@ if [[ -z "$IP6" ]]; then echo "IP6=${IP6:-}" >> "$CONFIG_ENV" fi +NORMALSUB_ENV="/etc/hysteria/core/scripts/normalsub/.env" + +if [[ -f "$NORMALSUB_ENV" ]]; then + echo "Checking if SUBPATH exists in $NORMALSUB_ENV..." + + if ! grep -q '^SUBPATH=' "$NORMALSUB_ENV"; then + echo "SUBPATH not found, generating a new one..." + SUBPATH=$(pwgen -s 32 1) + echo -e "\nSUBPATH=$SUBPATH" >> "$NORMALSUB_ENV" + else + echo "SUBPATH already exists, no changes made." + fi +else + echo "$NORMALSUB_ENV not found. Skipping SUBPATH check." +fi + echo "Setting ownership and permissions" chown hysteria:hysteria /etc/hysteria/ca.key /etc/hysteria/ca.crt chmod 640 /etc/hysteria/ca.key /etc/hysteria/ca.crt