Commit f8b1f4b3 authored by Ryan Jackson's avatar Ryan Jackson

rc.mksubboss script and build support

parent 7ce6fba0
......@@ -173,6 +173,10 @@ install: $(INSTALL_SBINDIR)/tmcd \
control-install: tmcc
@$(MAKE) -C freebsd control-install
subboss-install: client
@$(MAKE) -C $(MDSUBDIR) install
@$(MAKE) -C common subboss-install
client-install: client
@$(MAKE) -C $(MDSUBDIR) install
......
......@@ -42,6 +42,7 @@ install client-install:
local-install: path-install local-script-install symlinks
remote-install: path-install remote-script-install
control-install: path-install control-script-install
subboss-install: subboss-script-install
other-install:
(cd ../../os; $(MAKE) DESTDIR=$(DESTDIR) client-install)
......@@ -84,6 +85,9 @@ common-script-install: dir-install
$(INSTALL) -m 755 $(SRCDIR)/startcmddone $(BINDIR)/startcmddone
(cd config; $(MAKE) DESTDIR=$(DESTDIR) script-install)
subboss-script-install: dir-install
(cd config; $(MAKE) DESTDIR=$(DESTDIR) subboss-script-install)
symlinks: dir-install
rm -f $(TBBINDIR)/tevc$(EXE)
ln -s $(CLIENT_BINDIR)/tevc$(EXE) $(TBBINDIR)/tevc$(EXE)
......
......@@ -45,3 +45,6 @@ install:
script-install:
$(INSTALL_PROGRAM) $(SRCDIR)/librc.pm $(BINDIR)/librc.pm
$(INSTALL_PROGRAM) $(SCRIPTS) $(BINDIR)/rc
subboss-script-install: script-install
$(INSTALL_PROGRAM) $(SRCDIR)/rc.mksubboss $(BINDIR)/rc
#! /usr/bin/perl -w
#
# EMULAB-COPYRIGHT
# Copyright (c) 2004-2010 University of Utah and the Flux Group.
# All rights reserved.
#
use English;
use strict;
sub mysystem($;$);
sub RecreateDir($$);
sub SetupFatal($);
# Turn off line buffering on output
$| = 1;
# Drag in path stuff so we can find emulab stuff.
BEGIN { require "/etc/emulab/paths.pm"; import emulabpaths; }
# Only root.
if ($EUID != 0) {
die("*** $0:\n".
" Must be root to run this script!\n");
}
use libsetup;
use libtmcc;
use librc;
my $TBDIR = "/usr/testbed";
my ($bossname, $outer_bossip) = tmccbossinfo();
sub doboot()
{
my $EXTRAFS = "/z";
my $TFTPBOOT_DIR = "$EXTRAFS/tftpboot";
my $stuffdir = "$EXTRAFS/tmp";
my $MFSTARBALL = "tftpboot-subboss.tar.gz";
goto skipsetup if (!SUBBOSS());
print "Stopping tftpd (if running)";
# This needs to be system(), not mysystem since we don't
# care if it fails.
system("/usr/local/etc/rc.d/tftpd-hpa.sh stop");
RecreateDir($EXTRAFS,1);
mysystem("$BINDIR/mkextrafs.pl -f $EXTRAFS");
mysystem("mkdir -p $TFTPBOOT_DIR $stuffdir");
mysystem("ln -sf $TFTPBOOT_DIR /tftpboot");
print "Copying over tftpboot tar file from web server and unpacking\n";
#mysystem("wget -q -O $stuffdir/tftpboot.tar.gz ".
# "http://$bossname/downloads/$MFSTARBALL");
mysystem("fetch -q -o $stuffdir/tftpboot.tar.gz ".
"http://$bossname/downloads/$MFSTARBALL");
mysystem("tar xzf $stuffdir/tftpboot.tar.gz -C /tftpboot");
# FIXME clean up stuffdir?
print "Restarting tftpd";
mysystem("/usr/local/etc/rc.d/tftpd-hpa.sh start");
skipsetup:
mysystem("rm -f $BINDIR/rc/rc.mksubboss");
}
#
# Run a command string.
#
sub mysystem($;$)
{
my ($command, $retrycount) = @_;
$retrycount = 1
if (!defined($retrycount));
while ($retrycount--) {
print "Command: '$command'\n";
print "Started at: " . libsetup::TBTimeStamp() . "\n";
system($command);
last
if ($? == 0 || $retrycount == 0);
sleep(1);
}
if ($?) {
SetupFatal("Command failed: $? - $command");
}
print "Finished at: " . libsetup::TBTimeStamp() . "\n";
}
#
# Very paranoid routine to "remove" and optionally recreate a directory.
#
# If the directory exists and is a mount point, we umount it and
# fixup /etc/fstab so it doesn't get remounted.
#
# If we could not unmount it or it isn't a mount point, we just move
# the directory out of the way.
#
# If it exists but is not a directory, we move it out of the way.
#
sub RecreateDir($$)
{
my ($dir,$docreate) = @_;
#
# If path is a directory and already exists, we need to get rid of it.
# If it is a mount point, unmount it. Otherwise, rename it.
#
if (-d "$dir") {
if (system("umount $dir") == 0) {
# was a mounted FS, need to remove it from fstab if present
mysystem("sed -i '.orig' -E '\\;\[\[:space:\]\]$TBDIR\[\[:space:\]\];d' /etc/fstab");
}
# remove it if it is empty
rmdir("$dir");
}
#
# At this point, if the target still exists (directory or not)
# we have to move it out of the way. If that fails, we die.
#
if (-e "$dir") {
mysystem("mv $dir $dir.old.$$");
}
#
# Finally, make the directory
#
if ($docreate) {
mysystem("mkdir -p $dir");
}
}
#
# Print error and exit.
#
sub SetupFatal($)
{
my ($msg) = @_;
die("*** $0:\n".
" $msg\n");
}
doboot();
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