reconnect script

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 2011-05-27 at 15:25 -0500, Matthew Kitchin (public/usenet) wrote:
> 
> ping -c 4 10.85.0.1 2>/dev/null 1>/dev/nul
>        if [ $? -ne 0 ]; then
>           killall openconnect
>           echo passwd|openconnect https://myIP --no-cert-check --script 
> /etc/vpn-script --user=username --passwd-on-stdin
>        fi 

FWIW this is the script I use to keep openconnect up. It pauses between
reconnect attempts if it's failing to connect, and it aborts if it gets
a login failure...

OpenConnect itself should always exit when it's no longer working, as
long as DPD is running. And if for some reason it isn't requested by
your server, you can use the --force-dpd option to enable it anyway.

#!/bin/bash

VPNSERVER=x.x.x.x
read -p "Enter VPN password: " -s PASS

while true; do 
    route add default gw 90.155.92.193
    THEN=`date +%s`
	echo $PASS | openconnect -c /home/dwmw2/.cert/certificate.p12 --key-password-from-fsid $VPNSERVER -x foo.xml --script /etc/vpnc/vpnc-script --mtu 1266 -u david.woodhouse at intel.com --passwd-on-stdin
    if [ $? -eq 2 ]; then
	echo Exit code 2
	exit 1
    fi
    NOW=`date +%s`
    if [ $NOW -lt $(($THEN + 60)) ]; then
	echo Need to wait $(($THEN + 60 - $NOW)) seconds
	sleep $(($THEN + 60 - $NOW))
    fi
done

-- 
dwmw2




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux