Disconnect VPN before downloading a large package

Rohitds14
New Contributor III

Due to global lockdown our whole organisation is working from home in VPN and we are planning to push OSX update to macs due to some requirement.
We do not want all users to download OSX installer at a same time in VPN.
To reduce the VPN usage, i have written this script which will display a popup title box to disconnect your VPN before proceeding to OSX upgrade.
On clicking on it VPN will be disconnected and OSX package will start downloading.
This box will only displayed to user if VPN is connected.
Hope this helps any of you.
cheers!!

08a53e3123ed4c818f37e528eb4d5259

#!/bin/sh
#####################################################################################################
#
# ABOUT THIS SCRIPT
#
# NAME
#   disconnectVPN.sh
#
# DESCRIPTION
#   
#   this script is created to disconnect vpn, before triggering a policy which demand a large downloadable 
#   file. Due to global lockdown our organisation is working in VPN, To reduce VPN load 
#   this script has been created.
#
# How to use
#
#   this script will check if VPN is connected, if connected it will pop up a button to disconnect VPN.
#   Afterwards triggers a next policy, which contain a large downloadable package
#
#   
#
####################################################################################################
#
# HISTORY
#
#   Version: 1.0
#
#   - Created by Rohit Das
#
####################################################################################################

disconnectvpn ()
{

    response=`/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper 
        -windowType utility -title "Greetings from IT" -alignHeading center -alignDescription left 
        -description "You are connected with VPN network,before proceeding for the update click below to disconnect your VPN, After Software update you can re-connect your VPN" 
        -button1 "Disconnect" -defaultButton 1`

    if [[ "$response" == "0" ]];
        then

        sudo /opt/cisco/anyconnect/bin/vpn disconnect
        echo "vpn is now disconnected"
    else

        echo "VPN is not disconnected"
        exit 0
    fi

}



vpnstatus=`sudo /opt/cisco/anyconnect/bin/vpn status | grep ">> state:" | head -1`
echo "***checking VPN connection...***
"

if [[  $vpnstatus =~ "Connected" ]]; then
    echo "VPN connected....attempting to disconnect"


    disconnectvpn


else    
    echo "VPN not connected"

fi

echo "trigger policy"
sudo jamf policy -trigger <your policy trigger name>
0 REPLIES 0