Created
February 10, 2026 19:47
-
-
Save pedro0311/674f2e19691106417a989a43bf27b0a4 to your computer and use it in GitHub Desktop.
Script for migrating OpenVPN variables in NVRAM for FreshTomato. Converts old variable names to new ones used in version 2026.1+
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # | |
| # Script for migrating OpenVPN variables in NVRAM for FreshTomato. | |
| # Converts old variable names to new ones used in version 2026.1+ | |
| # | |
| # Copyright 2026 pedro | |
| # https://freshtomato.org/ | |
| # | |
| # Short HOWTO: | |
| # | |
| # - This script is only suitable for migration when you are currently | |
| # using a FreshTomato version before 2026.1! | |
| # | |
| # 1. Important! Stop ALL OpenVPN Client and Server instances on the router. | |
| # Do not change anything in your OVPN settings | |
| # 2. Enable Samba on your router (if not already done) to be able to copy | |
| # this file to it | |
| # 3. Copy this script to (for example) /tmp/migrate.ovpn.sh | |
| # 4. Open a shell OR you can as well do it in GUI -> Tools -> System Commands | |
| # 5. Run: chmod +x /tmp/migrate.ovpn.sh | |
| # 6. Run script: /tmp/migrate.ovpn.sh | |
| # 7. Update your router to version 2026.1+ | |
| # 8. The first time you open an OpenVPN Client or Server page in browser, | |
| # use Ctrl+F5 or Ctrl+Shift+R | |
| # 9. Done | |
| # | |
| echo "Starting OpenVPN variable migration in NVRAM..." | |
| migrate_var() { | |
| local old_name="$1" | |
| local new_name="$2" | |
| local value=$(nvram get "$old_name") | |
| echo "Migrating: $old_name -> $new_name" | |
| nvram set "$new_name=$value" | |
| nvram unset "$old_name" | |
| } | |
| echo "Migrating VPN clients (vpn_client -> vpnc)..." | |
| for i in 1 2 3; do | |
| for var in $(nvram show 2>/dev/null | grep "^vpn_client${i}_" | cut -d'=' -f1); do | |
| suffix=$(echo "$var" | sed "s/^vpn_client${i}_//") | |
| new_var="vpnc${i}_${suffix}" | |
| migrate_var "$var" "$new_var" | |
| done | |
| done | |
| echo "Migrating VPN servers (vpn_server -> vpns)..." | |
| for i in 1 2; do | |
| for var in $(nvram show 2>/dev/null | grep "^vpn_server${i}_" | cut -d'=' -f1); do | |
| suffix=$(echo "$var" | sed "s/^vpn_server${i}_//") | |
| new_var="vpns${i}_${suffix}" | |
| migrate_var "$var" "$new_var" | |
| done | |
| done | |
| echo "Migrating global variables..." | |
| migrate_var "vpn_server_eas" "vpns_eas" | |
| migrate_var "vpn_server_dns" "vpns_dns" | |
| migrate_var "vpn_client_eas" "vpnc_eas" | |
| echo "Committing changes to NVRAM..." | |
| nvram commit | |
| echo "Migration completed successfully!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment