Function to uninstall WARP
This commit is contained in:
36
menu.sh
36
menu.sh
@ -249,6 +249,40 @@ install_warp() {
|
|||||||
fi
|
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
|
# Function to configure WARP
|
||||||
configure_warp() {
|
configure_warp() {
|
||||||
# Check if wg-quick@wgcf.service is active
|
# Check if wg-quick@wgcf.service is active
|
||||||
@ -256,7 +290,7 @@ configure_warp() {
|
|||||||
echo "WARP is not active. Please Install WARP before configuring."
|
echo "WARP is not active. Please Install WARP before configuring."
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f "/etc/hysteria/config.json" ]; then
|
if [ -f "/etc/hysteria/config.json" ]; then
|
||||||
# Check the current status of WARP configurations
|
# 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)
|
warp_all_status=$(jq -r 'if .acl.inline | index("warps(all)") then "WARP active" else "Direct" end' /etc/hysteria/config.json)
|
||||||
|
|||||||
Reference in New Issue
Block a user