4 die "l2tpns requires RedHat 7.3 or above" if i_isa("SOE_linux_rh6");
9 for my $c (i_isa_fetchall('L2tpns_config')) {
10 foreach my $opt (keys %$c) {
11 if (ref $conf{$opt} and ref $conf{$opt} eq 'ARRAY') {
12 $c->{$opt} = [ $c->{$opt} ] unless ref $c->{$opt};
13 push @{$conf{$opt}}, @{$c->{$opt}};
14 } elsif (ref $c->{$opt} and ref $c->{$opt} eq 'ARRAY') {
15 # Make sure to copy to avoid changing /etc/machine
16 $conf{$opt} = [ $conf{$opt} ] if $conf{$opt};
18 push @{$conf{$opt}}, @{$c->{$opt}};
20 $conf{$opt} = $c->{$opt};
25 $conf{Address_pool} ||= i_isa("Address_pool"); # backwards compat
27 unless (i_isa("No_throttle")) {
28 chomp(my $kernel = `uname -r`);
29 print "WARN: l2tpns requires kernel 2.4.18-187OIE1. This is included in $_path/rpm/kernel-2.4.18-187OIE1.i386.rpm\n"
30 unless ($kernel eq '2.4.18-187OIE1' || $kernel =~ /^2\.4\.2\d/);
33 # Recompile the server if needed
34 if ((stat("src/l2tpns.c"))[9] > (stat("src/l2tpns"))[9]) {
36 command("make clean");
42 command("mkdir /dev/net") and ++$restart unless -d "/dev/net";
43 command("mknod /dev/net/tun c 10 200") and ++$restart unless -c "/dev/net/tun";
45 my $cluster = i_isa('Gateway_cluster');
46 my $cluster_name = $cluster->{master} || $cluster->{slave} || die 'Not a master or a slave' if $cluster;
47 my $master = $cluster && $cluster->{master};
48 my $command = $master ? "cluster_master" : "l2tpns";
49 push @{$m{$_class}->{Monitor}->{process}->{tests}}, $command;
53 $conf{'save state'} ||= 'no';
54 if (!$master && !$cluster->{bind_address}) {
55 die 'No bind address for cluster slave';
57 $conf{'bind address'} ||= $cluster->{bind_address} unless $master;
59 my @cluster_slaves = ();
60 my @cluster_slave_addresses = ();
61 foreach my $host (type_list('Gateway_cluster')) {
62 my $host_conf = OIE::Conform::i_isa(\%m, $host, 'Gateway_cluster');
63 if ($host_conf->{master} eq $cluster_name) {
64 $cluster_master = $host;
65 } elsif ($host_conf->{slave} eq $cluster_name) {
66 push @cluster_slaves, $host;
67 push @{$conf{Address_pool}}, map { "$host_conf->{bind_address}:$_" } @{$m{$host}->{L2tpns_config}->{Address_pool}} if $master;
68 push @cluster_slave_addresses, $m{$host}->{int_eth0}->{ip};
73 push @{$m{$_class}->{inittab_include}},
74 "$_path/src/cluster_master $m{$iam}->{int_eth0}->{ip}";
75 push @{$m{$_class}->{inittab_disable}},
77 $m{$_class}->{Firewall}->{$_} = '32792:udp'
78 foreach @cluster_slave_addresses;
80 $conf{'cluster master'} ||= $m{$cluster_master}->{int_eth0}->{ip};
83 # Build up address pool
84 my $pool = $conf{Address_pool};
86 my $address_pool = "";
89 $address_pool .= "$_\n";
92 text_install("$_path/etc/ip_pool.txt", $address_pool) and $restart++;
94 print "WARN: No Address_pool defined in machines.\n";
96 delete $conf{"Address_pool"}; # Don't add it to the conf file
98 my $servicenet = $conf{"servicenet"};
100 $conf{'servicenet'} = 'yes';
101 push @{$conf{plugin}}, 'servicenet' unless grep /^servicenet$/, @{$conf{plugin}};
102 file_install("/etc/rc.d/rc.firewall.INPUT.servicenet", "$_path/etc/rc.firewall.INPUT.servicenet", undef, undef,
103 "s/#SERVICENET#/$servicenet/g")
104 and queue_command("/etc/rc.d/rc.firewall");
106 $conf{'servicenet'} = 'no';
108 if (-f "/etc/rc.d/rc.firewall.INPUT.servicenet") {
109 unlink "/etc/rc.d/rc.firewall.INPUT.servicenet";
110 command("iptables -F snet");
114 # Note that we don't file_install the config file, but instead modify it
117 my $config = slurp_file("$_path/etc/l2tpns.cfg");
119 # plugins need to go first, else they won't pick up params
120 foreach my $p (@{$conf{plugin}}) {
121 $config =~ s/^#?\s*plugin\s+=\s+\Q$p\E$/plugin = $p/mg or
122 $config = "plugin = $p\n\n$config";
124 delete $conf{plugin};
126 foreach my $c (keys %conf) {
127 $config =~ s/^#?\s*\Q$c\E\s+=\s+.*$/$c = $conf{$c}/mg or
128 $config .= "$c = $conf{$c}\n\n";
131 file_install("/etc/rc.d/rc.firewall.INPUT.l2tpns", "$_path/etc/rc.firewall.INPUT.l2tpns")
132 and queue_command("/etc/rc.d/rc.firewall");
134 text_install("$_path/etc/l2tpns.cfg", $config) and $restart++;
136 queue_command("killall $command") if $restart;