[Pkg-utopia-maintainers] Bug#740492: network-manager-vpnc: check connectivity and loop

Ritesh Raj Sarraf rrs at debian.org
Sun Mar 2 11:34:06 UTC 2014


Package: network-manager-vpnc
Version: 0.9.8.6-1
Severity: wishlist

VPN connections could drop at time. Sometimes if the keep alive packet
is not served, and also for other reasons.

It would be good to have loop option available to ensure vpn
connectivity.


Currently, under NM, I do it using the dispatcher scripts.



========================================================================
rrs at zan:~$ cat /etc/NetworkManager/dispatcher.d/02vpnc 
#!/bin/sh -e


# Script to dispatch NetworkManager events
#

if [ -z "$1" ]; then
    echo "$0: called with no interface" 1>&2
    exit 1;
fi


# Fake ifupdown environment
export IFACE="$1"
export LOGICAL="$1"
export METHOD="NetworkManager"
export VERBOSITY="0"

if [ "$CONNECTION_UUID" = "50655113-6dbb-4472-b865-3dadcfc55fb1" ]; then
    # Run the right scripts
    case "$2" in
        up)
            export MODE="start"
            export PHASE="post-up"
            /home/rrs/bin/vpnc-connect.sh
            ;;
        down)
            export MODE="stop"
            export PHASE="post-down"
            /home/rrs/bin/vpnc-disconnect.sh
            ;;
# pre-up/pre-down not implemented. See
# https://bugzilla.gnome.org/show_bug.cgi?id=387832
#        pre-up)
#            export MODE="start"
#            export PHASE="pre-up"
#            run-parts /etc/network/if-pre-up.d
#            ;;
#        pre-down)
#            export MODE="stop"
#            export PHASE="pre-down"
#            run-parts /etc/network/if-down.d
#            ;;
        hostname|dhcp4-change|dhcp6-change)
            # Do nothing
            ;;
        *)
            echo "$0: called with unknown action \`$2'" 1>&2
            exit 1
            ;;
    esac
elif [ "$CONNECTION_UUID" = "09e21baf-848a-4fcd-90a0-34b6f1890adc" ];
then
    # Run the right scripts
    case "$2" in
        up)
            export MODE="start"
            export PHASE="post-up"
            /home/rrs/bin/vpnc-connect-external.sh
            ;;
        down)
            export MODE="stop"
            export PHASE="post-down"
            /home/rrs/bin/vpnc-disconnect-external.sh
            ;;
        hostname|dhcp4-change|dhcp6-change)
            # Do nothing
            ;;
        *)
            echo "$0: called with unknown action \`$2'" 1>&2
            exit 1
            ;;
    esac
fi

exit $?
==============================================================================


And then, a loop inside the calling shell script

==============================================================================

rrs at zan:~$ cat ~/bin/vpnc-connect.sh 
#!/bin/bash

SUDO=/usr/bin/sudo
VPNC_CONNECT=/usr/sbin/vpnc-connect
VPNC_DISCONNECT=/usr/sbin/vpnc-disconnect

if ! [ `pidof -x vpnc-loop.sh` ]; then
        /home/rrs/bin/vpnc-loop.sh &
fi
rrs at zan:~$ cat ~/bin/vpnc-loop.sh 
#!/bin/sh

while true;
do
        # Check if vpnc is running.
        pidof vpnc-connect && sleep 150 && continue;

        # If not running, run it.
        sudo vpnc-disconnect >/dev/null;
        sleep 1;
        sudo vpnc-connect >/dev/null;
        sleep 150;
done

rrs at zan:~$ cat ~/bin/vpnc-disconnect.sh 
#!/bin/bash

SUDO=/usr/bin/sudo
VPNC_CONNECT=/usr/sbin/vpnc-connect
VPNC_DISCONNECT=/usr/sbin/vpnc-disconnect

test `pidof -x vpnc-loop.sh` && kill -9 `pidof -x vpnc-loop.sh`
$SUDO $VPNC_DISCONNECT

==============================================================================

Having something like this natively in NM would be a good feature.



-- System Information:
Debian Release: jessie/sid
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'unstable'), (101, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 3.13-1-amd64 (SMP w/8 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages network-manager-vpnc depends on:
ii  libc6             2.17-97
ii  libdbus-1-3       1.8.0-1
ii  libdbus-glib-1-2  0.102-1
ii  libglib2.0-0      2.38.2-5
ii  libnm-glib-vpn1   0.9.8.0-5
ii  libnm-glib4       0.9.8.0-5
ii  libnm-util2       0.9.8.0-5
ii  vpnc              0.5.3r512-2

network-manager-vpnc recommends no packages.

network-manager-vpnc suggests no packages.

-- no debconf information



More information about the Pkg-utopia-maintainers mailing list