set rights in install and a .conf a import Tunnel Filedialog Part 1 /home when open

This commit is contained in:
2024-09-18 22:33:04 +02:00
parent 94558d32a9
commit 5c06db3681
6 changed files with 49 additions and 14 deletions

View File

@ -181,8 +181,10 @@ class ImportTunnel:
def wg_import_select(self):
try:
filepath = filedialog.askopenfilename(initialdir=Path('/home/*/'), title='Select Wireguard config File',
filepath = filedialog.askopenfilename(initialdir=Path('/home/'), title='Select Wireguard config '
'File',
filetypes=[('WG config files', '*.conf')], )
os.chmod(filepath, 0o600)
with open(filepath, 'r') as file:
read = file.read()
path_split = filepath.split('/')
@ -197,8 +199,9 @@ class ImportTunnel:
if self.a != '':
check_call(['nmcli', 'connection', 'down', TunnelActiv.active()])
ShowAddress.label_empty(self)
check_call(['nmcli', 'connection', 'import', 'type', 'wireguard', 'file', 'etc', '/wire_py',
check_call(['nmcli', 'connection', 'import', 'type', 'wireguard', 'file', Path('/etc') / 'wire_py' /
path_split])
else:
shutil.copy(filepath, Path('/etc/wire_py/'))
if self.a != '':
@ -221,6 +224,7 @@ class ImportTunnel:
ShowAddress.init_and_report(self, data)
ShowAddress.show_data(self)
check_call(['nmcli', 'con', 'mod', self.a, 'connection.autoconnect', 'no'])
if 'PrivateKey = ' not in read:
msg_window()
except EOFError:
@ -295,7 +299,7 @@ class ExportTunnels:
tl = ListTunnels.tl_list()
try:
if len(tl) != 0:
wg_tar = Path('/home/*/') / now_datetime
wg_tar = Path(f'/{home}/'), now_datetime
p_to_conf = Path('/etc/wire_py/')
shutil.make_archive(wg_tar, 'zip', p_to_conf)
#if zip_full != 0: