Commit c9a1a6f0 authored by Leigh B Stoller's avatar Leigh B Stoller
Browse files

Stub copies of the genirack setup scripts, to be updated later

when we have a candidate powder aggregate.
parent f662c2f3
......@@ -186,6 +186,7 @@ $MAINSITE = @TBMAINSITE@;
$PGENISUPPORT = @PROTOGENI_SUPPORT@;
$PROTOGENI_GENIRACK = @PROTOGENI_GENIRACK@;
$CONFIG_TARGETSYS = @CONFIG_TARGETSYS@;
$TARGETSYS_TARGET = @TARGETSYS_TARGET@;
$PORTAL_ENABLE = @PORTAL_ENABLE@;
$ELABINELAB = @ELABINELAB@;
$DBNAME = "@TBDBNAME@";
......
This diff is collapsed.
#
# Additional stuff for setting up a target system
#
use strict;
use libinstall;
use installvars;
my $CONFIGVARS = "$PREFIX/configvars.txt";
my $PORTSRC = "http://www.emulab.net/downloads/FreeBSD-".
"${FBSD_MAJOR}.${FBSD_MINOR}" . "-ports.tar.gz";
sub Install($$$)
{
my ($server, $isupdate, $impotent) = @_;
my %configvars = ();
# Replace if this script does an update for ip/domain.
return 0
if ($isupdate);
SET_TESTBED_VERSION($TARGETSYS_TARGET);
Phase "targetsys", "Doing additional target system tasks", sub {
PhaseSkip("Not a target system")
if (!$CONFIG_TARGETSYS);
Phase "config", "Reading in config variables", sub {
PhaseFail("No config file")
if (! -e $CONFIGVARS);
open(CN, $CONFIGVARS)
or PhaseFail("Could not open $CONFIGVARS: $!");
while (<CN>) {
if ($_ =~ /^([-\w]*)\s*=\s*(.*)$/) {
my $key = $1;
my $val = $2;
if ($val =~ /^'(.*)'$/) {
$val = $1;
}
$configvars{$key} = "$val";
}
}
close(CN);
};
#
# Have not figured this out yet; it runs during boss setup but
# the line in fstab gets lost. Run again and it works fine.
#
Phase "swapon", "Reruning rc.freebsd", sub {
PhaseSkip("already enabled") unless `grep -q swap $FSTAB`;
ExecQuietFatal("/usr/local/etc/emulab/rc/rc.freebsd");
};
Phase "rclocal", "Removing rc.local", sub {
PhaseSkip("already deleted")
if (! -e $RCLOCAL);
DeleteFileFatal($RCLOCAL);
};
Phase "emulabvar", "Removing stuff from /var/emulab/boot", sub {
PhaseSkip("already deleted")
if (! -e "/var/emulab/boot/vmname");
DeleteFileFatal("/var/emulab/boot/vmname");
};
#
# Need to remove the ELABINELAB flag.
#
my $OLDDEFSFILE = "$main::TOP_SRCDIR/defs-elabinelab";
my $NEWDEFSFILE = "$main::TOP_SRCDIR/defs-targetsys";
Phase "elabinelab", "Removing ELABINELAB from defs file", sub {
DoneIfExists($NEWDEFSFILE);
ExecQuietFatal("cat $OLDDEFSFILE | ".
" sed -e 's/^ELABINELAB/#ELABINELAB/' ".
" -e 's/^WWWHOST=boss/WWWHOST=www/' ".
" -e 's/^EXTERNAL_NTPS/#EXTERNAL_NTPS/' ".
" > $NEWDEFSFILE");
};
#
# Build and install software without ELABINELAB defined.
#
Phase "Software", "Rebuilding and Reinstalling Software", sub {
DoneIfExists("$PREFIX/marker");
Phase "cleaning", "Cleaning (please be patient)", sub {
ExecQuietFatal("cd $TOP_OBJDIR; $GMAKE clean");
};
Phase "config", "Configuring (please be patient)", sub {
ExecQuietFatal("cd $TOP_OBJDIR; ".
" $main::TOP_SRCDIR/configure ".
" --with-TBDEFS=$NEWDEFSFILE ".
" --disable-windows");
};
Phase "installing", "Installing (please be patient)", sub {
ExecQuietFatal("cd $TOP_OBJDIR; $GMAKE opsfs-install");
};
Phase "rc.testbed", "Installing testbed RC scripts", sub {
ExecQuietFatal("$GMAKE -C $TOP_OBJDIR/rc.d control-install");
};
Phase "ntpd", "Installing testbed ntp config", sub {
ExecQuietFatal("$GMAKE -C $TOP_OBJDIR/ntpd control-install");
};
Phase "control", "Installing control node clientside scripts", sub {
ExecQuietFatal("$GMAKE -C $TOP_OBJDIR/clientside/tmcc/freebsd ".
"control-install");
};
CreateFile("$PREFIX/marker", "genirack install marker");
};
#
# Reset the mailing lists. We do this late so that the target
# admins do not see a bunch of email until we are really ready.
#
Phase "emaillists", "Changing target for email lists", sub {
opendir(DIR, "/etc/mail/lists") or
PhaseFail("Cannot opendir /etc/mail/lists: $!");
my @lists = grep { $_ ne "." && $_ ne ".." } readdir(DIR);
closedir(DIR);
my @default = "genirack-ops\@flux.utah.edu";
if (exists($configvars{"TARGETSYS_TBOPS"})) {
@default = split(",", $configvars{"TARGETSYS_TBOPS"});
}
foreach my $list (@lists) {
my @where = @default;
my $fname = "/etc/mail/lists/$list";
DoneIfEdited($fname)
if (-e $fname);
DeleteFileFatal($fname)
if (-e $fname);
CreateFileFatal($fname, "# $list")
if (! -e $fname);
Phase "emaillist", "Changing target for $list", sub {
if ($list eq "testbed-logs" || $list eq "testbed-audit") {
@where = split(",", $configvars{"TARGETSYS_TBLOGS"})
if (exists($configvars{"TARGETSYS_TBLOGS"}));
}
elsif ($list eq "testbed-stated") {
@where = split(",", $configvars{"TARGETSYS_TBSTATED"})
if (exists($configvars{"TARGETSYS_TBSTATED"}));
}
AppendToFileFatal($fname, @where);
};
}
};
#
# Also grab the port source while close to the server.
#
Phase "portsrc", "Getting port source tarball", sub {
DoneIfExists("$PREFIX/ports.tar.gz");
FetchFileFatal($PORTSRC, "$PREFIX/ports.tar.gz");
};
Phase "ports", "Unpacking port source tarball", sub {
DoneIfExists("$PREFIX/ports/Mk");
ExecQuietFatal("cd $PREFIX; $TAR zxf $PREFIX/ports.tar.gz");
};
Phase "portlink", "Linking to unpacked ports tree", sub {
ExecQuietFatal("/bin/rm -rf /usr/ports")
if (-e "/usr/ports" && -d "/usr/ports");
ExecQuietFatal("cd /usr; ln -sf testbed/ports .");
};
Phase "rcconf", "Updating rcconf for actual boot", sub {
my @strings = ();
push(@strings,
"ifconfig_xn0=\"inet ". $configvars{"TARGETSYS_OPSIP"} .
" netmask " . $configvars{"TARGETSYS_NETMASK"} . " -tso\"");
# Actual default router.
push(@strings,
"defaultrouter=\"" . $configvars{"TARGETSYS_ROUTER"} . "\"");
# Going to lose all static routes below, so add this back.
push(@strings,
"syslogd_flags=\"-a " .
$configvars{"TARGETSYS_NETWORK"} . "/24\"");
# Jail network.
push(@strings,
"ifconfig_xn0_alias0=\"inet 172.17.253.254 ".
"netmask 255.240.0.0\"");
#
# Okay, we want to comment out a bunch of stuff.
#
my @patterns = (qr(^natd),
qr(^firewall),
qr(^defaultrouter),
qr(^static_routes),
qr(^route_genirack),
qr(^route_outerboss),
qr(^route_vnodes),
qr(^ifconfig_xn0),
qr(^ifconfig_xn0_alias0),
qr(^syslogd_flags),
);
DoneIfEdited($RCCONF);
UpdateFileFatal($RCCONF, \@patterns, @strings);
};
#
# Add named forwarders to resolv.conf to avoid failures
# during boot.
#
if (defined($configvars{"NAMED_FORWARDERS"})) {
my $forwarders = $configvars{"NAMED_FORWARDERS"};
my @forwarders = split(/[\s,]+/, $forwarders);
if (@forwarders) {
@forwarders = map {"nameserver $_"} @forwarders;
Phase "resolve", "Adding named forwarders to resolv.conf", sub {
DoneIfEdited($RESOLVECONF);
AppendToFileFatal($RESOLVECONF, @forwarders);
};
}
}
PhaseSucceed("Rack Setup Done");
};
return 0;
}
# Local Variables:
# mode:perl
# End:
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