Commit c2ff0bfa authored by Leigh Stoller's avatar Leigh Stoller

A bunch of little scripts made common and moved from the linux,freebsd

directories into a common subdir. Also cleaned up some.
parent 9e18f58e
......@@ -4,20 +4,15 @@
# Copyright (c) 2000-2002 University of Utah and the Flux Group.
# All rights reserved.
#
use English;
#
# Untaint path
#
$ENV{'PATH'} = '/bin:/sbin:/usr/bin:/usr/local/bin:/etc/testbed';
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
# Drag in path stuff so we can find emulab stuff.
BEGIN { require "/etc/emulab/paths.pm"; import emulabpaths; }
#
# Load the OS independent support library. It will load the OS dependent
# library and initialize itself.
#
use lib "/etc/testbed";
use libsetup;
#
......
......@@ -5,18 +5,16 @@
# All rights reserved.
#
. /etc/emulab/paths.sh
#
# Start the agents. The scripts decide themselves whether to do anything.
#
if [ -x /etc/testbed/rc.delayagent ]; then
/etc/testbed/rc.delayagent
if [ -x $BINDIR/rc.delayagent ]; then
$BINDIR/rc.delayagent
fi
if [ -x /etc/testbed/rc.progagent ]; then
/etc/testbed/rc.progagent
if [ -x $BINDIR/rc.progagent ]; then
$BINDIR/rc.progagent
fi
if [ -x /etc/testbed/rc.traffic ]; then
echo "Starting traffic generators ..."
/etc/testbed/rc.traffic
fi
......@@ -4,20 +4,16 @@
# Copyright (c) 2000-2002 University of Utah and the Flux Group.
# All rights reserved.
#
use English;
# Drag in path stuff so we can find emulab stuff.
BEGIN { require "/etc/emulab/paths.pm"; import emulabpaths; }
#
# Load Deltas.
#
my $reboot = 0;
#
# Untaint path
#
$ENV{'PATH'} = '/bin:/sbin:/usr/bin:/usr/local/bin:/etc/testbed';
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
#
# Turn off line buffering on output
#
......@@ -27,7 +23,6 @@ $| = 1;
# Load the OS independent support library. It will load the OS dependent
# library and initialize itself.
#
use lib "/etc/testbed";
use libsetup;
print STDOUT "Checking Testbed Delta configuration ... \n";
......
......@@ -4,20 +4,15 @@
# Copyright (c) 2000-2002 University of Utah and the Flux Group.
# All rights reserved.
#
use English;
#
# Untaint path
#
$ENV{'PATH'} = '/bin:/sbin:/usr/bin:/usr/local/bin:/etc/testbed';
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
# Drag in path stuff so we can find emulab stuff.
BEGIN { require "/etc/emulab/paths.pm"; import emulabpaths; }
#
# Load the OS independent support library. It will load the OS dependent
# library and initialize itself.
#
use lib "/etc/testbed";
use libsetup;
print "Starting Program Agent ...\n";
......
......@@ -4,86 +4,91 @@
# Copyright (c) 2000-2002 University of Utah and the Flux Group.
# All rights reserved.
#
. /etc/emulab/paths.sh
#
#
# Inform TMCD that we've rebooted, and are starting testbed setup
#
if [ -x /etc/testbed/tmcc ]; then
echo "Informing the testbed that we've rebooted ..."
/etc/testbed/tmcc state REBOOTED
fi
echo "Informing the testbed that we've rebooted ..."
$BINDIR/tmcc state TBSETUP
if [ -x /etc/testbed/tbshutdown ]; then
echo "Setting up shutdown notification (tbshutdown)..."
/etc/testbed/tbshutdown
if [ -x $BINDIR/tbshutdown ]; then
echo "Starting up shutdown notification daemon ..."
$BINDIR/tbshutdown
fi
if [ -x /etc/testbed/setup ]; then
echo "Doing Testbed setup configuration ..."
/etc/testbed/setup
fi
echo "Doing Testbed bootsetup configuration ..."
$BINDIR/bootsetup
if [ -x /etc/testbed/setipod ]; then
if [ -x $BINDIR/rc.ipod ]; then
echo "Setting up IPOD ... "
/etc/testbed/setipod
$BINDIR/rc.ipod
fi
if [ -x /etc/testbed/rc.tunnel ]; then
if [ -x $BOOTDIR/rc.tunnel ]; then
echo "Setting up Testbed tunnels ..."
/etc/testbed/rc.tunnel
$BOOTDIR/rc.tunnel
fi
if [ -x /etc/testbed/rc.ifc ]; then
if [ -x $BOOTDIR/rc.ifc ]; then
echo "Setting up Testbed interfaces ..."
/etc/testbed/rc.ifc
$BOOTDIR/rc.ifc
fi
# Note: no routing on delay nodes
if [ -x /etc/testbed/rc.delay ]; then
if [ -x $BOOTDIR/rc.delay ]; then
echo "Setting up Testbed delay configuration ..."
/etc/testbed/rc.delay
elif [ -x /etc/testbed/rc.route ]; then
$BOOTDIR/rc.delay
elif [ -x $BOOTDIR/rc.route ]; then
echo "Setting up Testbed interface routing ..."
/etc/testbed/rc.route enable
$BOOTDIR/rc.route enable
fi
if [ -x /etc/testbed/rc.rpm ]; then
if [ -x $BOOTDIR/rc.rpm ]; then
echo "Installing RPMs ..."
/etc/testbed/rc.rpm
$BOOTDIR/rc.rpm
fi
if [ -x /etc/testbed/rc.tarballs ]; then
if [ -x $BOOTDIR/rc.tarballs ]; then
echo "Installing Tarballs ..."
/etc/testbed/rc.tarballs
$BOOTDIR/rc.tarballs
fi
if [ -x /etc/testbed/rc.healthd ]; then
if [ -x $BINDIR/rc.healthd ]; then
echo "Starting node health monitoring ..."
/etc/testbed/rc.healthd start
$BINDIR/rc.healthd start
fi
if [ -x /etc/testbed/slothd ]; then
if [ -x $BINDIR/slothd ]; then
echo "Starting usage detector ..."
killall slothd
rm -f /var/run/slothd.pid
/etc/testbed/slothd
$BINDIR/slothd
fi
if [ -x $BINDIR/watchdog ]; then
echo "Starting update watchdog ..."
$BINDIR/watchdog
fi
if [ -x $BINDIR/bootvnodes ]; then
echo "Booting up vnodes ..."
# Foreground mode.
$BINDIR/bootvnodes -f
fi
/bin/rm -f /var/at/jobs/S*
if [ -s /etc/testbed/startupcmd ]; then
/bin/rm -f /var/spool/at/S*
if [ -s $BOOTDIR/startupcmd ]; then
echo "Scheduling startup command to run in a little bit ..."
echo "/etc/testbed/runstartup" | at -q S 'now + 2 minutes'
echo "$BINDIR/runstartup" | at -q S 'now + 2 minutes'
fi
if [ -x /etc/testbed/rc.agents ]; then
/etc/testbed/rc.agents
if [ -x $BINDIR/rc.agents ]; then
$BINDIR/rc.agents
fi
#
# Inform TMCD that we're up and running
#
if [ -x /etc/testbed/tmcc ]; then
echo "Informing the testbed that we're up and running ..."
/etc/testbed/tmcc state ISUP
if [ -x $BOOTDIR/rc.traffic ]; then
echo "Starting traffic generators ..."
$BOOTDIR/rc.traffic
fi
echo "Informing the testbed that we're up and running ..."
$BINDIR/tmcc state ISUP
......@@ -10,23 +10,18 @@
# if you sup this file, it won't take effect till the next reboot.
#
. /etc/emulab/paths.sh
#
# If on the MFS, skip this stuff and just do the MFS setup stuff.
#
if [ -e /etc/testbed/ismfs ]; then
/etc/testbed/rc.mfs
if [ -e $ETCDIR/ismfs ]; then
$BINDIR/rc.mfs
exit 0
fi
export HOME=/root
if [ -f /etc/testbed/supfile ]; then
echo "Checking for file updates ..."
set -- `/etc/testbed/tmcc bossinfo`
/usr/local/bin/cvsup -h $1 -e -1 -g -L 1 /etc/testbed/supfile
if [ -x $BINDIR/runcvsup.sh ]; then
$BINDIR/runcvsup.sh
fi
if [ -x /etc/testbed/rc.setup ]; then
echo "Starting Testbed Setup ..."
/etc/testbed/rc.setup
fi
$BINDIR/rc.setup
......@@ -4,34 +4,47 @@
# Copyright (c) 2000-2002 University of Utah and the Flux Group.
# All rights reserved.
#
use English;
use POSIX qw(setsid);
#
# Load the OS independent support library. It will load the OS dependent
# library and initialize itself.
#
use lib "/etc/testbed";
use libsetup;
# Drag in path stuff so we can find emulab stuff.
BEGIN { require "/etc/emulab/paths.pm"; import emulabpaths; }
#
# Untaint path
# Prototypes.
#
$ENV{'PATH'} = '/bin:/sbin:/usr/bin:/usr/local/bin:/etc/testbed';
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
sub fatal($);
sub background();
#
# Turn off line buffering on output
#
$| = 1;
#
# Load the OS independent support library. It will load the OS dependent
# library and initialize itself.
#
use libsetup;
# Locals;
my $logname;
my $logtemplate;
#
# Get the config parameters so we can open up a log file in the proper
# location. See below.
#
my ($pid, $eid, $vname);
if (! (($pid, $eid, $vname) = check_status())) {
fatal("Could not determine pid/eid");
if (JAILED()) {
$logtemplate = "$VARDIR/logs/runlog.XXXXXX";
}
else {
my ($pid, $eid, $vname) = check_status();
if (!defined($eid)) {
fatal("Could not determine pid/eid");
}
$logtemplate = "/proj/$pid/logs/runlog-$eid.$vname.XXXXXX";
}
#
......@@ -43,6 +56,7 @@ if (background()) {
#
exit 0;
}
sleep(10);
#
# Open up the command file, which tells us what to do.
......@@ -88,8 +102,8 @@ else {
$EGID = $GID = $gid;
$EUID = $UID = $uid;
exec($runcmd) or
fatal("Could not exec $runcmd: $!");
exec($runcmd);
exit($!);
}
print STDOUT "$runcmd returned $stat\n";
......@@ -126,6 +140,7 @@ sub background()
if ($mypid) {
return $mypid;
}
POSIX::setsid();
#
# We have to disconnect from the caller by redirecting both STDIN and
......@@ -138,9 +153,9 @@ sub background()
#
# Create a temporary name for a log file and untaint it.
#
$logname = `mktemp /proj/$pid/logs/runlog-$eid.$vname.XXXXXX`;
$logname = `mktemp $logtemplate`;
if ($?) {
die("mktemp failed!");
die("mktemp failed!");
}
# Note different taint check (allow /).
......@@ -154,6 +169,5 @@ sub background()
open(STDERR, ">> $logname") or die("opening $logname for STDERR: $!");
open(STDOUT, ">> $logname") or die("opening $logname for STDOUT: $!");
return 0;
}
......@@ -4,7 +4,6 @@
# Copyright (c) 2000-2002 University of Utah and the Flux Group.
# All rights reserved.
#
use English;
#
......@@ -13,18 +12,8 @@ use English;
# usage: sendevent <event>
#
#
# Untaint path
#
$ENV{'PATH'} = '/bin:/sbin:/usr/bin:/usr/local/bin:/etc/testbed';
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
#
# Load the OS independent support library. It will load the OS dependent
# library and initialize itself.
#
use lib "/etc/testbed";
use libsetup;
# Drag in path stuff so we can find emulab stuff.
BEGIN { require "/etc/emulab/paths.pm"; import emulabpaths; }
#
# We use the tmcc to figure out where the Testbed Event Daemon is running.
......
#!/bin/sh
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2002 University of Utah and the Flux Group.
# All rights reserved.
#
#
# Start the agents. The scripts decide themselves whether to do anything.
#
if [ -x /etc/rc.d/testbed/rc.delayagent ]; then
/etc/rc.d/testbed/rc.delayagent
fi
if [ -x /etc/rc.d/testbed/rc.progagent ]; then
/etc/rc.d/testbed/rc.progagent
fi
if [ -x /etc/rc.d/testbed/rc.traffic ]; then
echo "Starting traffic generators ..."
/etc/rc.d/testbed/rc.traffic
fi
#!/usr/bin/perl -wT
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2002 University of Utah and the Flux Group.
# All rights reserved.
#
use English;
#
# Load Deltas.
#
my $reboot = 0;
#
# Untaint path
#
$ENV{'PATH'} = '/bin:/sbin:/usr/bin:/usr/local/bin:/etc/testbed';
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
#
# Turn off line buffering on output
#
$| = 1;
#
# Load the OS independent support library. It will load the OS dependent
# library and initialize itself.
#
use lib "/etc/rc.d/testbed";
use libsetup;
print STDOUT "Checking Testbed Delta configuration ... \n";
#
# Delta configuration.
#
$reboot = install_deltas();
if ($reboot) {
system("sync");
system("reboot");
}
exit 0;
#!/usr/bin/perl -w
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2002 University of Utah and the Flux Group.
# All rights reserved.
#
use English;
#
# Untaint path
#
$ENV{'PATH'} = '/bin:/sbin:/usr/bin:/usr/local/bin:/etc/rc.d/testbed';
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
#
# Load the OS independent support library. It will load the OS dependent
# library and initialize itself.
#
use lib "/etc/rc.d/testbed";
use libsetup;
print "Starting Program Agent ...\n";
#
# We use the tmcc to figure out where the Testbed Event Daemon is running.
# Don't worry about the port for now.
#
my ($bossname) = split(" ", `tmcc bossinfo`);
#
# We have to run the program agent as the user that created the experiment.
# Might change at some point with multiuser nodes.
#
my (undef,$creator) = split("=", `tmcc creator`);
if (!defined($creator)) {
print STDERR "Could not determine experiment creator!\n";
exit(1);
}
chop($creator);
(undef,undef,$uid,$gid,undef,undef,undef,undef) = getpwnam($creator);
if (!defined($uid)) {
print STDERR "Could not determine experiment creator UID!\n";
exit(1);
}
#
# Become the creator and run the agent.
#
$EGID = $GID = $gid;
$EUID = $UID = $uid;
system("program-agent -s $bossname -l /tmp/progagent.debug &");
exit($? >> 0);
#!/bin/sh
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2002 University of Utah and the Flux Group.
# All rights reserved.
#
#
#
# Inform TMCD that we've rebooted, and are starting testbed setup
#
if [ -x /etc/rc.d/testbed/tmcc ]; then
echo "Informing the testbed that we've rebooted ..."
/etc/rc.d/testbed/tmcc state REBOOTED
fi
if [ -x /etc/rc.d/testbed/setup ]; then
echo "Setting up Testbed Configuration ..."
/etc/rc.d/testbed/setup
fi
if [ -x /etc/testbed/rc.tunnel ]; then
echo "Setting up Testbed tunnels ..."
/etc/testbed/rc.tunnel
fi
if [ -x /etc/rc.d/testbed/rc.ifc ]; then
echo "Setting up Testbed Interfaces ..."
/etc/rc.d/testbed/rc.ifc
fi
if [ -x /etc/rc.d/testbed/rc.route ]; then
echo "Setting up Testbed interface routing ..."
/etc/rc.d/testbed/rc.route enable
fi
if [ -x /etc/rc.d/testbed/rc.rpm ]; then
echo "Installing RPMs ..."
/etc/rc.d/testbed/rc.rpm
fi
if [ -x /etc/rc.d/testbed/rc.tarballs ]; then
echo "Installing Tarballs ..."
/etc/rc.d/testbed/rc.tarballs
fi
if [ -x /etc/rc.d/testbed/rc.healthd ]; then
echo "Starting node health monitoring ..."
/etc/rc.d/testbed/rc.healthd start
fi
if [ -x /etc/rc.d/testbed/slothd ]; then
echo "Starting usage detector ..."
killall slothd
rm -f /var/run/slothd.pid
/etc/rc.d/testbed/slothd
fi
/bin/rm -f /var/spool/at/S*
if [ -s /etc/rc.d/testbed/startupcmd ]; then
echo "Scheduling startup command to run in a little bit ..."
echo "/etc/rc.d/testbed/runstartup" | at -q S 'now + 2 minutes'
fi
if [ -x /etc/rc.d/testbed/rc.agents ]; then
/etc/rc.d/testbed/rc.agents
fi
#
# Inform TMCD that we're up and running
#
if [ -x /etc/rc.d/testbed/tmcc ]; then
echo "Informing the testbed that we're up and running ..."
/etc/rc.d/testbed/tmcc state ISUP
fi
#!/bin/sh
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2002 University of Utah and the Flux Group.
# All rights reserved.
#
#
# Don't put anything else in here. Put it in the rc.setup file cause
# if you sup this file, it won't take effect till the next reboot.
#
echo "Checking for file updates ..."
export HOME=/root
if [ -f /etc/rc.d/testbed/supfile ]; then
set -- `/etc/rc.d/testbed/tmcc bossinfo`
/usr/local/bin/cvsup -h $1 -e -1 -g -L 1 /etc/rc.d/testbed/supfile
fi
if [ -x /etc/rc.d/testbed/rc.setup ]; then
echo "Starting Testbed Setup ..."
/etc/rc.d/testbed/rc.setup
fi
#!/usr/bin/perl -wT
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2002 University of Utah and the Flux Group.
# All rights reserved.
#
use English;
#
# Untaint path
#
$ENV{'PATH'} = '/bin:/sbin:/usr/bin:/usr/local/bin:/etc/rc.d/testbed';
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
#
# Prototypes.
#
sub fatal($);
sub background();
#
# Turn off line buffering on output
#
$| = 1;
#
# Load the OS independent support library. It will load the OS dependent
# library and initialize itself.
#
use lib "/etc/rc.d/testbed";
use libsetup;
#
# Get the config parameters so we can open up a log file in the proper
# location. See below.
#
my ($pid, $eid, $vname);
if (! (($pid, $eid, $vname) = check_status())) {
fatal("Could not determine pid/eid");
}
#
# Disconnect from the caller (at daemon).
#
if (background()) {
#
# Parent exits normally
#
exit 0;
}
#
# Open up the command file, which tells us what to do.
#
open(CMD, TMSTARTUPCMD) or
fatal("Could not open " . TMSTARTUPCMD . ": $!");
my $runcmd;
my $login;
while (<CMD>) {
if ($_ =~ /CMD=\'([-\@\w.\/ ]+)\' UID=([0-9a-z]+)/) {
$runcmd = $1;
$login = $2;
}
}
if (!defined($runcmd) || !defined($login)) {
fatal(TMSTARTUPCMD . " not in proper format!");
}
(undef,undef,$uid,$gid,undef,undef,undef,undef) = getpwnam($login) or
fatal("Could not determine UID for $login");
chown($uid, $gid, $logname) or
fatal("Could not chown $logname to $uid/$gid: $!\n");
#
# Fork a child so that we can run the command as the user and wait for it.
#
$mypid = fork();
if ($mypid) {
#
# Parent waits for child.
#
waitpid($mypid, 0);
$stat = $? >> 8;
}
else {
#
# The child becomes the user and runs the command.
#
$EGID = $GID = $gid;
$EUID = $UID = $uid;
exec($runcmd) or
fatal("Could not exec $runcmd: $!");
}
print STDOUT "$runcmd returned $stat\n";
#
# Use the TMCC to tell the TMCD what the exit status was.
#
startcmdstatus($stat);
exit(0);
sub fatal($)
{
my($mesg) = $_[0];
print STDOUT "$mesg\n";
#
# Use the TMCC to tell the TMCD that we screwed the pooch.
#
startcmdstatus(666);
exit(-1);
}
#
# Put ourselves into the background so that caller sees immediate response.
#
sub background()
{
# Turn off line buffering on output
#
$| = 1;