diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 65f8540..3d2ae66 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,11 +4,9 @@
-
-
-
-
+
+
@@ -342,7 +340,15 @@
1725746027132
-
+
+
+ 1725820337669
+
+
+
+ 1725820337669
+
+
@@ -370,7 +376,6 @@
-
@@ -395,6 +400,7 @@
-
+
+
\ No newline at end of file
diff --git a/install.py b/install.py
index 1b55074..6b80cb8 100755
--- a/install.py
+++ b/install.py
@@ -1,10 +1,30 @@
#!/usr/bin/python3
import os
from pathlib import Path
+import subprocess
+from getpass import getpass
+startfile = ['#!/usr/bin/python3',
+ 'from subprocess import check_call', '\n',
+
+ 'path_to_file = ', '\n',
+
+ 'with open(path_to_file, 'r') as file:',
+ ' for line in file.readlines(): ',
+ ' a_con = line[5:] ',
+ "check_call(['nmcli', 'connection', 'up', a_con])",
+ 'file.close()']
home = Path.home()
# for services file in /lib/systemd/system/
path_for_a_con = home / '.config/wire_py/wg_py'
+# replace in startfile
+startfile[3] = 'path_to_file = ' "'" + str(path_for_a_con) + "'"
+
+with open('start_wg.py', 'w') as file_for_a_con:
+ for line in startfile:
+ file_for_a_con.write(line + '\n')
+file_for_a_con.close()
+
# create dir in home
mkdir = home / '.config/wire_py'
os.makedirs(mkdir, exist_ok=True)
@@ -12,6 +32,15 @@ os.makedirs(mkdir, exist_ok=True)
with open(mkdir / 'wg_py', 'w+') as file:
if 'true' not in file:
file.write('false')
-
file.close()
+# Prompt the user for the sudo password
+sudo_password = getpass('Enter sudo password: ')
+#def cp_files():
+
+# Define the command to run the Python script with sudo
+#command = ['sudo', '-S', 'python3', 'script.py']
+
+# Run the command as a subprocess, passing the sudo password
+#subprocess.run(command, input=sudo_password.encode(), check=True)
+
diff --git a/main.py b/main.py
index e3374dc..48f56ea 100755
--- a/main.py
+++ b/main.py
@@ -163,22 +163,23 @@ class FrameWidgets(ttk.Frame):
a_con = line[5:]
if select_tl == a_con:
self.selected_option.set(0)
- self.auto_con = 'no Autoconnect'
- with open(path_to_file, 'w') as file2:
- file2.write('false')
- file2.close()
-
+ self.autoconnect_var.set('no Autoconnect')
# for disable checkbox when Listbox empty
tl = ListTunnels.tl_list()
if len(tl) == 0:
self.wg_autostart.configure(state='disabled')
+ with open(path_to_file, 'w') as file2:
+ file2.write('false')
+ file2.close()
if self.a != '' and self.a == select_tl:
self.StrVar.set(value='')
StartStopBTN.button_start(self)
self.l_box.update()
# Address Label
- ShowAddress.label_empty(self)
+ self.add.set('')
+ self.DNS.set('')
+ self.enp.set('')
return select_tl
except IndexError:
@@ -246,7 +247,9 @@ class FrameWidgets(ttk.Frame):
self.StrVar.set('')
GreenLabel.green_show_label(self)
# Address Label
- ShowAddress.label_empty(self)
+ self.add.set('')
+ self.DNS.set('')
+ self.enp.set('')
ShowAddress.show_data(self)
except IndexError:
pass
diff --git a/start_wg.py b/start_wg.py
index d10eee5..dee75fd 100755
--- a/start_wg.py
+++ b/start_wg.py
@@ -1,12 +1,12 @@
#!/usr/bin/python3
from subprocess import check_call
-from pathlib import Path
-home = Path.home()
-path_to_file = home / '.config/wire_py/wg_py'
-with open(path_to_file, 'r') as file:
- for line in file.readlines():
- a_con = line[5:]
+path_to_file = '/home/punix/.config/wire_py/wg_py'
+
+
+with open(path_to_file, ) as file:
+ for line in file.readlines():
+ a_con = line[5:]
check_call(['nmcli', 'connection', 'up', a_con])
file.close()
diff --git a/wg_func.py b/wg_func.py
index 71f608b..af4e224 100755
--- a/wg_func.py
+++ b/wg_func.py
@@ -186,19 +186,23 @@ class ImportTunnel(tk.Tk):
file.close()
path_split = filepath.split('/')
path_split1 = path_split[-1]
+ self.a = TunnelActiv.active()
if 'PrivateKey = ' in read and 'PublicKey = ' in read:
if len(path_split1) > 17:
p1 = shutil.copy(filepath, home / 'tester/')
path_split = path_split1[len(path_split1) - 17:]
os.rename(p1, home / 'tester/' / str(path_split))
+
if self.a != '':
check_call(['nmcli', 'connection', 'down', TunnelActiv.active()])
+ ShowAddress.label_empty(self)
check_call(['nmcli', 'connection', 'import', 'type', 'wireguard', 'file', home / 'tester' /
path_split])
else:
shutil.copy(filepath, home / 'tester/')
if self.a != '':
check_call(['nmcli', 'connection', 'down', TunnelActiv.active()])
+ ShowAddress.label_empty(self)
check_call(['nmcli', 'connection', 'import', 'type', 'wireguard', 'file', filepath])
self.StrVar.set('')
@@ -248,6 +252,9 @@ class FileHandle:
off = open(path_to_file, 'w')
off.write('false ' + '\n')
off.close()
+ tl = ListTunnels.tl_list()
+ if len(tl) == 0:
+ self.wg_autostart.configure(state='disabled')
if self.selected_option.get() >= 1:
set_on = open(path_to_file, 'w')
set_on.write('true ' + select_tl)