little fixes a labels when stop and start, installer first functions works
This commit is contained in:
parent
35406026f0
commit
8fa6e6374f
20
.idea/workspace.xml
generated
20
.idea/workspace.xml
generated
@ -4,11 +4,9 @@
|
||||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="940e1630-c825-4d4c-be80-bc11f543c122" name="Changes" comment="little fixes">
|
||||
<change afterPath="$PROJECT_DIR$/home/punix/.config/wire_py/wg_py" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/install.py" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/punix/.config/wire_py/wg_py" afterDir="false" />
|
||||
<list default="true" id="940e1630-c825-4d4c-be80-bc11f543c122" name="Changes" comment="little fixes replace os.system with check_call first steps in install Script add wg_start.service file">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/install.py" beforeDir="false" afterPath="$PROJECT_DIR$/install.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/start_wg.py" beforeDir="false" afterPath="$PROJECT_DIR$/start_wg.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/wg_func.py" beforeDir="false" afterPath="$PROJECT_DIR$/wg_func.py" afterDir="false" />
|
||||
@ -342,7 +340,15 @@
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1725746027132</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="28" />
|
||||
<task id="LOCAL-00028" summary="little fixes replace os.system with check_call first steps in install Script add wg_start.service file">
|
||||
<option name="closed" value="true" />
|
||||
<created>1725820337669</created>
|
||||
<option name="number" value="00028" />
|
||||
<option name="presentableId" value="LOCAL-00028" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1725820337669</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="29" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
@ -370,7 +376,6 @@
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" />
|
||||
<MESSAGE value="Tunnel Start and Stop Work" />
|
||||
<MESSAGE value="wg_import_select in wg_func.py extended" />
|
||||
<MESSAGE value="add class Frame and class Massage, delete funktion go 100%, add resize window" />
|
||||
<MESSAGE value="add class Frame and class Massage, delete funktion go 100%, add resize window, add warning pic" />
|
||||
@ -395,6 +400,7 @@
|
||||
<MESSAGE value="fixes on empty Listbox now is disable and now works autoconnect label with read and write, delete works now with read and write" />
|
||||
<MESSAGE value="add Frame widget 3 for Buttons and Listbox with Scrollbar. all Widgets new format delete works now of disable checkbox when Listbox empty (part two)" />
|
||||
<MESSAGE value="little fixes" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="little fixes" />
|
||||
<MESSAGE value="little fixes replace os.system with check_call first steps in install Script add wg_start.service file" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="little fixes replace os.system with check_call first steps in install Script add wg_start.service file" />
|
||||
</component>
|
||||
</project>
|
31
install.py
31
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)
|
||||
|
||||
|
17
main.py
17
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
|
||||
|
@ -1,11 +1,11 @@
|
||||
#!/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:
|
||||
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])
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user