Commit e0fd30f9 authored by Leigh B. Stoller's avatar Leigh B. Stoller
Browse files

First pass at making ops look more like a testnode. At this point,

just a bare skeleton of the client side is installed; just enough to
send state events when ops boots. Since ops has to boot before boss
(NFS mounts) the main script goes into the background and retries
until success.

Note that the ssl version of tmcc is installed, and so the proper pem
files must be installed on ops. Thats ctrlnode.pem from the ssl obj
directory as well as emulab.pem (public part of CA) into /etc/emulab.
parent 51696907
......@@ -28,6 +28,7 @@ ETCDIR = $(DESTDIR)$(CLIENT_ETCDIR)
BINDIR = $(DESTDIR)$(CLIENT_BINDIR)
VARDIR = $(DESTDIR)$(CLIENT_VARDIR)
RCDIR = $(BINDIR)/rc
SYSRCDIR = $(DESTDIR)/usr/local/etc/rc.d
TBBINDIR = $(DESTDIR)/usr/testbed/bin
TBLIBDIR = $(DESTDIR)/usr/testbed/lib
INSTALL = /usr/bin/install -c
......@@ -103,7 +104,14 @@ remote-script-install: common-script-install
-chown root $(BINDIR)/vnodesetup
-chmod u+s $(BINDIR)/vnodesetup
control-script-install: dir-install
control-script-install: dir-install bossnode
$(INSTALL) -m 755 $(SRCDIR)/libsetup.pm $(BINDIR)/libsetup.pm
$(INSTALL) -m 755 $(SRCDIR)/watchdog $(BINDIR)/watchdog
$(INSTALL) -m 755 $(SRCDIR)/update $(BINDIR)/update
$(INSTALL) -m 755 $(SRCDIR)/libtmcc.pm $(BINDIR)/libtmcc.pm
$(INSTALL) -m 755 $(SRCDIR)/tmcc.pl $(BINDIR)/tmcc
$(INSTALL) -m 755 $(SRCDIR)/ctrlnode.sh $(SYSRCDIR)/ctrlnode.sh
$(INSTALL) -m 755 $(SRCDIR)/rc.ctrlnode $(RCDIR)/rc.ctrlnode
$(INSTALL) -m 755 $(SRCDIR)/config/librc.pm $(BINDIR)/librc.pm
$(INSTALL) bossnode $(ETCDIR)/bossnode
bossnode: GNUmakefile
echo >$@ "$(BOSSNODE)"
#!/bin/sh
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2004 University of Utah and the Flux Group.
# All rights reserved.
#
. /etc/emulab/paths.sh
#
# Boottime initialization of the control node (aka ops, users, etc).
#
case "$1" in
start)
$BINDIR/rc/rc.ctrlnode -b boot
;;
stop)
$BINDIR/rc/rc.ctrlnode shutdown
;;
*)
echo "Usage: `basename $0` {start|stop}" >&2
;;
esac
exit 0
#!/usr/bin/perl -w
#
# EMULAB-COPYRIGHT
# Copyright (c) 2004 University of Utah and the Flux Group.
# All rights reserved.
#
use English;
use Getopt::Std;
use POSIX qw(setsid);
#
# This script is run directly from boot on the control node (ops, users).
# Since boss needs to be up before this stuff will work, we go into the
# background so that the rest of boot is not held up.
#
sub usage()
{
print "Usage: " . scriptname() . "[-b] boot|shutdown|reconfig|reset\n";
exit(1);
}
my $optlist = "b";
my $background = 0;
my $action = "boot";
# 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 ($UID || $EUID) {
die("*** $0:\n".
" Must be root to run this script!\n");
}
# Script specific goo.
my $RCDIR = "$BINDIR/rc";
my $LOGFILE = "/var/log/testbedboot.debug";
#
# Load the OS independent support library. It will load the OS dependent
# library and initialize itself.
#
use libsetup;
use libtmcc;
use librc;
# Protos.
sub doboot();
sub doshutdown();
sub doreconfig();
sub docleanup();
# Parse command line.
if (! getopts($optlist, \%options)) {
usage();
}
if (defined($options{'b'})) {
$background = 1;
}
# Allow default above.
if (@ARGV) {
$action = $ARGV[0];
}
print "testbed ";
# Execute in background and return immediately.
if ($background && TBBackGround($LOGFILE)) {
sleep(1);
exit(0);
}
# Fully disconnect from bootup.
setsid();
# Execute the action.
SWITCH: for ($action) {
/^boot$/i && do {
doboot();
last SWITCH;
};
/^shutdown$/i && do {
doshutdown();
last SWITCH;
};
/^reconfig$/i && do {
doreconfig();
last SWITCH;
};
/^reset$/i && do {
docleanup();
last SWITCH;
};
fatal("Invalid action: $action\n");
}
exit(0);
#
# Boot Action.
#
sub doboot()
{
#
# Sort of a hodgepodge of stuff!
#
#
# Check for an os dependent initialization script.
#
my $os_script = "rc." . lc($OSNAME);
if (-x "$RCDIR/$os_script") {
system("$RCDIR/$os_script");
if ($?) {
fatal("Error running $RCDIR/$os_script");
}
}
#
# This might be a good thing to run on the control node?
#
if (-x "$BINDIR/tbshutdown") {
print("Starting up shutdown notification daemon\n");
system("$BINDIR/tbshutdown");
if ($?) {
fatal("Error running $BINDIR/tbshutdown");
}
}
#
# This might be a good thing to run on the control node?
#
if (-x "$RCDIR/rc.ipod") {
print("Setting up Ping of Death\n");
system("$RCDIR/rc.ipod");
# This is allowed to fail; ipod might not be supported.
}
#
# Tell boss we rebooted. We do this in a loop cause we have to wait
# for boss to come back alive in case it was also down.
#
print("Informing Emulab Control that we have rebooted\n");
while (1) {
if (tmcc(TMCCCMD_STATE, "TBSETUP") == 0) {
last;
}
print "Error sending TBSETUP to Emulab Control. Retrying ...\n";
sleep(5);
}
# Not much to do yet inbetween ... just delay a bit for settling down.
sleep(5);
# Now send ISUP
print("Informing Emulab Control that we are up and running\n");
while (1) {
if (tmcc(TMCCCMD_STATE, "ISUP") == 0) {
last;
}
print "Error sending ISUP to Emulab Control. Retrying ...\n";
sleep(5);
}
}
#
# Shutdown Action.
#
sub doshutdown()
{
print("Informing Emulab Control that we are are rebooting\n");
if (tmcc(TMCCCMD_STATE, "SHUTDOWN") < 0) {
fatal("Error sending SHUTDOWN to Emulab Control!");
}
}
#
# Node Reconfig Action (without rebooting).
#
sub doreconfig()
{
}
#
# Node cleanup action (node is reset to completely clean state).
#
sub docleanup()
{
}
......@@ -86,7 +86,7 @@ cdboot-install: destdircheck common-install etc-install \
control-install: dir-install
cp /dev/null $(ETCDIR)/isctrl
$(INSTALL) -m 755 ../tmcc $(BINDIR)/tmcc
$(INSTALL) -m 755 ../tmcc $(BINDIR)/tmcc.bin
$(INSTALL) -m 755 $(SRCDIR)/liblocsetup.pm $(BINDIR)/liblocsetup.pm
(cd ../common; $(MAKE) control-install)
@echo "Remember to install the PEM files if necessary"
......
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