8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
toggle-vpn.sh
#!/bin/bash # This script toggles VPN settings in docker-compose.yml # It enables or disables VPN-related configuration for services COMPOSE_FILE="docker-compose.yml" BACKUP_FILE="docker-compose.yml.bak" # Function to check if VPN is enabled check_vpn_status() { # Look for uncommented network_mode in qbittorrent section if grep -q "^\s*network_mode: service:vpn" "$COMPOSE_FILE"; then echo "VPN is currently ENABLED" return 0 else echo "VPN is currently DISABLED" return 1 fi } # Function to make a backup of docker-compose.yml backup_compose() { cp "$COMPOSE_FILE" "$BACKUP_FILE" echo "Created backup at $BACKUP_FILE" } # Function to enable VPN enable_vpn() { # Make a backup first backup_compose # Use awk to process the file awk ' # VPN section ports /# Uncomment\/enable below ports if VPN is used\/enabled/ { print $0; getline; sub(/^ # /, " "); print; while (getline && !/restart:/) { sub(/^ # /, " "); print; } print; next; } # qBittorrent section /# Unomment below if vpn is enabled/ { print $0; while (getline && !/condition: service_healthy/) { sub(/^ # /, " "); sub(/^ # /, " "); sub(/^ # /, " "); print; } sub(/^ # /, " "); print; next; } # qBittorrent network_mode /# network_mode: service:vpn/ { sub(/^ # /, " "); print; next; } # Comment qBittorrent networks /networks:.*# Comment this line if vpn is enabled/ { sub(/^ /, " # "); print; next; } # Comment qBittorrent media-stack-net /- media-stack-net.*# Comment this line if vpn is enabled/ { sub(/^ /, " # "); print; next; } # Comment qBittorrent ports /## Comment\/Disable below ports if VPN is enabled/ { print $0; while (getline && !/restart:/) { sub(/^ /, " # "); sub(/^ /, " # "); print; } print; next; } # Prowlarr section /# Uncomment below if vpn is enabled/ { print $0; while (getline && !/condition: service_healthy/) { sub(/^ # /, " "); sub(/^ # /, " "); sub(/^ # /, " "); print; } sub(/^ # /, " "); print; next; } # Prowlarr network_mode /# network_mode: service:vpn # Uncomment this line if vpn is enabled/ { sub(/^ # /, " "); print; next; } # Comment Prowlarr networks /networks:.*# Comment this line if vpn is enabled/ { sub(/^ /, " # "); print; next; } # Comment Prowlarr ports /# Comment below ports if VPN is enabled/ { print $0; while (getline && !/restart:/) { sub(/^ /, " # "); sub(/^ /, " # "); print; } print; next; } # Radarr and Sonarr networks /- media-stack-net.*# Comment this line if VPN is enabled/ { sub(/^ /, " # "); print; next; } # Uncomment Radarr and Sonarr ipv4_address /## Uncomment below lines if VPN is enabled/ { print $0; while (getline && /^ #/) { sub(/^ # /, " "); print; } print $0; next; } # Default action: print the line { print } ' "$COMPOSE_FILE" > "$COMPOSE_FILE.tmp" && mv "$COMPOSE_FILE.tmp" "$COMPOSE_FILE" echo "✅ VPN settings enabled successfully" } # Function to disable VPN disable_vpn() { # Make a backup first backup_compose # Use awk to process the file awk ' # VPN section ports /# Uncomment\/enable below ports if VPN is used\/enabled/ { print $0; getline; sub(/^ /, " # "); print; while (getline && !/restart:/) { sub(/^ /, " # "); print; } print; next; } # qBittorrent section /Unomment below if vpn is enabled/ { print $0; while (getline && !/condition: service_healthy/) { sub(/^ /, " # "); sub(/^ /, " # "); print; } sub(/^ /, " # "); print; next; } # qBittorrent network_mode /network_mode: service:vpn/ { sub(/^ /, " # "); print; next; } # Uncomment qBittorrent networks /# networks:.*# Comment this line if vpn is enabled/ { sub(/^ # /, " "); print; next; } # Uncomment qBittorrent media-stack-net /# - media-stack-net.*# Comment this line if vpn is enabled/ { sub(/^ # /, " "); print; next; } # Uncomment qBittorrent ports /## Comment\/Disable below ports if VPN is enabled/ { print $0; while (getline && !/restart:/) { sub(/^ # /, " "); sub(/^ # /, " "); print; } print; next; } # Prowlarr section /Uncomment below if vpn is enabled/ { print $0; while (getline && !/condition: service_healthy/) { sub(/^ /, " # "); sub(/^ /, " # "); print; } sub(/^ /, " # "); print; next; } # Prowlarr network_mode /network_mode: service:vpn # Uncomment this line if vp 898A n is enabled/ { sub(/^ /, " # "); print; next; } # Uncomment Prowlarr networks /# networks:.*# Comment this line if vpn is enabled/ { sub(/^ # /, " "); print; next; } # Uncomment Prowlarr ports /Comment below ports if VPN is enabled/ { print $0; while (getline && !/restart:/) { sub(/^ # /, " "); sub(/^ # /, " "); print; } print; next; } # Radarr and Sonarr networks /# - media-stack-net.*# Comment this line if VPN is enabled/ { sub(/^ # /, " "); print; next; } # Comment Radarr and Sonarr ipv4_address /media-stack-net:/ { sub(/^ /, " # "); print; getline; sub(/^ /, " # "); print; next; } # Default action: print the line { print } ' "$COMPOSE_FILE" > "$COMPOSE_FILE.tmp" && mv "$COMPOSE_FILE.tmp" "$COMPOSE_FILE" echo "✅ VPN settings disabled successfully" } if [[ "$1" == "on" ]]; then echo "🔐 Enabling VPN settings..." enable_vpn elif [[ "$1" == "off" ]]; then echo "🔓 Disabling VPN settings..." disable_vpn elif [[ "$1" == "status" ]]; then check_vpn_status else echo "Usage: $0 [on|off|status]" echo " on - Enable VPN settings" echo " off - Disable VPN settings" echo " status - Check current VPN status" exit 1 fi
UPDATE: Updated this. far more solid
The text was updated successfully, but these errors were encountered:
Thanks for the suggestion. I will check if this will be feasible
Sorry, something went wrong.
No branches or pull requests
Uh oh!
There was an error while loading. Please reload this page.
toggle-vpn.sh
UPDATE: Updated this. far more solid
The text was updated successfully, but these errors were encountered: