projects
/
tinc
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Use the new VpnMask directive to add a route to the rest of the VPN.
[tinc]
/
debian
/
init.d
diff --git
a/debian/init.d
b/debian/init.d
index
c9a75fc
..
de3b308
100644
(file)
--- a/
debian/init.d
+++ b/
debian/init.d
@@
-1,30
+1,27
@@
#! /usr/bin/perl -w
#
# System startup script for tinc
#! /usr/bin/perl -w
#
# System startup script for tinc
-# $Id: init.d,v 1.3 2000/05/13 00:54:27 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 $NAME="tinc";
my $DESC="tinc daemons";
#
my $DAEMON="/usr/sbin/tincd";
my $NAME="tinc";
my $DESC="tinc daemons";
-my $NETS="test2";
my $TCONF="/etc/tinc";
my $TCONF="/etc/tinc";
-my $EXTRA="
-d
";
+my $EXTRA="";
-if (! -f $DAEMON) { exit 0; }
+# Put your VPN names in here.
+my $NETS=""; # This is a space-separated list of networks to be started.
-# Check the daemon
-if ( ! -x $DAEMON ) {
- print "**tinc: daemon $DAEMON does not exist or is not executable!\n";
- exit 1;
-}
-# Check the configuration directory
-if ( ! -d $TCONF ) {
- print "**tinc: configuration directory ($TCONF) not found!\n";
- exit 1;
-}
+if (! -f $DAEMON) { exit 0; }
+if ($NETS eq "") {
+ warn "Please edit /etc/init.d/tinc before attempting to start tinc.\n";
+ exit 0;
+}
##############################################################################
# vpn_load () Loads VPN configuration
##############################################################################
# vpn_load () Loads VPN configuration
@@
-47,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)) {
@@
-61,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;
@@
-92,17
+94,13
@@
sub vpn_load {
sub vpn_start {
vpn_load($_[0]) || die "tinc: could not vpn_load $_[0]";
sub vpn_start {
vpn_load($_[0]) || die "tinc: could not vpn_load $_[0]";
- if (! -c "/dev/$DEV") {
- if (-e "/dev/$DEV") {
- unlink("/dev/$DEV");
- }
- $num = $NUM + 16;
- system("echo mknod --mode=0600 /dev/$DEV c 36 $num");
- }
system("insmod ethertap -s --name=\"ethertap$NUM\" unit=\"$NUM\" >/dev/null");
system("ifconfig $DEV hw ether $MAC");
system("insmod ethertap -s --name=\"ethertap$NUM\" unit=\"$NUM\" >/dev/null");
system("ifconfig $DEV hw ether $MAC");
- system("ifconfig $DEV $ADR netmask $MSK broadcast $BRD");
+ 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("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");
+ }
}
}
@@
-111,7
+109,7
@@
sub vpn_start {
##############################################################################
# vpn_stop () Stops specified VPN
#
##############################################################################
# vpn_stop () Stops specified VPN
#
-# $
1
... VPN to stop
+# $
_[0]
... VPN to stop
sub vpn_stop {
vpn_load($_[0]) || return 1;
sub vpn_stop {
vpn_load($_[0]) || return 1;