Commit 47ddaeb0 authored by Leigh B. Stoller's avatar Leigh B. Stoller

More IXP changes:

* Put a hosts file in /opt/config, which gets copied to /etc/hosts on
  the IXP.
* Put a resolv.conf in /opt/config, which gets copied to /etc on
  the IXP.
* Add support for startcmd, which will override the default boot.
* Do not squash root in the /opt export.
parent b81854af
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
# Copyright (c) 2000-2003 University of Utah and the Flux Group. # Copyright (c) 2000-2003 University of Utah and the Flux Group.
# All rights reserved. # All rights reserved.
# #
# TODO: Startup command in rc.ixp. Use old version.
use English; use English;
use Getopt::Std; use Getopt::Std;
use Socket; use Socket;
...@@ -72,6 +74,7 @@ my $confdir = "/opt/config"; ...@@ -72,6 +74,7 @@ my $confdir = "/opt/config";
my $ixtemplate = "ixsys.l3fwdr.template"; my $ixtemplate = "ixsys.l3fwdr.template";
my $ixconfig = "ixsys.l3fwdr"; my $ixconfig = "ixsys.l3fwdr";
my $ixroute = "route.l3fwdr"; my $ixroute = "route.l3fwdr";
my $bootscript = "$confdir/bootscript";
# #
# Okay, lets background so we can redirect all the output. We wait for the # Okay, lets background so we can redirect all the output. We wait for the
...@@ -116,11 +119,44 @@ if (! ixpsetup($ixpid)) { ...@@ -116,11 +119,44 @@ if (! ixpsetup($ixpid)) {
exit(0); exit(0);
} }
#
# Gen up a hostnames in the config dir.
#
dohostnames("$confdir/hosts");
#
# Copy resolv.conf
#
system("cp -f /etc/resolv.conf $confdir") == 0
or die("*** $0:\n".
" Could not cp resolv.conf!\n");
my $TM = OPENTMCC(TMCCCMD_STARTUP);
my $startcmd = <$TM>;
CLOSETMCC($TM);
if (defined($startcmd)) {
open(RUN, "> $bootscript")
or die("Could not open $bootscript: $!");
if ($startcmd =~ /CMD=\'(.+)\' UID=([0-9A-Za-z]+)/) {
print RUN "#!/bin/sh\n";
print RUN "\n";
print RUN "$1\n";
}
else {
warn "*** WARNING: Bad startupcmd line: $startcmd";
}
close(RUN);
chmod(0755, $bootscript);
}
# #
# Ask tmcd for the configuration data. Create the file and store into # Ask tmcd for the configuration data. Create the file and store into
# the directory. # the directory.
# #
my $TM = OPENTMCC(TMCCCMD_SUBCONFIG); $TM = OPENTMCC(TMCCCMD_SUBCONFIG);
while (<$TM>) { while (<$TM>) {
chomp(); chomp();
SWITCH1: { SWITCH1: {
...@@ -151,6 +187,7 @@ while (<$TM>) { ...@@ -151,6 +187,7 @@ while (<$TM>) {
}; };
/^NETMASK="(.*)"$/ && do { /^NETMASK="(.*)"$/ && do {
$config{"IXP1200_MASK"} = $1; $config{"IXP1200_MASK"} = $1;
$config{"HOST_MASK"} = $1;
last SWITCH1; last SWITCH1;
}; };
print STDERR "Invalid Directive: $_\n"; print STDERR "Invalid Directive: $_\n";
...@@ -176,6 +213,14 @@ foreach my $conf (keys(%config)) { ...@@ -176,6 +213,14 @@ foreach my $conf (keys(%config)) {
print RC "export $conf=$val\n"; print RC "export $conf=$val\n";
} }
# Need this one too.
print RC "export HOST_CNTL_I=" . `$BINDIR/control_interface`;
# And this. Could be done elsewhere ...
my (undef,undef,undef,undef,@ipaddrs) = gethostbyname("fs.emulab.net");
$FSIP = inet_ntoa($ipaddrs[0]);
print RC "export FS_IP=$FSIP\n";
print RC "export PROJECT=$pid\n";
print RC "\n"; print RC "\n";
print RC "./.create_environment\n"; print RC "./.create_environment\n";
close(RC); close(RC);
...@@ -201,43 +246,53 @@ system("mv -f create_environment.rc.new create_environment.rc") == 0 ...@@ -201,43 +246,53 @@ system("mv -f create_environment.rc.new create_environment.rc") == 0
# #
my @ifacelist = doifconfig(); my @ifacelist = doifconfig();
if (@ifacelist) { #
# # Copy the template to the config file, replace the TAG with the
# Copy the template to the config file, replace the TAG with the # interfaces we got above. When the card boots its little linux,
# interfaces we got above. When the card boots its little linux, # it will run a script that reads this new file (the directory
# it will run a script that reads this new file (the directory # we write it to is NFS mounted by the card).
# we write it to is NFS mounted by the card). #
# open(TEMPL, "$confdir/$ixtemplate") or
open(TEMPL, "$confdir/$ixtemplate") or die("Could not open $confdir/$ixtemplate: $!\n");
die("Could not open $confdir/$ixtemplate: $!\n"); open(CONF, ">$confdir/$ixconfig") or
open(CONF, ">$confdir/$ixconfig") or die("Could not open $confdir/$ixconfig: $!\n");
die("Could not open $confdir/$ixconfig: $!\n");
while (<TEMPL>) { while (<TEMPL>) {
print CONF $_; print CONF $_;
if ($_ =~ /^\# IXPINTERFACES:$/) { if ($_ =~ /^\# IXPINTERFACES:$/) {
foreach my $iface (@ifacelist) { foreach my $iface (@ifacelist) {
my $inet = $iface->{"IPADDR"};
my $mask = $iface->{"IPMASK"};
my $mac = $iface->{"MAC"};
my ($ifaceno) = ($iface->{"IFACE"} =~ /^[a-zA-Z]*(\d*)/);
my $bcast = inet_ntoa((inet_aton($inet) & inet_aton($mask)) |
~(inet_aton($mask)));
if ($mac =~ /^(\w{2})(\w{2})(\w{2})(\w{2})(\w{2})(\w{2})$/) { my $inet = $iface->{"IPADDR"};
$mac = "$1:$2:$3:$4:$5:$6"; my $mask = $iface->{"IPMASK"};
} my $mac = $iface->{"MAC"};
$ifaceno--; my ($ifaceno) = ($iface->{"IFACE"} =~ /^[a-zA-Z]*(\d*)/);
my $bcast = inet_ntoa((inet_aton($inet) & inet_aton($mask)) |
~(inet_aton($mask)));
print CONF "interface $ifaceno $inet $bcast $mask $mac 1\n"; if ($mac =~ /^(\w{2})(\w{2})(\w{2})(\w{2})(\w{2})(\w{2})$/) {
$mac = "$1:$2:$3:$4:$5:$6";
} }
$ifaceno--;
print CONF "interface $ifaceno $inet $bcast $mask $mac 1\n";
}
# Give the rest of the interfaces a stub setup. Otherwise the
# card wedges. Amazing. Something to do with arp.
for ($i = scalar(@ifacelist) + 1; $i <=4; $i++) {
my $ifaceno = $i - 1;
my $mac = "00:23:45:67:89:0${i}";
my $mask = "255.255.255.0";
my $inet = "10.254.$i.0";
my $bcast = "10.254.$i.255";
print CONF "interface $ifaceno $inet $bcast $mask $mac 1\n";
} }
} }
close(TEMPL);
close(CONF);
} }
close(TEMPL);
close(CONF);
# #
# Now set up the routes file. # Now set up the routes file.
...@@ -294,10 +349,12 @@ close(CONF); ...@@ -294,10 +349,12 @@ close(CONF);
# #
# Export the root filesystem to the IXP. # Export the root filesystem to the IXP.
# #
system("exportfs -o rw,root_squash " . $config{"IXP1200_IP"} . ":/") == 0 system("exportfs -o rw,no_root_squash " . $config{"IXP1200_IP"} . ":/opt") == 0
or die("*** $0:\n". or die("*** $0:\n".
" Could not exportfs / to IXP!\n"); " Could not exportfs / to IXP!\n");
exit(0);
# #
# Fire off the boot. # Fire off the boot.
# #
......
...@@ -5,15 +5,17 @@ ...@@ -5,15 +5,17 @@
# All rights reserved. # All rights reserved.
# #
# A totally bogus hack. This is run on the card. # A totally bogus hack. This is run on the card. Must copy to /opt/config.
BOOTDIR="/nfs/config" BOOTDIR="/opt/config"
armdir="/nfs/ixasdk/bin/arm-be" armdir="/opt/ixasdk/bin/arm-be"
ixconfig="ixsys.l3fwdr" ixconfig="ixsys.l3fwdr"
cd $armdir if [-x $BOOTDIR/bootscript ]; then
echo "Running local bootscript ..."
if [ -x ixstart -a -e $BOOTDIR/$ixconfig ]; then $BOOTDIR/bootscript
elif [ -x $armdir/ixstart -a -e $BOOTDIR/$ixconfig ]; then
echo "Setting up interfaces ..." echo "Setting up interfaces ..."
cd $armdir
./ixstart $BOOTDIR/$ixconfig ./ixstart $BOOTDIR/$ixconfig
fi fi
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment