diff options
author | Christian Poessinger <christian@poessinger.com> | 2020-11-03 19:56:20 +0100 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2020-11-03 19:56:20 +0100 |
commit | 620271eca13b3535472243f98bca766ed6ec19ed (patch) | |
tree | fe34254922c1deb9521f20b3ab4a578721a34813 /src/migration-scripts/interfaces/13-to-14 | |
parent | 0ec4ad03abb952fbc817df4bbaaf4ab05fbc9753 (diff) | |
parent | 01e3d935a34f38e48364724da1cad7cbbb18576e (diff) | |
download | vyos-1x-620271eca13b3535472243f98bca766ed6ec19ed.tar.gz vyos-1x-620271eca13b3535472243f98bca766ed6ec19ed.zip |
Merge branch 'wifi-wpa3' of github.com:c-po/vyos-1x into current
* 'wifi-wpa3' of github.com:c-po/vyos-1x:
wireless: T3042: move wifi-regulatory-domain into individual interface definition
wireless: T2653: reset wireless priority to crux state
wireless: T3034: add WPA3 support
wireless: T3043: rename "wpa mode both" to "wpa+wpa2"
ifconfig: T2985: fix wireless-bridge creation
Diffstat (limited to 'src/migration-scripts/interfaces/13-to-14')
-rwxr-xr-x | src/migration-scripts/interfaces/13-to-14 | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/migration-scripts/interfaces/13-to-14 b/src/migration-scripts/interfaces/13-to-14 new file mode 100755 index 000000000..fc6d7f443 --- /dev/null +++ b/src/migration-scripts/interfaces/13-to-14 @@ -0,0 +1,61 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2020 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/>. + +# T3043: rename Wireless interface security mode 'both' to 'wpa+wpa2' +# T3043: move "system wifi-regulatory-domain" to indicidual wireless interface + +import os + +from sys import exit, argv +from vyos.configtree import ConfigTree + +if __name__ == '__main__': + if (len(argv) < 1): + 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 = ['interfaces', 'wireless'] + if not config.exists(base): + # Nothing to do + exit(0) + + country_code = '' + cc_cli = ['system', 'wifi-regulatory-domain'] + if config.exists(cc_cli): + country_code = config.return_value(cc_cli) + config.delete(cc_cli) + + for wifi in config.list_nodes(base): + sec_mode = base + [wifi, 'security', 'wpa', 'mode'] + if config.exists(sec_mode): + mode = config.return_value(sec_mode) + if mode == 'both': + config.set(sec_mode, value='wpa+wpa2', replace=True) + + if country_code: + config.set(base + [wifi, 'country-code'], value=country_code) + + 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) |