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

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

View File

@ -4,8 +4,13 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="940e1630-c825-4d4c-be80-bc11f543c122" name="Changes" comment="fix checkbox disable and policy rename main.py to wg_main.py">
<list default="true" id="940e1630-c825-4d4c-be80-bc11f543c122" name="Changes" comment="fix rename in Messagebox warning to error">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Wire-Py.desktop" beforeDir="false" afterPath="$PROJECT_DIR$/Wire-Py.desktop" afterDir="false" />
<change beforePath="$PROJECT_DIR$/install" beforeDir="false" afterPath="$PROJECT_DIR$/install" afterDir="false" />
<change beforePath="$PROJECT_DIR$/org.wirepy.policy" beforeDir="false" afterPath="$PROJECT_DIR$/org.wirepy.policy" afterDir="false" />
<change beforePath="$PROJECT_DIR$/wg_func.py" beforeDir="false" afterPath="$PROJECT_DIR$/wg_func.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/wg_main.py" beforeDir="false" afterPath="$PROJECT_DIR$/wg_main.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -404,7 +409,15 @@
<option name="project" value="LOCAL" />
<updated>1726650691719</updated>
</task>
<option name="localTasksCounter" value="35" />
<task id="LOCAL-00035" summary="fix rename in Messagebox warning to error">
<option name="closed" value="true" />
<created>1726652747322</created>
<option name="number" value="00035" />
<option name="presentableId" value="LOCAL-00035" />
<option name="project" value="LOCAL" />
<updated>1726652747322</updated>
</task>
<option name="localTasksCounter" value="36" />
<servers />
</component>
<component name="UnknownFeatures">
@ -445,7 +458,6 @@
</component>
<component name="VcsManagerConfiguration">
<option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" />
<MESSAGE value="add Class StartStopBTN to wg_func.py" />
<MESSAGE value="Set Style to Clam&#10;Improved layout of widgets" />
<MESSAGE value="Remove open file function, add Show Address Labels with tk.StrVar when remove a not active Tunnel Labels of Active Tunnel removed!" />
<MESSAGE value="fixed error when active tunnel is deleted,&#10;now also the Address Label is emptied" />
@ -470,6 +482,23 @@
<MESSAGE value="new format little fixes icons sort add policy add .desktop File install Part 2" />
<MESSAGE value="install fix for set dir right" />
<MESSAGE value="fix checkbox disable and policy rename main.py to wg_main.py" />
<option name="LAST_COMMIT_MESSAGE" value="fix checkbox disable and policy rename main.py to wg_main.py" />
<MESSAGE value="fix rename in Messagebox warning to error" />
<option name="LAST_COMMIT_MESSAGE" value="fix rename in Messagebox warning to error" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
<breakpoints>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/wg_main.py</url>
<line>1</line>
<option name="timeStamp" value="1" />
</line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/wg_func.py</url>
<line>11</line>
<option name="timeStamp" value="2" />
</line-breakpoint>
</breakpoints>
</breakpoint-manager>
</component>
</project>

View File

@ -4,4 +4,4 @@ Name=Wire-Py
Exec=/usr/bin/wirepy
Terminal=false
Categories=Network;
Icon=/usr/share/icons/wp-icons/128/wg-vpn.png
Icon=/usr/share/icons/wp-icons/128/wg_vpn.png

10
install
View File

@ -4,12 +4,13 @@ which sudo >/dev/null
if [ $? -ne 0 ]
then
su -
apt install python3-tk && apt install tcl-ttkthemes && \
apt install python3-tk -y && apt install tcl-ttkthemes -y && \
cp wg_main.py start_wg.py wg_func.py wirepy /usr/bin/ && \
mkdir -p /etc/wire_py && cp -R wp-icons /usr/share/icons/ && \
if [ ! -e /usr/local/bin/wirepy ]
chown -R root:root /etc/wire_py && sudo chmod 755 /etc/wire_py && \
if [ ! -f /usr/local/bin/wirepy ]
then
sudo ln -s /usr/bin/wirepy.py /usr/local/bin/wirepy
ln -s /usr/bin/wirepy.py /usr/local/bin/wirepy >/dev/null
fi
cp org.wirepy.policy /usr/share/polkit-1/actions/ && \
cp Wire-Py.desktop /usr/share/applications/ && \
@ -20,7 +21,8 @@ else
sudo apt install python3-tk && sudo apt install tcl-ttkthemes && \
sudo cp wg_main.py start_wg.py wg_func.py wirepy /usr/bin/ && \
sudo mkdir -p /etc/wire_py && sudo cp -R wp-icons /usr/share/icons/ && \
if [ ! -e /usr/local/bin/wirepy ]
sudo chown -R root:root /etc/wire_py && sudo chmod 755 /etc/wire_py && \
if [ ! -f /usr/local/bin/wirepy ]
then
sudo ln -s /usr/bin/wirepy.py /usr/local/bin/wirepy
fi

View File

@ -10,7 +10,7 @@
<allow_inactive>auth_admin_keep</allow_inactive>
<allow_active>yes</allow_active>
</defaults>
<annotate key="org.freedesktop.policykit.exec.path">/usr/bin/wire-py/wg_main.py</annotate>
<annotate key="org.freedesktop.policykit.exec.path">/usr/bin/wg_main.py</annotate>
<annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
</action>
</policyconfig>

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:

View File

@ -58,7 +58,7 @@ class FrameWidgets(ttk.Frame):
self.imp_pic = tk.PhotoImage(file=r'/usr/share/icons/wp-icons/48/wg_import.png')
self.tr_pic = tk.PhotoImage(file=r'/usr/share/icons/wp-icons/48/wg_trash.png')
self.exp_pic = tk.PhotoImage(file=r'/usr/share/icons/wp-icons/48/wg_export.png')
self.warning_pic = tk.PhotoImage(file=r'/usr/share/icons/wp-icons/64/warning.png')
self.warning_pic = tk.PhotoImage(file=r'/usr/share/icons/wp-icons/64/error.png')
# Show active Tunnel
self.a = TunnelActiv.active()