diff options
author | Christian Breunig <christian@breunig.cc> | 2024-01-03 18:58:17 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-03 18:58:17 +0100 |
commit | 1cc70ce273cbddb5ea9eb4148808c6c2aaf3d28f (patch) | |
tree | 3a175bdd292e31fc91f2215dd4aaa4b5f01c39a1 /src/migration-scripts | |
parent | 4f56a3df61cd66234fa2fda254869c17eaf1eca6 (diff) | |
parent | df2db15dde6ef928556a4e632bce3222428c6486 (diff) | |
download | vyos-1x-1cc70ce273cbddb5ea9eb4148808c6c2aaf3d28f.tar.gz vyos-1x-1cc70ce273cbddb5ea9eb4148808c6c2aaf3d28f.zip |
Merge pull request #2719 from c-po/sagitta-backports-accel-ppp
Backports for Accel-PPP based serviced T5801, T5842 and T5688
Diffstat (limited to 'src/migration-scripts')
-rwxr-xr-x | src/migration-scripts/l2tp/4-to-5 | 20 | ||||
-rwxr-xr-x | src/migration-scripts/l2tp/5-to-6 | 110 | ||||
-rwxr-xr-x | src/migration-scripts/pppoe-server/6-to-7 | 21 | ||||
-rwxr-xr-x | src/migration-scripts/sstp/4-to-5 | 19 |
4 files changed, 156 insertions, 14 deletions
diff --git a/src/migration-scripts/l2tp/4-to-5 b/src/migration-scripts/l2tp/4-to-5 index fe8ab357e..496dc83d6 100755 --- a/src/migration-scripts/l2tp/4-to-5 +++ b/src/migration-scripts/l2tp/4-to-5 @@ -45,12 +45,22 @@ if not config.exists(pool_base): exit(0) default_pool = '' range_pool_name = 'default-range-pool' -subnet_pool_name = 'default-subnet-pool' +subnet_base_name = 'default-subnet-pool' +number = 1 +subnet_pool_name = f'{subnet_base_name}-{number}' +prev_subnet_pool = subnet_pool_name if config.exists(pool_base + ['subnet']): - subnet = config.return_value(pool_base + ['subnet']) - config.delete(pool_base + ['subnet']) - config.set(pool_base + [subnet_pool_name, 'range'], value=subnet) default_pool = subnet_pool_name + for subnet in config.return_values(pool_base + ['subnet']): + config.set(pool_base + [subnet_pool_name, 'range'], value=subnet) + if prev_subnet_pool != subnet_pool_name: + config.set(pool_base + [prev_subnet_pool, 'next-pool'], + value=subnet_pool_name) + prev_subnet_pool = subnet_pool_name + number += 1 + subnet_pool_name = f'{subnet_base_name}-{number}' + + config.delete(pool_base + ['subnet']) if config.exists(pool_base + ['start']) and config.exists(pool_base + ['stop']): start_ip = config.return_value(pool_base + ['start']) @@ -61,7 +71,7 @@ if config.exists(pool_base + ['start']) and config.exists(pool_base + ['stop']): config.set(pool_base + [range_pool_name, 'range'], value=ip_range) if default_pool: config.set(pool_base + [range_pool_name, 'next-pool'], - value=subnet_pool_name) + value=default_pool) default_pool = range_pool_name if default_pool: diff --git a/src/migration-scripts/l2tp/5-to-6 b/src/migration-scripts/l2tp/5-to-6 new file mode 100755 index 000000000..ca0b13dcc --- /dev/null +++ b/src/migration-scripts/l2tp/5-to-6 @@ -0,0 +1,110 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2023 VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 or later as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + + +import os + +from sys import argv +from sys import exit +from vyos.configtree import ConfigTree + + +if len(argv) < 2: + print("Must specify file name!") + exit(1) + +file_name = argv[1] + +with open(file_name, 'r') as f: + config_file = f.read() + +config = ConfigTree(config_file) +base = ['vpn', 'l2tp', 'remote-access'] +if not config.exists(base): + exit(0) + +#migrate idle to ppp option lcp-echo-timeout +idle_path = base + ['idle'] +if config.exists(idle_path): + config.set(base + ['ppp-options', 'lcp-echo-timeout'], + value=config.return_value(idle_path)) + config.delete(idle_path) + +#migrate mppe from authentication to ppp-otion +mppe_path = base + ['authentication', 'mppe'] +if config.exists(mppe_path): + config.set(base + ['ppp-options', 'mppe'], + value=config.return_value(mppe_path)) + config.delete(mppe_path) + +#migrate require to protocol +require_path = base + ['authentication', 'require'] +if config.exists(require_path): + protocols = list(config.return_values(require_path)) + for protocol in protocols: + config.set(base + ['authentication', 'protocols'], value=protocol, + replace=False) + config.delete(require_path) +else: + config.set(base + ['authentication', 'protocols'], value='mschap-v2') + +#migrate default gateway if not exist +if not config.exists(base + ['gateway-address']): + config.set(base + ['gateway-address'], value='10.255.255.0') + +#migrate authentication radius timeout +rad_timeout_path = base + ['authentication', 'radius', 'timeout'] +if config.exists(rad_timeout_path): + if int(config.return_value(rad_timeout_path)) > 60: + config.set(rad_timeout_path, value=60) + +#migrate authentication radius acct timeout +rad_acct_timeout_path = base + ['authentication', 'radius', 'acct-timeout'] +if config.exists(rad_acct_timeout_path): + if int(config.return_value(rad_acct_timeout_path)) > 60: + config.set(rad_acct_timeout_path,value=60) + +#migrate authentication radius max-try +rad_max_try_path = base + ['authentication', 'radius', 'max-try'] +if config.exists(rad_max_try_path): + if int(config.return_value(rad_max_try_path)) > 20: + config.set(rad_max_try_path, value=20) + +#migrate dae-server to dynamic-author +dae_path_old = base + ['authentication', 'radius', 'dae-server'] +dae_path_new = base + ['authentication', 'radius', 'dynamic-author'] + +if config.exists(dae_path_old + ['ip-address']): + config.set(dae_path_new + ['server'], + value=config.return_value(dae_path_old + ['ip-address'])) + +if config.exists(dae_path_old + ['port']): + config.set(dae_path_new + ['port'], + value=config.return_value(dae_path_old + ['port'])) + +if config.exists(dae_path_old + ['secret']): + config.set(dae_path_new + ['key'], + value=config.return_value(dae_path_old + ['secret'])) + +if config.exists(dae_path_old): + config.delete(dae_path_old) + +try: + with open(file_name, 'w') as f: + f.write(config.to_string()) +except OSError as e: + print("Failed to save the modified config: {}".format(e)) + exit(1) diff --git a/src/migration-scripts/pppoe-server/6-to-7 b/src/migration-scripts/pppoe-server/6-to-7 index 34996d8fe..d856c1f34 100755 --- a/src/migration-scripts/pppoe-server/6-to-7 +++ b/src/migration-scripts/pppoe-server/6-to-7 @@ -50,13 +50,24 @@ if not config.exists(pool_base): exit(0) default_pool = '' range_pool_name = 'default-range-pool' -subnet_pool_name = 'default-subnet-pool' + +subnet_base_name = 'default-subnet-pool' +number = 1 +subnet_pool_name = f'{subnet_base_name}-{number}' +prev_subnet_pool = subnet_pool_name #Default nameless pools migrations if config.exists(pool_base + ['subnet']): - subnet = config.return_value(pool_base + ['subnet']) - config.delete(pool_base + ['subnet']) - config.set(pool_base + [subnet_pool_name, 'range'], value=subnet) default_pool = subnet_pool_name + for subnet in config.return_values(pool_base + ['subnet']): + config.set(pool_base + [subnet_pool_name, 'range'], value=subnet) + if prev_subnet_pool != subnet_pool_name: + config.set(pool_base + [prev_subnet_pool, 'next-pool'], + value=subnet_pool_name) + prev_subnet_pool = subnet_pool_name + number += 1 + subnet_pool_name = f'{subnet_base_name}-{number}' + + config.delete(pool_base + ['subnet']) if config.exists(pool_base + ['start']) and config.exists(pool_base + ['stop']): start_ip = config.return_value(pool_base + ['start']) @@ -67,7 +78,7 @@ if config.exists(pool_base + ['start']) and config.exists(pool_base + ['stop']): config.set(pool_base + [range_pool_name, 'range'], value=ip_range) if default_pool: config.set(pool_base + [range_pool_name, 'next-pool'], - value=subnet_pool_name) + value=default_pool) default_pool = range_pool_name gateway = '' diff --git a/src/migration-scripts/sstp/4-to-5 b/src/migration-scripts/sstp/4-to-5 index 0f332e04f..3a86c79ec 100755 --- a/src/migration-scripts/sstp/4-to-5 +++ b/src/migration-scripts/sstp/4-to-5 @@ -43,12 +43,23 @@ if not config.exists(base): if not config.exists(pool_base): exit(0) -subnet_pool_name = 'default-subnet-pool' +subnet_base_name = 'default-subnet-pool' +number = 1 +subnet_pool_name = f'{subnet_base_name}-{number}' +prev_subnet_pool = subnet_pool_name if config.exists(pool_base + ['subnet']): - subnet = config.return_value(pool_base + ['subnet']) + default_pool = subnet_pool_name + for subnet in config.return_values(pool_base + ['subnet']): + config.set(pool_base + [subnet_pool_name, 'range'], value=subnet) + if prev_subnet_pool != subnet_pool_name: + config.set(pool_base + [prev_subnet_pool, 'next-pool'], + value=subnet_pool_name) + prev_subnet_pool = subnet_pool_name + number += 1 + subnet_pool_name = f'{subnet_base_name}-{number}' + config.delete(pool_base + ['subnet']) - config.set(pool_base + [subnet_pool_name, 'range'], value=subnet) - config.set(base + ['default-pool'], value=subnet_pool_name) + config.set(base + ['default-pool'], value=default_pool) # format as tag node config.set_tag(pool_base) |