Page Menu
Home
VyOS Platform
Search
Configure Global Search
Log In
Files
F119903506
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/src/migration-scripts/interfaces/22-to-23 b/src/migration-scripts/interfaces/22-to-23
index c52a26908..c6dc32baf 100755
--- a/src/migration-scripts/interfaces/22-to-23
+++ b/src/migration-scripts/interfaces/22-to-23
@@ -1,66 +1,64 @@
#!/usr/bin/env python3
#
# Copyright (C) 2021 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/>.
-# A VTI interface also requires an IPSec configuration - VyOS 1.2 supported
-# having a VTI interface in the CLI but no IPSec configuration - drop VTI
-# configuration if this is the case for VyOS 1.4
+# Migrate Wireguard to store keys in CLI
import os
import sys
from vyos.configtree import ConfigTree
if __name__ == '__main__':
if (len(sys.argv) < 1):
print("Must specify file name!")
sys.exit(1)
file_name = sys.argv[1]
with open(file_name, 'r') as f:
config_file = f.read()
config = ConfigTree(config_file)
base = ['interfaces', 'wireguard']
if not config.exists(base):
# Nothing to do
sys.exit(0)
for interface in config.list_nodes(base):
private_key_path = base + [interface, 'private-key']
key_file = 'default'
if config.exists(private_key_path):
key_file = config.return_value(private_key_path)
full_key_path = f'/config/auth/wireguard/{key_file}/private.key'
if not os.path.exists(full_key_path):
print(f'Could not find wireguard private key for migration on interface "{interface}"')
continue
with open(full_key_path, 'r') as f:
key_data = f.read().strip()
config.set(private_key_path, value=key_data)
for peer in config.list_nodes(base + [interface, 'peer']):
config.rename(base + [interface, 'peer', peer, 'pubkey'], 'public-key')
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))
sys.exit(1)
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Thu, Nov 26, 9:25 PM (13 h, 20 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4957855
Default Alt Text
(2 KB)
Attached To
Mode
rVYOSONEX vyos-1x
Attached
Detach File
Event Timeline
Log In to Comment