Add SUBPATH to normalsub.env if missing

This commit is contained in:
Whispering Wind
2025-02-28 21:14:56 +03:30
committed by GitHub
parent 3a2b769234
commit 40bbac95ab

View File

@ -52,7 +52,7 @@ echo "Removing /etc/hysteria directory"
rm -rf /etc/hysteria/ rm -rf /etc/hysteria/
echo "Cloning Hysteria2 repository" 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" 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 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" echo "IP6=${IP6:-}" >> "$CONFIG_ENV"
fi 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" echo "Setting ownership and permissions"
chown hysteria:hysteria /etc/hysteria/ca.key /etc/hysteria/ca.crt chown hysteria:hysteria /etc/hysteria/ca.key /etc/hysteria/ca.crt
chmod 640 /etc/hysteria/ca.key /etc/hysteria/ca.crt chmod 640 /etc/hysteria/ca.key /etc/hysteria/ca.crt