little fixes a labels when stop and start, installer first functions works
This commit is contained in:
parent
35406026f0
commit
8fa6e6374f
@ -4,11 +4,9 @@
|
|||||||
<option name="autoReloadType" value="SELECTIVE" />
|
<option name="autoReloadType" value="SELECTIVE" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="940e1630-c825-4d4c-be80-bc11f543c122" name="Changes" comment="little fixes">
|
<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 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" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<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$/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$/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" />
|
<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" />
|
<option name="project" value="LOCAL" />
|
||||||
<updated>1725746027132</updated>
|
<updated>1725746027132</updated>
|
||||||
</task>
|
</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 />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
<component name="Vcs.Log.Tabs.Properties">
|
<component name="Vcs.Log.Tabs.Properties">
|
||||||
@ -370,7 +376,6 @@
|
|||||||
</component>
|
</component>
|
||||||
<component name="VcsManagerConfiguration">
|
<component name="VcsManagerConfiguration">
|
||||||
<option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" />
|
<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="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" />
|
||||||
<MESSAGE value="add class Frame and class Massage, delete funktion go 100%, add resize window, add warning pic" />
|
<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="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="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" />
|
<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>
|
</component>
|
||||||
</project>
|
</project>
|
31
install.py
31
install.py
@ -1,10 +1,30 @@
|
|||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
import os
|
import os
|
||||||
from pathlib import Path
|
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()
|
home = Path.home()
|
||||||
# for services file in /lib/systemd/system/
|
# for services file in /lib/systemd/system/
|
||||||
path_for_a_con = home / '.config/wire_py/wg_py'
|
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
|
# create dir in home
|
||||||
mkdir = home / '.config/wire_py'
|
mkdir = home / '.config/wire_py'
|
||||||
os.makedirs(mkdir, exist_ok=True)
|
os.makedirs(mkdir, exist_ok=True)
|
||||||
@ -12,6 +32,15 @@ os.makedirs(mkdir, exist_ok=True)
|
|||||||
with open(mkdir / 'wg_py', 'w+') as file:
|
with open(mkdir / 'wg_py', 'w+') as file:
|
||||||
if 'true' not in file:
|
if 'true' not in file:
|
||||||
file.write('false')
|
file.write('false')
|
||||||
|
|
||||||
file.close()
|
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:]
|
a_con = line[5:]
|
||||||
if select_tl == a_con:
|
if select_tl == a_con:
|
||||||
self.selected_option.set(0)
|
self.selected_option.set(0)
|
||||||
self.auto_con = 'no Autoconnect'
|
self.autoconnect_var.set('no Autoconnect')
|
||||||
with open(path_to_file, 'w') as file2:
|
|
||||||
file2.write('false')
|
|
||||||
file2.close()
|
|
||||||
|
|
||||||
# for disable checkbox when Listbox empty
|
# for disable checkbox when Listbox empty
|
||||||
tl = ListTunnels.tl_list()
|
tl = ListTunnels.tl_list()
|
||||||
if len(tl) == 0:
|
if len(tl) == 0:
|
||||||
self.wg_autostart.configure(state='disabled')
|
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:
|
if self.a != '' and self.a == select_tl:
|
||||||
self.StrVar.set(value='')
|
self.StrVar.set(value='')
|
||||||
StartStopBTN.button_start(self)
|
StartStopBTN.button_start(self)
|
||||||
self.l_box.update()
|
self.l_box.update()
|
||||||
# Address Label
|
# Address Label
|
||||||
ShowAddress.label_empty(self)
|
self.add.set('')
|
||||||
|
self.DNS.set('')
|
||||||
|
self.enp.set('')
|
||||||
|
|
||||||
return select_tl
|
return select_tl
|
||||||
except IndexError:
|
except IndexError:
|
||||||
@ -246,7 +247,9 @@ class FrameWidgets(ttk.Frame):
|
|||||||
self.StrVar.set('')
|
self.StrVar.set('')
|
||||||
GreenLabel.green_show_label(self)
|
GreenLabel.green_show_label(self)
|
||||||
# Address Label
|
# Address Label
|
||||||
ShowAddress.label_empty(self)
|
self.add.set('')
|
||||||
|
self.DNS.set('')
|
||||||
|
self.enp.set('')
|
||||||
ShowAddress.show_data(self)
|
ShowAddress.show_data(self)
|
||||||
except IndexError:
|
except IndexError:
|
||||||
pass
|
pass
|
||||||
|
12
start_wg.py
12
start_wg.py
@ -1,12 +1,12 @@
|
|||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
from subprocess import check_call
|
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'
|
||||||
for line in file.readlines():
|
|
||||||
a_con = line[5:]
|
|
||||||
|
with open(path_to_file, ) as file:
|
||||||
|
for line in file.readlines():
|
||||||
|
a_con = line[5:]
|
||||||
check_call(['nmcli', 'connection', 'up', a_con])
|
check_call(['nmcli', 'connection', 'up', a_con])
|
||||||
file.close()
|
file.close()
|
||||||
|
@ -186,19 +186,23 @@ class ImportTunnel(tk.Tk):
|
|||||||
file.close()
|
file.close()
|
||||||
path_split = filepath.split('/')
|
path_split = filepath.split('/')
|
||||||
path_split1 = path_split[-1]
|
path_split1 = path_split[-1]
|
||||||
|
self.a = TunnelActiv.active()
|
||||||
if 'PrivateKey = ' in read and 'PublicKey = ' in read:
|
if 'PrivateKey = ' in read and 'PublicKey = ' in read:
|
||||||
if len(path_split1) > 17:
|
if len(path_split1) > 17:
|
||||||
p1 = shutil.copy(filepath, home / 'tester/')
|
p1 = shutil.copy(filepath, home / 'tester/')
|
||||||
path_split = path_split1[len(path_split1) - 17:]
|
path_split = path_split1[len(path_split1) - 17:]
|
||||||
os.rename(p1, home / 'tester/' / str(path_split))
|
os.rename(p1, home / 'tester/' / str(path_split))
|
||||||
|
|
||||||
if self.a != '':
|
if self.a != '':
|
||||||
check_call(['nmcli', 'connection', 'down', TunnelActiv.active()])
|
check_call(['nmcli', 'connection', 'down', TunnelActiv.active()])
|
||||||
|
ShowAddress.label_empty(self)
|
||||||
check_call(['nmcli', 'connection', 'import', 'type', 'wireguard', 'file', home / 'tester' /
|
check_call(['nmcli', 'connection', 'import', 'type', 'wireguard', 'file', home / 'tester' /
|
||||||
path_split])
|
path_split])
|
||||||
else:
|
else:
|
||||||
shutil.copy(filepath, home / 'tester/')
|
shutil.copy(filepath, home / 'tester/')
|
||||||
if self.a != '':
|
if self.a != '':
|
||||||
check_call(['nmcli', 'connection', 'down', TunnelActiv.active()])
|
check_call(['nmcli', 'connection', 'down', TunnelActiv.active()])
|
||||||
|
ShowAddress.label_empty(self)
|
||||||
check_call(['nmcli', 'connection', 'import', 'type', 'wireguard', 'file', filepath])
|
check_call(['nmcli', 'connection', 'import', 'type', 'wireguard', 'file', filepath])
|
||||||
|
|
||||||
self.StrVar.set('')
|
self.StrVar.set('')
|
||||||
@ -248,6 +252,9 @@ class FileHandle:
|
|||||||
off = open(path_to_file, 'w')
|
off = open(path_to_file, 'w')
|
||||||
off.write('false ' + '\n')
|
off.write('false ' + '\n')
|
||||||
off.close()
|
off.close()
|
||||||
|
tl = ListTunnels.tl_list()
|
||||||
|
if len(tl) == 0:
|
||||||
|
self.wg_autostart.configure(state='disabled')
|
||||||
if self.selected_option.get() >= 1:
|
if self.selected_option.get() >= 1:
|
||||||
set_on = open(path_to_file, 'w')
|
set_on = open(path_to_file, 'w')
|
||||||
set_on.write('true ' + select_tl)
|
set_on.write('true ' + select_tl)
|
||||||
|
Loading…
Reference in New Issue
Block a user