diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index cdeab28..153e2ac 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,7 +4,17 @@
-
+
+
+
+
+
+
+
+
+
+
+
@@ -40,14 +50,19 @@
{
"keyToString": {
"ASKED_ADD_EXTERNAL_FILES": "true",
+ "Python.INSTALL.executor": "Run",
+ "Python.install.executor": "Run",
"Python.main.executor": "Run",
+ "Python.messagebox.executor": "Run",
+ "Python.start_wg.executor": "Run",
+ "Python.wg_func.executor": "Run",
"RunOnceActivity.ShowReadmeOnStart": "true",
"git-widget-placeholder": "main",
"last_opened_file_path": "/home/punix/Pyapps/wire-py",
"settings.editor.selected.configurable": "preferences.lookFeel"
}
}
-
+
@@ -70,6 +85,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -287,10 +329,47 @@
1725567453540
-
+
+
+ 1725639633873
+
+
+
+ 1725639633873
+
+
+
+ 1725746027132
+
+
+
+ 1725746027132
+
+
+
+ 1725820337669
+
+
+
+ 1725820337669
+
+
+
+ 1725991610908
+
+
+
+ 1725991610908
+
+
+
-
-
@@ -339,6 +421,9 @@
-
+
+
+
+
\ No newline at end of file
diff --git a/install.py b/install.py
new file mode 100755
index 0000000..0ed4497
--- /dev/null
+++ b/install.py
@@ -0,0 +1,34 @@
+#!/usr/bin/python3
+from pathlib import Path
+from getpass import getpass
+
+# for services file in /lib/systemd/system/
+config_path = Path.home() / ".config" / "wire_py" / "wg_py"
+
+start_file = f'''\
+#!/usr/bin/python3
+from subprocess import check_call
+
+path_to_file = {str(config_path)!r}
+
+with open(path_to_file, 'r') as file:
+ *_, line = file
+a_con = line[5:]
+check_call(['nmcli', 'connection', 'up', a_con])
+'''
+
+Path("start_wg.py").write_text(start_file)
+
+config_path.parent.mkdir(exist_ok=True)
+if not Path.exists(config_path):
+ config_path.write_text("false")
+
+# 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 618518c..99d97c8 100755
--- a/main.py
+++ b/main.py
@@ -1,13 +1,13 @@
#!/usr/bin/python3
import os
import tkinter as tk
+from subprocess import check_call
from tkinter import ttk
-
+from pathlib import Path
from wg_func import (TunnelActiv, ListTunnels, ImportTunnel, ConToDict, GreenLabel, StartStopBTN, ShowAddress,
FileHandle, ExportTunnels, OnOff)
font_color = '#4011a7'
-replacement = ''
class MainWindow(tk.Tk):
@@ -35,8 +35,7 @@ class MainWindow(tk.Tk):
# App Menu
self.app_menu = tk.Menu(self, borderwidth=0)
- for item in self.app_menu.keys():
- print(item, ': ', self.app_menu[item])
+
self.configure(menu=self.app_menu)
self.app_menu.add_cascade(label='?')
@@ -47,6 +46,7 @@ class FrameWidgets(ttk.Frame):
def __init__(self, container, **kwargs):
super().__init__(container, **kwargs)
+ self.auto_con = None
self.enp = None
self.DNS = None
self.add = None
@@ -64,23 +64,24 @@ class FrameWidgets(ttk.Frame):
# Show active Tunnel
self.a = TunnelActiv.active()
# Label Frame 1
+ self.lb_frame_btn_lbox = ttk.Frame(self)
+ self.lb_frame_btn_lbox.configure(relief='flat')
+ self.lb_frame_btn_lbox.grid(column=0, rowspan=4, row=0)
+ self.columnconfigure(0, weight=1)
+ self.rowconfigure(0, weight=1)
+ # Label Frame 2
self.lb_frame = ttk.Frame(self)
self.lb_frame.configure(relief='solid')
self.lb_frame.grid(column=2, row=1, sticky='snew', padx=20, pady=5)
self.columnconfigure(2, weight=1)
self.rowconfigure(1, weight=1)
- # Label Frame 2
+ # Label Frame 3
self.lb_frame2 = ttk.Frame(self)
self.lb_frame2.configure(relief='solid')
self.lb_frame2.grid(column=2, row=2, sticky='snew', padx=20, pady=5)
self.columnconfigure(2, weight=1)
self.rowconfigure(2, weight=1)
- # Label Frame 3
- self.lb_frame_buttons = ttk.Frame(self)
- self.lb_frame_buttons.configure(relief='flat')
- self.lb_frame_buttons.grid(column=0, rowspan=4, row=0)
- self.columnconfigure(0, weight=1)
- self.rowconfigure(0, weight=1)
+
# Show active Label
self.select_tunnel = None
self.lb = tk.Label(self, text='Active: ')
@@ -104,17 +105,16 @@ class FrameWidgets(ttk.Frame):
# Listbox with Scrollbar
def enable_check_box(event):
tl = ListTunnels.tl_list()
- print(len(tl))
if len(tl) != 0:
self.wg_autostart.configure(state='normal')
- self.l_box = tk.Listbox(self.lb_frame_buttons, fg='#606060', selectmode='single')
+ self.l_box = tk.Listbox(self.lb_frame_btn_lbox, fg='#606060', selectmode='single')
self.l_box.config(highlightthickness=0, relief='ridge')
self.l_box.config(font=('Ubuntu', 12, 'bold'))
self.l_box.grid(column=1, rowspan=4, row=0, sticky='ns')
self.l_box.event_add('<>', '')
self.l_box.bind('<>', enable_check_box)
- self.scrollbar = ttk.Scrollbar(self.lb_frame_buttons, orient='vertical', command=self.l_box.yview)
+ self.scrollbar = ttk.Scrollbar(self.lb_frame_btn_lbox, orient='vertical', command=self.l_box.yview)
self.scrollbar.grid(column=1, rowspan=4, row=0, sticky='nse')
self.l_box.configure(yscrollcommand=self.scrollbar.set)
self.rowconfigure(0, weight=1)
@@ -127,13 +127,12 @@ class FrameWidgets(ttk.Frame):
# Button Vpn
if self.a != '':
StartStopBTN.button_stop(self)
- wg_read = os.environ['HOME'] + '/tester/' + str(self.a) + '.conf'
- file = open(wg_read, 'r')
- data = ConToDict.covert_to_dict(file)
+ wg_read = Path.home() / 'tester/' / str(self.a + '.conf')
+ with open(wg_read, 'r') as file:
+ data = ConToDict.covert_to_dict(file)
# Address Label
ShowAddress.init_and_report(self, data)
ShowAddress.show_data(self)
- file.close()
else:
StartStopBTN.button_start(self)
# Address Label
@@ -143,7 +142,7 @@ class FrameWidgets(ttk.Frame):
ShowAddress.label_empty(self)
ShowAddress.show_data(self)
# Button Import
- self.btn_i = tk.Button(self.lb_frame_buttons,
+ self.btn_i = tk.Button(self.lb_frame_btn_lbox,
image=self.imp_pic, bd=0,
command=lambda: ImportTunnel.wg_import_select(self))
self.btn_i.grid(column=0, row=1, padx=15, pady=8)
@@ -152,49 +151,43 @@ class FrameWidgets(ttk.Frame):
try:
self.select_tunnel = self.l_box.curselection()
select_tl = self.l_box.get(self.select_tunnel[0])
- os.system('nmcli connection delete ' + str(select_tl))
+ check_call(['nmcli', 'connection', 'delete', select_tl])
self.l_box.delete(self.select_tunnel[0])
- os.remove(os.environ['HOME'] + '/tester/' + str(select_tl) + '.conf')
+ os.remove(Path.home() / 'tester/' / str(select_tl + '.conf'))
- del_tl_read = open('wg_py.xml', 'r')
- if 'false ' in del_tl_read:
- first_word = 'false '
- else:
- first_word = 'true '
-
- word_replace = ''
- # using the for loop
- for line in del_tl_read:
- line = line.strip()
- changes = line.replace(first_word + select_tl, '')
- word_replace = word_replace + changes + "\n"
-
- del_tl_read.close()
- del_tl = open('wg_py.xml', 'w')
- del_tl.write(word_replace)
- del_tl.close()
+ path_to_file = Path.home() / '.config/wire_py/wg_py'
+ with open(path_to_file, 'r') as file2:
+ for line in file2.readlines():
+ a_con = line[5:]
+ if select_tl == a_con:
+ self.selected_option.set(0)
+ 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')
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:
pass
# Button Trash
- self.btn_tr = tk.Button(self.lb_frame_buttons, image=self.tr_pic, bd=0, command=delete)
+ self.btn_tr = tk.Button(self.lb_frame_btn_lbox, image=self.tr_pic, bd=0, command=delete)
self.btn_tr.grid(column=0, row=2, padx=15, pady=8)
# Button Export
- self.btn_exp = tk.Button(self.lb_frame_buttons, image=self.exp_pic, bd=0, command=ExportTunnels.wg_export)
+ self.btn_exp = tk.Button(self.lb_frame_btn_lbox, image=self.exp_pic, bd=0, command=ExportTunnels.wg_export)
self.btn_exp.grid(column=0, row=3, padx=15, pady=8)
# Button Rename
@@ -203,7 +196,11 @@ class FrameWidgets(ttk.Frame):
# Check Buttons
self.selected_option = tk.IntVar()
-
+ self.autoconnect_var = tk.StringVar()
+ self.autoconnect_var.set(self.auto_con)
+ self.autoconnect = tk.Label(self, textvariable=self.autoconnect_var, fg='blue', padx=5)
+ self.autoconnect.config(font=('Ubuntu', 11))
+ self.autoconnect.grid(column=0, row=4, sticky='ne', pady=20)
self.wg_autostart = tk.Checkbutton(self,
text='Autoconnect on:',
variable=self.selected_option,
@@ -223,14 +220,13 @@ class FrameWidgets(ttk.Frame):
StartStopBTN.button_start(self)
self.select_tunnel = self.l_box.curselection()
select_tl = self.l_box.get(self.select_tunnel[0])
- os.system('nmcli connection up ' + str(select_tl))
- wg_read = os.environ['HOME'] + '/tester/' + str(select_tl) + '.conf'
- file = open(wg_read, 'r')
- data = ConToDict.covert_to_dict(file)
+ check_call(['nmcli', 'connection', 'up', select_tl])
+ wg_read = Path.home() / 'tester/' / str(select_tl + '.conf')
+ with open(wg_read, 'r') as file:
+ data = ConToDict.covert_to_dict(file)
# Address Label
ShowAddress.init_and_report(self, data)
ShowAddress.show_data(self)
- file.close()
# Button Start/Stop
StartStopBTN.button_stop(self)
self.a = TunnelActiv.active()
@@ -240,14 +236,16 @@ class FrameWidgets(ttk.Frame):
elif self.a != '':
# Button Start/Stop
StartStopBTN.button_stop(self)
- os.system('nmcli connection down ' + str(self.a))
+ check_call(['nmcli', 'connection', 'down', self.a])
# Button Start/Stop
StartStopBTN.button_start(self)
self.a = TunnelActiv.active()
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
new file mode 100755
index 0000000..8c13876
--- /dev/null
+++ b/start_wg.py
@@ -0,0 +1,9 @@
+#!/usr/bin/python3
+from subprocess import check_call
+
+path_to_file = '/home/punix/.config/wire_py/wg_py'
+
+with open(path_to_file, 'r') as file:
+ *_, line = file
+a_con = line[5:]
+check_call(['nmcli', 'connection', 'up', a_con])
diff --git a/wg_func.py b/wg_func.py
index 2a0fe3b..34a91d7 100755
--- a/wg_func.py
+++ b/wg_func.py
@@ -4,37 +4,40 @@ import shutil
from datetime import datetime
from tkinter import filedialog, ttk
import tkinter as tk
+from pathlib import Path
+from subprocess import check_call
font_color = '#4011a7'
+path_to_file = Path.home() / '.config/wire_py/wg_py'
-class Message(tk.Tk):
- def __init__(self, *args, **kwargs):
- super().__init__(*args, **kwargs)
-
- self.warning_pic = None
- self.x_width = 300
- self.y_height = 120
- self.monitor_center_x = self.winfo_screenwidth() / 2 - (self.x_width / 2)
- self.monitor_center_y = self.winfo_screenheight() / 2 - (self.y_height / 2)
- self.resizable(width=False, height=False)
- self.title('Import error!')
- self.configure()
- self.geometry('%dx%d+%d+%d' % (self.x_width, self.y_height, self.monitor_center_x, self.monitor_center_y))
- self.columnconfigure(0, weight=1)
-
- self.label = tk.Label(self, image=self.warning_pic,
- text='Oh... no valid Wireguard File!\nPlease select a valid Wireguard File')
- self.label.config(font=('Ubuntu', 11), padx=15, pady=15)
- self.label.grid(column=0, row=0)
- self.button = tk.Button(self, text='OK', command=self.destroy)
- self.button.config(padx=15, pady=5)
- self.button.grid(column=0, row=1)
+def msg_window():
+ msg = tk.Toplevel()
+ msg.resizable(width=False, height=False)
+ msg.x_width = 340
+ msg.y_height = 140
+ msg.title('Import error!')
+ msg.monitor_center_x = msg.winfo_screenwidth() / 2 - (msg.x_width / 2)
+ msg.monitor_center_y = msg.winfo_screenheight() / 2 - (msg.y_height / 2)
+ msg.geometry('%dx%d+%d+%d' % (msg.x_width, msg.y_height, msg.monitor_center_x, msg.monitor_center_y))
+ msg.columnconfigure(0, weight=1)
+ msg.configure(pady=20)
+ msg.warning = tk.PhotoImage(file=r'icons/warning_64.png')
+ msg.i_warning = tk.Label(msg, image=msg.warning)
+ msg.i_warning.grid(column=0, row=0)
+ label = tk.Label(msg, text='Oh... no valid Wireguard File!\nPlease select a valid Wireguard File')
+ label.config(font=('Ubuntu', 11), padx=15, pady=15)
+ label.grid(column=1, row=0)
+ button = tk.Button(msg, text='OK', command=msg.destroy)
+ button.config(padx=15, pady=5)
+ button.grid(column=0, columnspan=2, row=1)
+ wg_icon_2 = tk.PhotoImage(file=r'icons/wg-stop.png')
+ msg.iconphoto(True, wg_icon_2)
+ msg.winfo_toplevel()
-class GreenLabel(tk.Tk):
- def __init__(self, container, **kwargs):
- super().__init__(container, **kwargs)
+class GreenLabel:
+ def __init__(self):
self.StrVar = None
self.lb_tunnel = None
@@ -45,27 +48,28 @@ class GreenLabel(tk.Tk):
self.columnconfigure(2, weight=1)
self.rowconfigure(0, weight=1)
+ def columnconfigure(self, param, weight):
+ pass
-class StartStopBTN(tk.Tk):
- def __init__(self, *args, **kwargs):
- super().__init__(*args, **kwargs)
- self.lb_frame_buttons = None
+ def rowconfigure(self, param, weight):
+ pass
+
+
+class StartStopBTN:
+ def __init__(self):
+ self.lb_frame_btn_lbox = None
self.wg_switch = None
self.btn_stst = None
self.wg_vpn_start = tk.PhotoImage(file=r'icons/wg-vpn-start-48.png')
self.wg_vpn_stop = tk.PhotoImage(file=r'icons/wg-vpn-stop-48.png')
def button_stop(self):
- self.btn_stst = tk.Button(self.lb_frame_buttons, image=self.wg_vpn_stop, bd=0, command=self.wg_switch)
+ self.btn_stst = tk.Button(self.lb_frame_btn_lbox, image=self.wg_vpn_stop, bd=0, command=self.wg_switch)
self.btn_stst.grid(column=0, row=0, padx=15, pady=8)
- #self.columnconfigure(0, weight=1)
- #self.rowconfigure(0, weight=1)
def button_start(self):
- self.btn_stst = tk.Button(self.lb_frame_buttons, image=self.wg_vpn_start, bd=0, command=self.wg_switch)
+ self.btn_stst = tk.Button(self.lb_frame_btn_lbox, image=self.wg_vpn_start, bd=0, command=self.wg_switch)
self.btn_stst.grid(column=0, row=0, padx=15, pady=8)
- #self.columnconfigure(0, weight=1)
- #self.rowconfigure(0, weight=1)
class ConToDict:
@@ -115,9 +119,8 @@ class TunnelActiv:
return active
-class ShowAddress(tk.Tk):
- def __init__(self, container, **kwargs):
- super().__init__(container, **kwargs)
+class ShowAddress:
+ def __init__(self):
self.lb_frame2 = None
self.lb_frame = None
self.endpoint = None
@@ -165,10 +168,9 @@ class ListTunnels:
class ImportTunnel:
+
def __init__(self):
- self.enp = None
- self.DNS = None
- self.add = None
+
self.select_tunnel = None
self.wg_switch = None
self.btn_stst = None
@@ -179,27 +181,30 @@ class ImportTunnel:
def wg_import_select(self):
try:
- filepath = filedialog.askopenfilename(initialdir=os.environ['HOME'], title='Select Wireguard config File',
- filetypes=[('WG config files', '*.conf')])
- file = open(filepath, 'r')
- read = file.read()
- file.close()
+ filepath = filedialog.askopenfilename(initialdir=Path.home(), title='Select Wireguard config File',
+ filetypes=[('WG config files', '*.conf')], )
+ with open(filepath, 'r') as file:
+ read = file.read()
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, os.environ['HOME'] + '/tester/')
+ p1 = shutil.copy(filepath, Path.home() / 'tester/')
path_split = path_split1[len(path_split1) - 17:]
- os.rename(p1, os.environ['HOME'] + '/tester/' + str(path_split))
+ os.rename(p1, Path.home() / 'tester/' / str(path_split))
+
if self.a != '':
- os.system('nmcli connection down ' + str(TunnelActiv.active()))
- os.system('nmcli connection import type wireguard file ' + os.environ['HOME'] + '/tester/' +
- str(path_split))
+ check_call(['nmcli', 'connection', 'down', TunnelActiv.active()])
+ ShowAddress.label_empty(self)
+ check_call(['nmcli', 'connection', 'import', 'type', 'wireguard', 'file', Path.home() / 'tester' /
+ path_split])
else:
- shutil.copy(filepath, os.environ['HOME'] + '/tester/')
+ shutil.copy(filepath, Path.home() / 'tester/')
if self.a != '':
- os.system('nmcli connection down ' + str(TunnelActiv.active()))
- os.system('nmcli connection import type wireguard file ' + str(filepath))
+ check_call(['nmcli', 'connection', 'down', TunnelActiv.active()])
+ ShowAddress.label_empty(self)
+ check_call(['nmcli', 'connection', 'import', 'type', 'wireguard', 'file', filepath])
self.StrVar.set('')
self.a = TunnelActiv.active()
@@ -209,19 +214,15 @@ class ImportTunnel:
self.StrVar.set(self.a)
GreenLabel.green_show_label(self)
StartStopBTN.button_stop(self)
- wg_read = os.environ['HOME'] + '/tester/' + str(self.a) + '.conf'
- file = open(wg_read, 'r')
- data = ConToDict.covert_to_dict(file)
+ wg_read = Path.home() / 'tester/' / str(self.a + '.conf')
+ with open(wg_read, 'r') as file:
+ data = ConToDict.covert_to_dict(file)
# Address Label
ShowAddress.init_and_report(self, data)
ShowAddress.show_data(self)
- file.close()
- os.system('nmcli con mod ' + str(self.a) + ' connection.autoconnect no')
- new_tl = open('wg_py.xml', 'a')
- new_tl.write('false ' + str(self.a) + '\n')
- new_tl.close()
+ check_call(['nmcli', 'con', 'mod', self.a, 'connection.autoconnect', 'no'])
if 'PrivateKey = ' not in read:
- Message()
+ msg_window()
except EOFError:
pass
except TypeError:
@@ -241,34 +242,20 @@ class FileHandle:
self.tl = None
self.selected_option = None
self.l_box = None
- self.select_tunnel = None
def box_set(self):
- word_replace = ''
try:
- self.select_tunnel = self.l_box.curselection()
- select_tl = self.l_box.get(self.select_tunnel[0])
+ select_tunnel = self.l_box.curselection()
+ select_tl = self.l_box.get(select_tunnel[0])
if self.selected_option.get() == 0:
- set_on = open('wg_py.xml', 'r')
- # using the for loop
- for line in set_on:
- line = line.strip()
- changes = line.replace('true ' + select_tl, 'false ' + select_tl)
- os.system('nmcli con mod ' + str(self.auto_con) + ' connection.autoconnect no')
- word_replace = word_replace + changes + "\n"
- set_on.close()
+ with open(path_to_file, 'w') as off:
+ off.write('false ' + '\n')
+ tl = ListTunnels.tl_list()
+ if len(tl) == 0:
+ self.wg_autostart.configure(state='disabled')
if self.selected_option.get() >= 1:
- set_on = open('wg_py.xml', 'r')
- # using the for loop
- for line in set_on:
- line = line.strip()
- changes = line.replace('false ' + select_tl, 'true ' + select_tl)
- os.system('nmcli con mod ' + str(select_tl) + ' connection.autoconnect yes')
- word_replace = word_replace + changes + "\n"
- set_on.close()
- set_off = open('wg_py.xml', 'w')
- set_off.write(word_replace)
- set_off.close()
+ with open(path_to_file, 'w') as set_on:
+ set_on.write('true ' + select_tl)
except IndexError:
self.selected_option.set(1)
@@ -276,26 +263,26 @@ class FileHandle:
OnOff.on_off(self)
-class OnOff(tk.Tk, FileHandle):
- def __init__(self, container, **kwargs):
- super().__init__(container, **kwargs)
+class OnOff:
+ def __init__(self):
+ self.wg_autostart = None
+ self.selected_option = None
+ self.auto_con = None
+ self.autoconnect = None
+ self.autoconnect_var = None
self.lb_frame_buttons = None
def on_off(self):
- a_connect = {}
- on_or_off = open('wg_py.xml', 'r')
- for line in on_or_off.readlines():
- line_splitted = line.split()
- a_connect[line_splitted[0]] = line_splitted[1]
- if 'true' in a_connect:
- self.selected_option.set(1)
- self.autoconnect_var.set('')
- self.auto_con = a_connect['true']
-
- else:
- self.wg_autostart.configure(state='disabled')
- self.auto_con = 'no Autoconnect'
- on_or_off.close()
+ with open(path_to_file, 'r') as file:
+ for line in file.readlines():
+ a_connect = line
+ if 'true' in a_connect:
+ self.selected_option.set(1)
+ self.autoconnect_var.set('')
+ self.auto_con = a_connect[5:]
+ else:
+ self.wg_autostart.configure(state='disabled')
+ self.auto_con = 'no Autoconnect'
self.autoconnect_var = tk.StringVar()
self.autoconnect_var.set(self.auto_con)
@@ -308,12 +295,12 @@ class ExportTunnels:
@staticmethod
def wg_export():
now_time = datetime.now()
- now_datetime = now_time.strftime('/wg-exp-' + '%m-%d-%Y' + '-' + '%H:%M')
+ now_datetime = now_time.strftime('wg-exp-' + '%m-%d-%Y' + '-' + '%H:%M')
tl = ListTunnels.tl_list()
try:
if len(tl) != 0:
- wg_tar = os.environ['HOME'] + now_datetime
- p_to_conf = os.environ['HOME'] + '/tester'
+ wg_tar = Path.home() / now_datetime
+ p_to_conf = Path.home() / 'tester/'
shutil.make_archive(wg_tar, 'zip', p_to_conf)
#if zip_full != 0:
#print('Export erfolgraeich')
diff --git a/wg_py b/wg_py
new file mode 100644
index 0000000..e69de29
diff --git a/wg_py.xml b/wg_py.xml
deleted file mode 100644
index 2d98c87..0000000
--- a/wg_py.xml
+++ /dev/null
@@ -1,2 +0,0 @@
-false peer_iasus
-false rverEppingen
diff --git a/wg_start.service b/wg_start.service
new file mode 100644
index 0000000..6d86638
--- /dev/null
+++ b/wg_start.service
@@ -0,0 +1,10 @@
+[Unit]
+Description=Automatic Tunnel Start
+After=network-online.target
+
+[Service]
+Type=oneshot
+ExecStartPre=/bin/sleep 3
+ExecStart=/bin/start_wg.py
+[Install]
+WantedBy=multi-user.target