diff --git a/upgrade.sh b/upgrade.sh index 37742f3..cca57d7 100644 --- a/upgrade.sh +++ b/upgrade.sh @@ -35,13 +35,28 @@ for FILE in "${FILES[@]}"; do cp "$TEMP_DIR/$FILE" "$FILE" done -if [ ! -f /etc/hysteria/.configs.env ]; then - echo ".configs.env not found, creating it with default SNI=bts.com" - echo "SNI=bts.com" > /etc/hysteria/.configs.env +CONFIG_ENV="/etc/hysteria/.configs.env" +if [ ! -f "$CONFIG_ENV" ]; then + echo ".configs.env not found, creating it with default SNI=bts.com and IPs." + echo "SNI=bts.com" > "$CONFIG_ENV" else echo ".configs.env already exists." fi +export $(grep -v '^#' "$CONFIG_ENV" | xargs 2>/dev/null) + +if [[ -z "$IP4" ]]; then + echo "IP4 not found, fetching from ip.gs..." + IP4=$(curl -s -4 ip.gs || echo "") + echo "IP4=${IP4:-}" >> "$CONFIG_ENV" +fi + +if [[ -z "$IP6" ]]; then + echo "IP6 not found, fetching from ip.gs..." + IP6=$(curl -s -6 ip.gs || echo "") + echo "IP6=${IP6:-}" >> "$CONFIG_ENV" +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