Use the new VpnMask directive to add a route to the rest of the VPN.
[tinc] / debian / init.d
index 4733951..de3b308 100644 (file)
@@ -1,7 +1,9 @@
 #! /usr/bin/perl -w
 #
 # System startup script for tinc
 #! /usr/bin/perl -w
 #
 # System startup script for tinc
-# $Id: init.d,v 1.5 2000/05/15 17:15:52 zarq Exp $
+# $Id: init.d,v 1.6 2000/05/16 14:34:44 zarq Exp $
+#
+# Based on Lubomir Bulej's Redhat init script.
 #
 
 my $DAEMON="/usr/sbin/tincd";
 #
 
 my $DAEMON="/usr/sbin/tincd";
@@ -10,6 +12,7 @@ my $DESC="tinc daemons";
 my $TCONF="/etc/tinc";
 my $EXTRA="";
 
 my $TCONF="/etc/tinc";
 my $EXTRA="";
 
+# Put your VPN names in here.
 my $NETS="";  # This is a space-separated list of networks to be started.
 
 
 my $NETS="";  # This is a space-separated list of networks to be started.
 
 
@@ -41,6 +44,8 @@ sub vpn_load {
        } elsif ( /^[ ]*(MyOwnVPNIP|MyVirtualIP)[ =]+([^ \#]+)/i ) {
            $VPN=$2;
            chomp($VPN);
        } elsif ( /^[ ]*(MyOwnVPNIP|MyVirtualIP)[ =]+([^ \#]+)/i ) {
            $VPN=$2;
            chomp($VPN);
+       } elsif ( /^[ ]*VpnMask[ =]+([^ \#]+)/i ) {
+           $VPNMASK=$1;
        }
     }
     if(!defined($DEV)) {
        }
     }
     if(!defined($DEV)) {
@@ -55,6 +60,9 @@ sub vpn_load {
     if($VPN eq "") {
        die "tinc: No argument to MyVirtualIP/MyOwnVPNIP";
     }
     if($VPN eq "") {
        die "tinc: No argument to MyVirtualIP/MyOwnVPNIP";
     }
+    if(defined($VPNMASK) && $VPNMASK eq "") {
+       die "tinc: Invalid argument to VpnMask";
+    }
     $ADR = $VPN;
     $ADR =~ s/^([^\/]+)\/.*$/$1/;
     $LEN = $VPN;
     $ADR = $VPN;
     $ADR =~ s/^([^\/]+)\/.*$/$1/;
     $LEN = $VPN;
@@ -90,6 +98,9 @@ sub vpn_start {
     system("ifconfig $DEV hw ether $MAC");
     system("ifconfig $DEV $ADR netmask $MSK broadcast $BRD -arp");
     system("start-stop-daemon --start --quiet --pidfile /var/run/$NAME.$_[0].pid --exec $DAEMON -- -n $_[0] $EXTRA");
     system("ifconfig $DEV hw ether $MAC");
     system("ifconfig $DEV $ADR netmask $MSK broadcast $BRD -arp");
     system("start-stop-daemon --start --quiet --pidfile /var/run/$NAME.$_[0].pid --exec $DAEMON -- -n $_[0] $EXTRA");
+    if(defined($VPNMASK)) {
+       system("route add -net $ADR netmask $VPNMASK dev $DEV");
+    }
 }
 
 
 }