Last active
January 2, 2023 18:34
-
-
Save sming/0c56fb7a54a68d502aded2b71e501bba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Props to https://gist.github.com/kaleksandrov/3cfee92845a403da995e7e44ba771183 from whom I took the code inside | |
# the conditional. | |
THIS_SCRIPT_INVOCATION=$0 | |
# The return status of this function will be 0 if globalprotect is running, 1 if not running because grep returns 0 | |
# if it finds a match and 1 if not. | |
# We basically grep for globalprotect but exclude all the matches we don't want | |
ps-grep () { | |
ps auwwwwx | grep -i globalprotect | grep -v "$THIS_SCRIPT_INVOCATION" | grep -v 'grep ' | grep -v "%CPU" > /dev/null | |
} | |
ps-grep | |
IS_RUNNING=$? | |
if [ "$IS_RUNNING" -eq "0" ] | |
then | |
echo "Stopping GlobalProtect..." | |
launchctl remove com.paloaltonetworks.gp.pangps | |
launchctl remove com.paloaltonetworks.gp.pangpa | |
echo "Done!" | |
else | |
echo "Starting GlobalProtect..." | |
launchctl load /Library/LaunchAgents/com.paloaltonetworks.gp.pangpa.plist | |
launchctl load /Library/LaunchAgents/com.paloaltonetworks.gp.pangps.plist | |
echo "Done!" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I don't think this command works for some GlobalProtect clients or OS versions. Running either this script, or either commands individually as root on my macOS 12.2.1 system does not stop or start the GlobalProtect client and it also does not break my GlobalProtect clients VPN connection to our Firewall. Maybe something changed either with the GP client, it's configuration (could ours be configured to not allow this), or something new in the macOS 12.