mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2025-05-20 07:26:58 -04:00
fix: disconnect VPN when sleep
This commit is contained in:
@@ -10,6 +10,10 @@ install:
|
||||
install -Dm755 artifacts/usr/bin/gpgui $(DESTDIR)/usr/bin/gpgui; \
|
||||
fi
|
||||
|
||||
# Install the disconnect hooks
|
||||
install -Dm755 artifacts/usr/lib/NetworkManager/dispatcher.d/pre-down.d/gpclient.down $(DESTDIR)/usr/lib/NetworkManager/dispatcher.d/pre-down.d/gpclient.down
|
||||
install -Dm755 artifacts/usr/lib/NetworkManager/dispatcher.d/gpclient-nm-hook $(DESTDIR)/usr/lib/NetworkManager/dispatcher.d/gpclient-nm-hook
|
||||
|
||||
install -Dm644 artifacts/usr/share/applications/gpgui.desktop $(DESTDIR)/usr/share/applications/gpgui.desktop
|
||||
install -Dm644 artifacts/usr/share/icons/hicolor/scalable/apps/gpgui.svg $(DESTDIR)/usr/share/icons/hicolor/scalable/apps/gpgui.svg
|
||||
install -Dm644 artifacts/usr/share/icons/hicolor/32x32/apps/gpgui.png $(DESTDIR)/usr/share/icons/hicolor/32x32/apps/gpgui.png
|
||||
@@ -26,6 +30,9 @@ uninstall:
|
||||
rm -f $(DESTDIR)/usr/bin/gpgui-helper
|
||||
rm -f $(DESTDIR)/usr/bin/gpgui
|
||||
|
||||
rm -f $(DESTDIR)/usr/lib/NetworkManager/dispatcher.d/pre-down.d/gpclient.down
|
||||
rm -f $(DESTDIR)/usr/lib/NetworkManager/dispatcher.d/gpclient-nm-hook
|
||||
|
||||
rm -f $(DESTDIR)/usr/share/applications/gpgui.desktop
|
||||
rm -f $(DESTDIR)/usr/share/icons/hicolor/scalable/apps/gpgui.svg
|
||||
rm -f $(DESTDIR)/usr/share/icons/hicolor/32x32/apps/gpgui.png
|
||||
|
26
packaging/files/usr/lib/NetworkManager/dispatcher.d/gpclient-nm-hook
Executable file
26
packaging/files/usr/lib/NetworkManager/dispatcher.d/gpclient-nm-hook
Executable file
@@ -0,0 +1,26 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Resume the VPN connection if the network comes back up
|
||||
|
||||
set -e
|
||||
|
||||
PIDFILE=/tmp/gpservice_disconnected.pid
|
||||
|
||||
resume_vpn() {
|
||||
if [ -f $PIDFILE ]; then
|
||||
PID=$(cat $PIDFILE)
|
||||
|
||||
# Always remove the PID file
|
||||
rm $PIDFILE
|
||||
|
||||
# Ensure the PID is a gpservice process
|
||||
if ps -p $PID -o comm= | grep -q gpservice; then
|
||||
# Send a USR2 signal to the gpclient process to resume the VPN connection
|
||||
kill -USR2 $PID
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
if [ "$2" = "up" ]; then
|
||||
resume_vpn
|
||||
fi
|
@@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
# Disconnect the VPN connection before the network goes down
|
||||
/usr/bin/gpclient disconnect --wait 3
|
@@ -60,6 +60,13 @@ make build OFFLINE=@OFFLINE@ BUILD_FE=0
|
||||
%{_datadir}/icons/hicolor/scalable/apps/gpgui.svg
|
||||
%{_datadir}/polkit-1/actions/com.yuezk.gpgui.policy
|
||||
|
||||
%dir /usr/lib/NetworkManager
|
||||
%dir /usr/lib/NetworkManager/dispatcher.d
|
||||
%dir /usr/lib/NetworkManager/dispatcher.d/pre-down.d
|
||||
|
||||
/usr/lib/NetworkManager/dispatcher.d/pre-down.d/gpclient.down
|
||||
/usr/lib/NetworkManager/dispatcher.d/gpclient-nm-hook
|
||||
|
||||
%dir %{_datadir}/icons/hicolor
|
||||
%dir %{_datadir}/icons/hicolor/32x32
|
||||
%dir %{_datadir}/icons/hicolor/32x32/apps
|
||||
|
Reference in New Issue
Block a user