Last active
May 2, 2024 12:25
-
-
Save nylander/d58a9d4e1678f6aeb6632040d1d0abb3 to your computer and use it in GitHub Desktop.
Start/stop script for FortiClient VPN on Linux
This file contains hidden or 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
#!/usr/bin/env bash | |
# Start/stop FortiClient VPN | |
# Last modified: ons mar 15, 2023 03:47 | |
# Sign: JN | |
# To disable starting forticlient after reboot: | |
# 1. Comment out the command (edit and add an `#` in front of the line) in file | |
# `/opt/forticlient/start-fortitray-launcher.sh` | |
# 2. `sudo systemctl disable forticlient-scheduler` | |
# After step 1 and 2 above, forticlient daemon will not start after reboot. To | |
# start the VPN client however, you first need to start the daemon, then the | |
# client. This can be done with this script. | |
if [[ $# -ne 1 ]]; then | |
echo "ERROR: expects one argument (start or stop)" >&2 | |
exit 1 | |
fi | |
if [[ "$1" == '-h' || "$1" == '--help' ]] ; then | |
echo -e "Description: Start or stop FortiClient VPN\nUsage: $0 stop|start\nNote: requires sudo privileges" | |
exit 0 | |
elif [[ "$1" == "start" ]] ; then | |
echo "start forticlient" | |
pgrep fctsched > /dev/null | |
if [ $? -eq 1 ] ; then | |
sudo systemctl start forticlient-scheduler | |
fi | |
forticlient &> /dev/null & | |
elif [[ "$1" == "stop" ]] ; then | |
echo "stop forticlient" | |
sudo systemctl stop forticlient-scheduler | |
else | |
echo "ERROR: unknown argument ($1). Expects start or stop." >&2 | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Using my current forticlient version (7.2.4.0809 on Ubuntu 22.04.4), the system start/stop doesn't work. I instead use a script that simply connects or disconnects: