*.o
l2tpns
+nsctl
state.dump
*.swp
cluster_master
+++ /dev/null
-#!/usr/bin/perl -w
-# vim:ft=perl
-
-die "l2tpns requires RedHat 7.3 or above" if i_isa("SOE_linux_rh6");
-
-my $restart = 0;
-
-my %conf = ();
-for my $c (i_isa_fetchall('L2tpns_config')) {
- foreach my $opt (keys %$c) {
- if (ref $conf{$opt} and ref $conf{$opt} eq 'ARRAY') {
- $c->{$opt} = [ $c->{$opt} ] unless ref $c->{$opt};
- push @{$conf{$opt}}, @{$c->{$opt}};
- } elsif (ref $c->{$opt} and ref $c->{$opt} eq 'ARRAY') {
- # Make sure to copy to avoid changing /etc/machine
- $conf{$opt} = [ $conf{$opt} ] if $conf{$opt};
- $conf{$opt} ||= [];
- push @{$conf{$opt}}, @{$c->{$opt}};
- } else {
- $conf{$opt} = $c->{$opt};
- }
- }
-}
-
-$conf{Address_pool} ||= i_isa("Address_pool"); # backwards compat
-
-unless (i_isa("No_throttle")) {
- chomp(my $kernel = `uname -r`);
- print "WARN: l2tpns requires kernel 2.4.18-187OIE1. This is included in $_path/rpm/kernel-2.4.18-187OIE1.i386.rpm\n"
- unless ($kernel eq '2.4.18-187OIE1' || $kernel =~ /^2\.4\.2\d/);
-}
-
-# Recompile the server if needed
-if ((stat("src/l2tpns.c"))[9] > (stat("src/l2tpns"))[9]) {
- chdir("src");
- command("make clean");
- command("make");
- chdir("..");
- $restart++;
-}
-
-command("mkdir /dev/net") and ++$restart unless -d "/dev/net";
-command("mknod /dev/net/tun c 10 200") and ++$restart unless -c "/dev/net/tun";
-
-my $cluster = i_isa('Gateway_cluster');
-my $cluster_name = $cluster->{master} || $cluster->{slave} || die 'Not a master or a slave' if $cluster;
-my $master = $cluster && $cluster->{master};
-my $command = $master ? "cluster_master" : "l2tpns";
-push @{$m{$_class}->{Monitor}->{process}->{tests}}, $command;
-
-
-if ($cluster) {
- $conf{'save state'} ||= 'no';
- if (!$master && !$cluster->{bind_address}) {
- die 'No bind address for cluster slave';
- }
- $conf{'bind address'} ||= $cluster->{bind_address} unless $master;
- my $cluster_master;
- my @cluster_slaves = ();
- my @cluster_slave_addresses = ();
- foreach my $host (type_list('Gateway_cluster')) {
- my $host_conf = OIE::Conform::i_isa(\%m, $host, 'Gateway_cluster');
- if ($host_conf->{master} eq $cluster_name) {
- $cluster_master = $host;
- } elsif ($host_conf->{slave} eq $cluster_name) {
- push @cluster_slaves, $host;
- push @{$conf{Address_pool}}, map { "$host_conf->{bind_address}:$_" } @{$m{$host}->{L2tpns_config}->{Address_pool}} if $master;
- push @cluster_slave_addresses, $m{$host}->{int_eth0}->{ip};
- }
- }
-
- if ($master) {
- push @{$m{$_class}->{inittab_include}},
- "$_path/src/cluster_master $m{$iam}->{int_eth0}->{ip}";
- push @{$m{$_class}->{inittab_disable}},
- "$_path/src/l2tpns";
- $m{$_class}->{Firewall}->{$_} = '32792:udp'
- foreach @cluster_slave_addresses;
- }
- $conf{'cluster master'} ||= $m{$cluster_master}->{int_eth0}->{ip};
-}
-
-# Build up address pool
-my $pool = $conf{Address_pool};
-if ($pool) {
- my $address_pool = "";
-
- foreach (@$pool) {
- $address_pool .= "$_\n";
- }
-
- text_install("$_path/etc/ip_pool.txt", $address_pool) and $restart++;
-} else {
- print "WARN: No Address_pool defined in machines.\n";
-}
-delete $conf{"Address_pool"}; # Don't add it to the conf file
-
-my $servicenet = $conf{"servicenet"};
-if ($servicenet) {
- $conf{'servicenet'} = 'yes';
- push @{$conf{plugin}}, 'servicenet' unless grep /^servicenet$/, @{$conf{plugin}};
- file_install("/etc/rc.d/rc.firewall.INPUT.servicenet", "$_path/etc/rc.firewall.INPUT.servicenet", undef, undef,
- "s/#SERVICENET#/$servicenet/g")
- and queue_command("/etc/rc.d/rc.firewall");
-} else {
- $conf{'servicenet'} = 'no';
- # Uninstall
- if (-f "/etc/rc.d/rc.firewall.INPUT.servicenet") {
- unlink "/etc/rc.d/rc.firewall.INPUT.servicenet";
- command("iptables -F snet");
- }
-}
-
-# Note that we don't file_install the config file, but instead modify it
-# in place
-
-my $config = slurp_file("$_path/etc/l2tpns.cfg");
-
-# plugins need to go first, else they won't pick up params
-foreach my $p (@{$conf{plugin}}) {
- $config =~ s/^#?\s*plugin\s+=\s+\Q$p\E$/plugin = $p/mg or
- $config = "plugin = $p\n\n$config";
-}
-delete $conf{plugin};
-
-foreach my $c (keys %conf) {
- $config =~ s/^#?\s*\Q$c\E\s+=\s+.*$/$c = $conf{$c}/mg or
- $config .= "$c = $conf{$c}\n\n";
-}
-
-file_install("/etc/rc.d/rc.firewall.INPUT.l2tpns", "$_path/etc/rc.firewall.INPUT.l2tpns")
- and queue_command("/etc/rc.d/rc.firewall");
-
-text_install("$_path/etc/l2tpns.cfg", $config) and $restart++;
-
-queue_command("killall $command") if $restart;
-
+++ /dev/null
-#!/bin/sh
-#
-# install - install a program, script, or datafile
-# This comes from X11R5.
-#
-# Calling this script install-sh is preferred over install.sh, to prevent
-# `make' implicit rules from creating a file called install from it
-# when there is no Makefile.
-#
-# This script is compatible with the BSD install script, but was written
-# from scratch.
-#
-
-
-# set DOITPROG to echo to test this script
-
-# Don't use :- since 4.3BSD and earlier shells don't like it.
-doit="${DOITPROG-}"
-
-
-# put in absolute paths if you don't have them in your path; or use env. vars.
-
-mvprog="${MVPROG-mv}"
-cpprog="${CPPROG-cp}"
-chmodprog="${CHMODPROG-chmod}"
-chownprog="${CHOWNPROG-chown}"
-chgrpprog="${CHGRPPROG-chgrp}"
-stripprog="${STRIPPROG-strip}"
-rmprog="${RMPROG-rm}"
-mkdirprog="${MKDIRPROG-mkdir}"
-
-tranformbasename=""
-transform_arg=""
-instcmd="$mvprog"
-chmodcmd="$chmodprog 0755"
-chowncmd=""
-chgrpcmd=""
-stripcmd=""
-rmcmd="$rmprog -f"
-mvcmd="$mvprog"
-src=""
-dst=""
-dir_arg=""
-
-while [ x"$1" != x ]; do
- case $1 in
- -c) instcmd="$cpprog"
- shift
- continue;;
-
- -d) dir_arg=true
- shift
- continue;;
-
- -m) chmodcmd="$chmodprog $2"
- shift
- shift
- continue;;
-
- -o) chowncmd="$chownprog $2"
- shift
- shift
- continue;;
-
- -g) chgrpcmd="$chgrpprog $2"
- shift
- shift
- continue;;
-
- -s) stripcmd="$stripprog"
- shift
- continue;;
-
- -t=*) transformarg=`echo $1 | sed 's/-t=//'`
- shift
- continue;;
-
- -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
- shift
- continue;;
-
- *) if [ x"$src" = x ]
- then
- src=$1
- else
- # this colon is to work around a 386BSD /bin/sh bug
- :
- dst=$1
- fi
- shift
- continue;;
- esac
-done
-
-if [ x"$src" = x ]
-then
- echo "install: no input file specified"
- exit 1
-else
- true
-fi
-
-if [ x"$dir_arg" != x ]; then
- dst=$src
- src=""
-
- if [ -d $dst ]; then
- instcmd=:
- else
- instcmd=mkdir
- fi
-else
-
-# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
-# might cause directories to be created, which would be especially bad
-# if $src (and thus $dsttmp) contains '*'.
-
- if [ -f $src -o -d $src ]
- then
- true
- else
- echo "install: $src does not exist"
- exit 1
- fi
-
- if [ x"$dst" = x ]
- then
- echo "install: no destination specified"
- exit 1
- else
- true
- fi
-
-# If destination is a directory, append the input filename; if your system
-# does not like double slashes in filenames, you may need to add some logic
-
- if [ -d $dst ]
- then
- dst="$dst"/`basename $src`
- else
- true
- fi
-fi
-
-## this sed command emulates the dirname command
-dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
-
-# Make sure that the destination directory exists.
-# this part is taken from Noah Friedman's mkinstalldirs script
-
-# Skip lots of stat calls in the usual case.
-if [ ! -d "$dstdir" ]; then
-defaultIFS='
-'
-IFS="${IFS-${defaultIFS}}"
-
-oIFS="${IFS}"
-# Some sh's can't handle IFS=/ for some reason.
-IFS='%'
-set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
-IFS="${oIFS}"
-
-pathcomp=''
-
-while [ $# -ne 0 ] ; do
- pathcomp="${pathcomp}${1}"
- shift
-
- if [ ! -d "${pathcomp}" ] ;
- then
- $mkdirprog "${pathcomp}"
- else
- true
- fi
-
- pathcomp="${pathcomp}/"
-done
-fi
-
-if [ x"$dir_arg" != x ]
-then
- $doit $instcmd $dst &&
-
- if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
- if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
- if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
- if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
-else
-
-# If we're going to rename the final executable, determine the name now.
-
- if [ x"$transformarg" = x ]
- then
- dstfile=`basename $dst`
- else
- dstfile=`basename $dst $transformbasename |
- sed $transformarg`$transformbasename
- fi
-
-# don't allow the sed command to completely eliminate the filename
-
- if [ x"$dstfile" = x ]
- then
- dstfile=`basename $dst`
- else
- true
- fi
-
-# Make a temp file name in the proper directory.
-
- dsttmp=$dstdir/#inst.$$#
-
-# Move or copy the file name to the temp name
-
- $doit $instcmd $src $dsttmp &&
-
- trap "rm -f ${dsttmp}" 0 &&
-
-# and set any options; do chmod last to preserve setuid bits
-
-# If any of these fail, we abort the whole thing. If we want to
-# ignore errors from any of these, just make sure not to ignore
-# errors from the above "$doit $instcmd $src $dsttmp" command.
-
- if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
- if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
- if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
- if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
-
-# Now rename the file to the real destination.
-
- $doit $rmcmd -f $dstdir/$dstfile &&
- $doit $mvcmd $dsttmp $dstdir/$dstfile
-
-fi &&
-
-
-exit 0
initdata();
init_cli();
read_config_file();
- log(0, 0, 0, 0, "$Id: l2tpns.c,v 1.3 2004-03-05 00:22:06 fred_nerk Exp $\n(c) Copyright 2002 FireBrick (Andrews & Arnold Ltd / Watchfront Ltd) - GPL licenced\n");
+ log(1, 0, 0, 0, "L2TPNS Version 1.1.0 - http://l2tpns.sourceforge.net/\n");
+ log(1, 0, 0, 0, "Licensed under the GPL\n");
/* Start up the cluster first, so that we don't have two machines with
* the same IP at once.