Commit 58b8fdf4 authored by Robert Ricci's avatar Robert Ricci

Several enhancements to the installation scripts:

In ops-install, only make mailing list files for email addresses
that we think will be hosted on ops.

To both boss-install and ops-install, add a '-p' option to specify
a directory in which binary packages can be found - so that we can
avoid building ports.

Fix up the way we handle the elvind config file - it must be identical
to the one in the source tree. Add a library function to check for
this.

These are as yet untested.
parent f609c891
......@@ -45,9 +45,11 @@ my $PW = "/usr/sbin/pw";
my $PATCH = "/usr/bin/patch";
my $SSH_KEYGEN = "/usr/bin/ssh-keygen";
my $PKG_INFO = "/usr/sbin/pkg_info";
my $PKG_ADD = "/usr/sbin/pkg_add";
my $TOUCH = "/usr/bin/touch";
my $SSH = "/usr/bin/ssh";
my $CP = "/bin/cp";
my $ENV = "/usr/bin/env";
my $SUIDPERL = "/usr/bin/suidperl";
......@@ -80,6 +82,7 @@ my $PHP_INI = "/usr/local/etc/php.ini";
my $CRACKLIB_DICT = "/usr/local/lib/pw_dict.pwd";
my $STL_PATCH = "$TOP_SRCDIR/patches/g++.patch";
my $M2CRYPTO_PATCH = "$TOP_SRCDIR/patches/m2crypto.patch";
my $SSH_CONFIG = "/etc/ssh/ssh_config";
......@@ -130,6 +133,12 @@ my @CISCO_MIBS = ("CISCO-SMI", "CISCO-TC", "CISCO-VTP-MIB", "CISCO-PAGP-MIB",
my @OPS_NAMES = ($FSNODE, $USERNODE);
#
# The meta-port (name and version) that drags in all the dependancies for
# a boss node
#
my $BOSS_PORT = "emulab-boss-1.5";
#
# Figure out which directory we live in, so that some stages can do thing
# relative to it.
......@@ -148,6 +157,27 @@ use lib '@srcdir@';
use English;
use libinstall;
use Getopt::Std;
#
# Handle command-line options
#
sub usage {
print "Usage: ops-install [-p packagedir]\n";
exit(1);
}
my $packagedir = "";
my %opts;
getopt("p:",%opts);
if ($opt{p}) {
$packagedir = $opt{p};
}
if (@ARGV) {
usage();
}
#
# Make sure they know what they're getting into...
......@@ -216,7 +246,19 @@ Phase "tftp", "Setting up directories for tftp", sub {
};
Phase "ports", "Installing ports", sub {
Phase "packages", "Installing packages", sub {
if (!ExecQuiet("$PKG_INFO -e $BOSS_PORT")) {
PhaseSkip("Ports already installed");
}
if (!$packagedir) {
PhaseSkip("No package directory provided");
}
ExecQuietFatal("$ENV PKG_PATH=$packagedir $PKG_ADD $BOSS_PORT");
};
Phase "pcopy", "Copying ports into place", sub {
if ($packagedir) {
PhaseSkip("Package directory provided");
}
DoneIfExists("$PORTSDIR/emulab-boss");
ExecQuietFatal("$SH $SRCDIR/ports/ports-install");
};
......@@ -224,6 +266,10 @@ Phase "ports", "Installing ports", sub {
if (!ExecQuiet("$PKG_INFO -e emulab-boss-1.5")) {
PhaseSkip("Ports already installed");
}
if ($packagedir) {
PhaseSkip("Package directory provided");
}
PhaseFail("Please install ports manually, since some\n of them are " .
"interactive. Run: \n" .
"cd $PORTSDIR/emulab-boss && make install\n" .
......@@ -238,6 +284,12 @@ Phase "patches", "Applying patches", sub {
}
ExecQuietFatal("$PATCH -f -p0 -i $STL_PATCH");
};
Phase "m2cryptopatch", "Patching m2crypto", sub {
if (!ExecQuiet("$PATCH -C -f -R -p0 -i $M2CRYPTO_PATCH")) {
PhaseSkip("$M2CRYPTO_PATCH already applied");
}
ExecQuietFatal("$PATCH -f -p0 -i $M2CRYPTO_PATCH");
};
};
Phase "cracklib", "Installing cracklib", sub {
......@@ -599,7 +651,7 @@ Phase "sslcerts", "Setting up SSL certificates", sub {
Phase "event", "Setting up event system", sub {
Phase "elvinconf", "Installing elvind config file", sub {
DoneIfExists("$ELVIND_CONF");
DoneIfIdentical($ELVIND_CONF,$BOSS_ELVIND_CONF);
ExecQuietFatal("$CP $BOSS_ELVIND_CONF $ELVIND_CONF");
};
};
......
......@@ -244,6 +244,24 @@ sub DoneIfEdited($) {
my ($filename) = @_;
if (!$filename) { PhaseFail("Bad filename passed to DoneIfEdited"); }
open(FH,$filename) or return;
if (!-e $filename1 || !-e $filename2) {
return;
}
if (!ExecQuiet("cmp -s $filename1 $filename2")) {
PhaseSkip("Files $filename1 and $filename2 are identical");
}
}
#
# Check to see if the phase is already done, as evidenced by the fact that two
# files are identical
#
sub DoneIfIdentical($) {
my ($filename1,$filename2) = @_;
if (!$filename1 || !$filename2) {
PhaseFail("Bad filename passed to DoneIfIdentical");
}
open(FH,$filename1) or return;
if (grep /$MAGIC_STRING/, <FH>) {
PhaseSkip("File $filename has already been edited\n");
}
......
......@@ -41,6 +41,27 @@ use lib '@srcdir@';
use English;
use libinstall;
use Getopt::Std;
#
# Handle command-line options
#
sub usage {
print "Usage: ops-install [-p packagedir]\n";
exit(1);
}
my $packagedir = "";
my %opts;
getopt("p:",%opts);
if ($opt{p}) {
$packagedir = $opt{p};
}
if (@ARGV) {
usage();
}
#
# Figure out which directory we live in, so that some stages can do thing
......@@ -59,9 +80,11 @@ my $PW = "/usr/sbin/pw";
my $NEWALIASES = "/usr/bin/newaliases";
my $SH = "/bin/sh";
my $PKG_INFO = "/usr/sbin/pkg_info";
my $PKG_ADD = "/usr/sbin/pkg_add";
my $PWD = "/bin/pwd";
my $CP = "/bin/cp";
my $GMAKE = "/usr/local/bin/gmake";
my $ENV = "/usr/bin/env";
#
# Some files we edit/create
......@@ -94,7 +117,8 @@ my $RCDIR = "/usr/local/etc/rc.d";
my @LOCAL_HOSTS = ($OURDOMAIN,$BOSSNODE,$USERNODE,$FSNODE);
my @LOGFILES = ("/var/log/logins","/var/log/tiplogs/capture.log",
"/var/log/mountd.log");
my @MAILING_LIST_NAMES = map { /^([\w-]+)\@/ } @MAILING_LISTS;
my @LOCAL_MAILING_LISTS = grep(/$OURDOMAIN$/,@MAILING_LISTS);
my @MAILING_LIST_NAMES = map { /^([\w-]+)\@/ } @LOCAL_MAILING_LISTS;
my @TESTBED_DIRS = ([$PREFIX, "0775"], ["/users", "0755"],
["/proj", "0755"], ["/groups", "0755"], ["/share", "0775"]);
......@@ -105,6 +129,12 @@ my @TESTBED_DIRS = ([$PREFIX, "0775"], ["/users", "0755"],
my $ELVIND_CONF = "/usr/local/etc/elvind.conf";
my $OPS_ELVIND_CONF = "$TOP_OBJDIR/event/etc/elvind-ops.conf";
#
# The meta-port (name and version) that drags in all the dependancies for
# an ops node
#
my $OPS_PORT = "emulab-ops-1.4";
#
# Make sure they know what they're getting into...
#
......@@ -151,14 +181,29 @@ Phase "dirs", "Setting directory permissions", sub {
};
Phase "ports", "Installing ports", sub {
Phase "packages", "Installing packages", sub {
if (!ExecQuiet("$PKG_INFO -e $OPS_PORT")) {
PhaseSkip("Ports already installed");
}
if (!$packagedir) {
PhaseSkip("No package directory provided");
}
ExecQuietFatal("$ENV PKG_PATH=$packagedir $PKG_ADD $OPS_PORT");
};
Phase "pcopy", "Copying ports into place", sub {
if ($packagedir) {
PhaseSkip("Package directory provided");
}
DoneIfExists("$PORTSDIR/emulab-ops");
ExecQuietFatal("$SH $SRCDIR/ports/ports-install");
};
Phase "pinstall", "Installing ports (may take a while)", sub {
if (!ExecQuiet("$PKG_INFO -e emulab-ops-1.4")) {
if (!ExecQuiet("$PKG_INFO -e $OPS_PORT")) {
PhaseSkip("Ports already installed");
}
if ($packagedir) {
PhaseSkip("Package directory provided");
}
#
# This port is dead-simple, so it's safe to do it from this script
......@@ -208,7 +253,7 @@ Phase "sendmail","Configuring sendmail", sub {
map("$_:\t:include:$LIST_DIR/$_",@MAILING_LIST_NAMES));
};
Phase "newaliases", "Running newaliases", sub {
PhaseSkip("No new aliases") unless @MAILING_LISTS;
PhaseSkip("No new aliases") unless @MAILING_LIST_NAMES;
PhaseSkip("No new aliases") if PhaseWasSkipped("aliases");
ExecQuietFatal($NEWALIASES);
};
......@@ -398,7 +443,7 @@ Phase "capture", "Setting up capture", sub {
Phase "event", "Setting up event system", sub {
Phase "elvinconf", "Installing elvind config file", sub {
DoneIfExists("$ELVIND_CONF");
DoneIfIdentical($ELVIND_CONF,$OPS_ELVIND_CONF);
ExecQuietFatal("$CP $OPS_ELVIND_CONF $ELVIND_CONF");
};
};
......@@ -420,5 +465,5 @@ print "Please reboot this machine before proceeding with boss setup\n";
if (!PhaseWasSkipped("maillists")) {
print "Local mailing lists have been created, with no members, in\n";
print "$LIST_DIR . Please add members to the following lists:\n";
print map "$_\n", @MAILING_LISTS;
print map "$_\n", @LOCAL_MAILING_LISTS;
}
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