Monitor connection status of VPN and reconnect if disconnected
here's how i did it:
save the following to /usr/local/bin/vpn
if [[ "{$(/opt/cisco/anyconnect/bin/vpn status)[0]}" == *"Disconnected"* ]]; then
/opt/cisco/anyconnect/bin/vpn connect SERVER
fi
chmod +x /usr/local/bin/vpn
save the following to /Library/LaunchDaemons/com.example.utilities.vpn.plist
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.example.whatever.vpn</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/vpn</string>
</array>
<key>StartInterval</key>
<integer>30</integer>
</dict>
</plist>
load it into launchd
:
launchctl load -w /Library/LaunchDaemons/com.example.whatever.vpn.plist
check that it's there:
launchctl list | grep whatever