simplify cases and add ifconfig_syntax_del variable
authorDaniel Lenski <dlenski@gmail.com>
Wed, 18 Nov 2020 04:52:36 +0000 (20:52 -0800)
committerDaniel Lenski <dlenski@gmail.com>
Wed, 25 Nov 2020 18:45:47 +0000 (18:45 +0000)
Signed-off-by: Daniel Lenski <dlenski@gmail.com>
vpnc-script

index af7e9411f451e0ba246a5c3f29d97f92694dccce..191bc00d4d39e5e9cd494980e145afdeccf59c82 100755 (executable)
@@ -101,6 +101,7 @@ if [ "$OS" = "Linux" ]; then
        route_syntax_gw="gw"
        route_syntax_del="del"
        route_syntax_netmask="netmask"
+       ifconfig_syntax_del="del"
 else
        # iproute2 is Linux only; if `which ip` returns something on another OS, it's likely an unrelated tool
        # (see https://github.com/dlenski/openconnect/issues/132#issuecomment-470475009)
@@ -109,6 +110,7 @@ else
        route_syntax_gw=""
        route_syntax_del="delete"
        route_syntax_netmask="-netmask"
+       ifconfig_syntax_del="delete"
 fi
 if [ "$OS" = "SunOS" ]; then
        route_syntax_interface="-interface"
@@ -390,7 +392,7 @@ else # use route command
                # route and use its gateway.
                case "$VPNGATEWAY" in
                *:*)    route add -inet6 -host "$VPNGATEWAY" $route_syntax_gw "`get_ipv6_default_gw`";;
-               *.*)    route add -host "$VPNGATEWAY" $route_syntax_gw "`get_default_gw`";;
+               *)      route add -host "$VPNGATEWAY" $route_syntax_gw "`get_default_gw`";;
                esac
        }
 
@@ -401,7 +403,7 @@ else # use route command
        del_vpngateway_route() {
                case "$VPNGATEWAY" in
                *:*)    route $route_syntax_del -inet6 -host "$VPNGATEWAY" $route_syntax_gw "`get_ipv6_default_gw`";;
-               *.*)    route $route_syntax_del -host "$VPNGATEWAY" $route_syntax_gw "`get_default_gw`";;
+               *)      route $route_syntax_del -host "$VPNGATEWAY" $route_syntax_gw "`get_default_gw`";;
                esac
        }
 
@@ -501,7 +503,7 @@ else # use route command
        }
 
        reset_ipv6_default_route() {
-               route $route_syntax_del -inet6 ::/1 "$INTERNAL_IP6_ADDRESS" 
+               route $route_syntax_del -inet6 ::/1 "$INTERNAL_IP6_ADDRESS"
                route $route_syntax_del -inet6 8000::/1 "$INTERNAL_IP6_ADDRESS"
                :
        }
@@ -1080,7 +1082,7 @@ do_disconnect() {
                        INTERNAL_IP6_NETMASK="$INTERNAL_IP6_ADDRESS/128"
                fi
                if [ -n "$INTERNAL_IP6_NETMASK" ]; then
-                       ifconfig "$TUNDEV" inet6 delete $INTERNAL_IP6_NETMASK
+                       ifconfig "$TUNDEV" inet6 $ifconfig_syntax_del $INTERNAL_IP6_NETMASK
                fi
        fi