#!/usr/bin/perl
+# udptunnel-reconf
+# Set up the relevant stuff in /etc/userv/vpn, and then run
+# this. It should tell you what to do to inittab and ipif-networks.
+
+# This is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with userv-utils; if not, write to the Free Software
+# Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# $Id: udptunnel-reconf.pl,v 1.1.2.3 2000/12/11 01:53:01 ian Exp $
use Socket;
-#$sharedir= '/usr/local/share/userv/udptunnelconf';
-$sharedir= '/home/ian/things/userv-utils/udptunnelconf';
-$confdir= '/etc/udptunnel';
+# @@@-
+$shareuserv= "`pwd`";
+$etcvpn= "`pwd`";
+$varlibvpn= "`pwd`";
+# -@@@
sub badusage () { die "usage: udptunnel-reconf [<directory>]\n"; }
$debug=0;
badusage();
}
-if (@ARGV) { $confdir= shift @ARGV; }
+if (@ARGV) { $etcvpn= shift @ARGV; }
badusage() if @ARGV;
-chdir $confdir or fault("$confdir: $!");
+chdir $etcvpn or fault("$etcvpn: $!");
sub run_m4 ($$$) {
my ($wanted, $site, $variable) = @_;
$x= "m4 -P -DWANTED=$wanted -DWHVARIABLE=V_$variable -DV_global=global ".
- "-DV_site=$site ".
- "-DV_defaults=$sharedir/defaults $sharedir/config.m4";
+ "-DV_site=$site -DV_varlibvpn=$varlibvpn ".
+ "-DV_defaults=$shareuserv/udptunnel-vpn-defaults ".
+ "$shareuserv/udptunnel-vpn-config.m4";
print STDERR $x,"\n" if $debug>=2;
open X, "$x |" or die $!;
undef $/;
rename "$fn.new",$fn or die $!;
}
-write_file(var_global(ipifnetsfile),'ipifnetsfile','', $ipif_file);
+$ipifnetsfile= var_global(ipifnetsfile);
+write_file($ipifnetsfile,'ipifnetsfile','', $ipif_file);
$active_file= '';
$inittab= '';
foreach $site (@actives) {
$active_file.= "$site\t".var_site('activesxinfo')."\n";
$inittab.= sprintf("t%d", $ix++).':'.var_site('inittab_line')."\n";
- write_file(var_site('invoke_file'), 'invoke_file',
- var_site('invoke_head'),
- var_site('invoke_body'));
+ $invoke_file= var_site('invoke_file');
+ write_file($invoke_file, 'invoke_file',
+ var_site('invoke_head'), var_site('invoke_body'));
+ chmod 0777&~umask, $invoke_file or die $!;
}
write_file(var_global('activesfile'),'activesfile', '',$active_file);
-write_file(var_global('inittab_fragfile'),'inittab_fragfile',
-"# You can cut and paste all or part of this into your inittab if you like.",
- $inittab);
+
+print
+"# You can cut and paste all or part of this into your inittab if you like:\n",
+ $inittab;
+
+print
+"# And consider adding this line, or some of this file's contents,\n".
+"# to your /etc/userv/ipif-networks:\n",
+ "$ipifnetsfile\n"
+ if $ipifnetsfile =~ m,^/,;
$passive_file= '';
foreach $site (@passives) {