Set a script only for forticlient >=v7.0.0.0
This commit is contained in:
parent
1b7b0d8bba
commit
18f64fccd5
|
@ -1,7 +1,7 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Purpose {{{
|
||||
# This script will try to manage VPN with forticlient
|
||||
# This script will try to manage VPN with forticlient v7
|
||||
# 1. Start a VPN will
|
||||
# a. Ensure forticlient systemd unit is started.
|
||||
# b. Try to connect to VPN with profile name.
|
||||
|
@ -42,6 +42,7 @@ export DEBUG
|
|||
readonly REQUEST_STATUS_DEFAULT="start"
|
||||
readonly VPN_PROFILE_NAME_DEFAULT="Universite Rennes 1"
|
||||
VPN_USER_DEFAULT=$(whoami) ; readonly VPN_USER_DEFAULT
|
||||
readonly FORTICLIENT_NEW_VERSION="7.0.0.0"
|
||||
|
||||
## Colors
|
||||
readonly PURPLE='\033[1;35m'
|
||||
|
@ -135,6 +136,10 @@ define_vars() { # {{{
|
|||
readonly vpn_user="${VPN_USER_DEFAULT}"
|
||||
fi
|
||||
## }}}
|
||||
## Try to get forticlient version {{{
|
||||
is_command_available "dpkg" "| " \
|
||||
&& forticlient_current_version=$(dpkg --list -- forticlient | awk '/^ii *forticlient/ {print $3}' | sed 's/.:\(.*\)-.*/\1/')
|
||||
## }}}
|
||||
}
|
||||
# }}}
|
||||
|
||||
|
@ -177,6 +182,12 @@ main() { # {{{
|
|||
define_vars
|
||||
debug_message "| Define vars"
|
||||
|
||||
## If forticlient version is lower than expected one (7) {{{
|
||||
### Exit with error
|
||||
is_version_greater_than "${forticlient_current_version}" "${FORTICLIENT_NEW_VERSION}" \
|
||||
|| error_message "Forticlient installed version (${forticlient_current_version}) seems lower than expected (>=${FORTICLIENT_NEW_VERSION}). Please see fortinet.vpn.v6.sh script instead." 02
|
||||
## }}}
|
||||
|
||||
## If the VPN must be stopped {{{
|
||||
if [ "${request_status}" = "stop" ]; then
|
||||
debug_message "-- Disconnect VPN BEGIN"
|
||||
|
@ -185,7 +196,7 @@ main() { # {{{
|
|||
forticlient_status=$(forticlient vpn status | head --lines=1 | sed 's/Status: \(.*\)/\1/' || error_message "Error while requesting current VPN status." 22)
|
||||
if [ "${forticlient_status}" = "Connected" ]; then
|
||||
debug_message "| VPN is ${RED}${forticlient_status}${COLOR_DEBUG}, try to disconnect it…"
|
||||
### Try to discconnect
|
||||
### Try to disconnect
|
||||
forticlient vpn disconnect > /dev/null \
|
||||
|| error_message "Error when disconnecting VPN." 11
|
||||
fi
|
Loading…
Reference in New Issue