From c7535a3d8ee957efa5928d4020c05d8759be85d2 Mon Sep 17 00:00:00 2001 From: Whispering Wind <151555003+ReturnFI@users.noreply.github.com> Date: Mon, 1 Jul 2024 23:01:30 +0330 Subject: [PATCH] Function to uninstall WARP --- menu.sh | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/menu.sh b/menu.sh index 3db769c..b583350 100644 --- a/menu.sh +++ b/menu.sh @@ -249,6 +249,40 @@ install_warp() { fi } +# Function to uninstall WARP and update config.json +uninstall_warp() { + 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 + 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" ' + .acl.inline |= map( + if . == "warps(all)" or . == "warps(geoip:google)" or . == "warps(geosite:google)" or . == "warps(geosite:netflix)" or . == "warps(geosite:spotify)" or . == "warps(geosite:openai)" or . == "warps(geoip:openai)" then + "direct" + elif . == "warps(geosite:ir)" then + "reject(geosite:ir)" + elif . == "warps(geoip:ir)" then + "reject(geoip:ir)" + else + . + 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 + + restart_hysteria_service >/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." + fi + else + echo "WARP is not active. Skipping uninstallation." + fi +} + # Function to configure WARP configure_warp() { # Check if wg-quick@wgcf.service is active @@ -256,7 +290,7 @@ configure_warp() { echo "WARP is not active. Please Install WARP before configuring." return fi - + if [ -f "/etc/hysteria/config.json" ]; then # Check the current status of WARP configurations warp_all_status=$(jq -r 'if .acl.inline | index("warps(all)") then "WARP active" else "Direct" end' /etc/hysteria/config.json)