Script when connection is ended?

David Woodhouse dwmw2 at infradead.org
Fri Aug 13 04:57:15 EDT 2010


On Thu, 2010-08-12 at 21:46 -0500, Matthew Kitchin (public/usenet)
wrote:
>   Is there any way to call a script when a connection is ended from 
> reaching your timeout set on the VPN server?
> I can certainly do a cron job to check and see if if the connection is
> up. I just thought it would be cool if there was anyway to launch 
> something automatically when you were disconnected for reaching you 
> session time limit. 

We already call the configured script with 'reason=disconnect'. Although
we do that for *any* disconnection, and we don't provide the reason.

It wouldn't be hard to make openconnect provide the reason....

diff --git a/tun.c b/tun.c
index a581327..05117df 100644
--- a/tun.c
+++ b/tun.c
@@ -628,6 +628,7 @@ void shutdown_tun(struct openconnect_info *vpninfo)
 	} else {
 		if (vpninfo->vpnc_script) {
 			setenv("reason", "disconnect", 1);
+			setenv("CISCO_DISCONNECT_REASON", vpninfo->quit_reason, 1);
 			if (system(vpninfo->vpnc_script) == -1) {
 				vpninfo->progress(vpninfo, PRG_ERR,
 						  "Failed to spawn script '%s': %s\n",

However, before changing the interface to vpnc-script by adding a new
variable like this, we should talk to vpnc folks and see if they want to
add something similar.

It would be useful to make NetworkManager use this extra reason string
too -- currently, you just get a pop-up saying the connection failed,
without any indication of why it really disconnected.

-- 
David Woodhouse                            Open Source Technology Centre
David.Woodhouse at intel.com                              Intel Corporation




More information about the openconnect-devel mailing list