Refactor paths

This commit is contained in:
Sarina
2024-07-22 15:46:16 +03:30
parent 1985a171e9
commit ba9ff87b8c
11 changed files with 133 additions and 96 deletions

View File

@ -1,8 +1,15 @@
#!/bin/bash
# Source the path.sh script to load the CONFIG_FILE and CLI_PATH variables
source /etc/hysteria/core/scripts/path.sh
# Check if WARP is active
if systemctl is-active --quiet wg-quick@wgcf.service; then
echo "Uninstalling WARP..."
bash <(curl -fsSL git.io/warp.sh) dwg
if [ -f "/etc/hysteria/config.json" ]; then
# Check if the config file exists
if [ -f "$CONFIG_FILE" ]; then
default_config='["reject(geosite:ir)", "reject(geoip:ir)", "reject(geosite:category-ads-all)", "reject(geoip:private)", "reject(geosite:google@ads)"]'
jq --argjson default_config "$default_config" '
@ -17,14 +24,15 @@ if systemctl is-active --quiet wg-quick@wgcf.service; then
.
end
) | .acl.inline |= ($default_config + (. - $default_config | map(select(. != "direct"))))
' /etc/hysteria/config.json > /etc/hysteria/config_temp.json && mv /etc/hysteria/config_temp.json /etc/hysteria/config.json
jq 'del(.outbounds[] | select(.name == "warps" and .type == "direct" and .direct.mode == 4 and .direct.bindDevice == "wgcf"))' /etc/hysteria/config.json > /etc/hysteria/config_temp.json && mv /etc/hysteria/config_temp.json /etc/hysteria/config.json
' "$CONFIG_FILE" > /etc/hysteria/config_temp.json && mv /etc/hysteria/config_temp.json "$CONFIG_FILE"
python3 /etc/hysteria/core/cli.py restart-hysteria2 > /dev/null 2>&1
jq 'del(.outbounds[] | select(.name == "warps" and .type == "direct" and .direct.mode == 4 and .direct.bindDevice == "wgcf"))' "$CONFIG_FILE" > /etc/hysteria/config_temp.json && mv /etc/hysteria/config_temp.json "$CONFIG_FILE"
python3 "$CLI_PATH" restart-hysteria2 > /dev/null 2>&1
echo "WARP uninstalled and configurations reset to default."
else
echo "${red}Error:${NC} Config file /etc/hysteria/config.json not found."
echo "Error: Config file $CONFIG_FILE not found."
fi
else
echo "WARP is not active. Skipping uninstallation."
fi
fi