Commit c2ff0bfa authored by Leigh B. Stoller's avatar Leigh B. 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 @@ ...@@ -4,20 +4,15 @@
# Copyright (c) 2000-2002 University of Utah and the Flux Group. # Copyright (c) 2000-2002 University of Utah and the Flux Group.
# All rights reserved. # All rights reserved.
# #
use English; use English;
# # Drag in path stuff so we can find emulab stuff.
# Untaint path BEGIN { require "/etc/emulab/paths.pm"; import emulabpaths; }
#
$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 # Load the OS independent support library. It will load the OS dependent
# library and initialize itself. # library and initialize itself.
# #
use lib "/etc/testbed";
use libsetup; use libsetup;
# #
......
...@@ -5,18 +5,16 @@ ...@@ -5,18 +5,16 @@
# All rights reserved. # All rights reserved.
# #
. /etc/emulab/paths.sh
# #
# Start the agents. The scripts decide themselves whether to do anything. # Start the agents. The scripts decide themselves whether to do anything.
# #
if [ -x /etc/testbed/rc.delayagent ]; then if [ -x $BINDIR/rc.delayagent ]; then
/etc/testbed/rc.delayagent $BINDIR/rc.delayagent
fi fi
if [ -x /etc/testbed/rc.progagent ]; then if [ -x $BINDIR/rc.progagent ]; then
/etc/testbed/rc.progagent $BINDIR/rc.progagent
fi fi
if [ -x /etc/testbed/rc.traffic ]; then
echo "Starting traffic generators ..."
/etc/testbed/rc.traffic
fi
...@@ -4,20 +4,16 @@ ...@@ -4,20 +4,16 @@
# Copyright (c) 2000-2002 University of Utah and the Flux Group. # Copyright (c) 2000-2002 University of Utah and the Flux Group.
# All rights reserved. # All rights reserved.
# #
use English; use English;
# Drag in path stuff so we can find emulab stuff.
BEGIN { require "/etc/emulab/paths.pm"; import emulabpaths; }
# #
# Load Deltas. # Load Deltas.
# #
my $reboot = 0; 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 # Turn off line buffering on output
# #
...@@ -27,7 +23,6 @@ $| = 1; ...@@ -27,7 +23,6 @@ $| = 1;
# Load the OS independent support library. It will load the OS dependent # Load the OS independent support library. It will load the OS dependent
# library and initialize itself. # library and initialize itself.
# #
use lib "/etc/testbed";
use libsetup; use libsetup;
print STDOUT "Checking Testbed Delta configuration ... \n"; print STDOUT "Checking Testbed Delta configuration ... \n";
......
...@@ -4,20 +4,15 @@ ...@@ -4,20 +4,15 @@
# Copyright (c) 2000-2002 University of Utah and the Flux Group. # Copyright (c) 2000-2002 University of Utah and the Flux Group.
# All rights reserved. # All rights reserved.
# #
use English; use English;
# # Drag in path stuff so we can find emulab stuff.
# Untaint path BEGIN { require "/etc/emulab/paths.pm"; import emulabpaths; }
#
$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 # Load the OS independent support library. It will load the OS dependent
# library and initialize itself. # library and initialize itself.
# #
use lib "/etc/testbed";
use libsetup; use libsetup;
print "Starting Program Agent ...\n"; print "Starting Program Agent ...\n";
......
...@@ -4,86 +4,91 @@ ...@@ -4,86 +4,91 @@
# Copyright (c) 2000-2002 University of Utah and the Flux Group. # Copyright (c) 2000-2002 University of Utah and the Flux Group.
# All rights reserved. # All rights reserved.
# #
. /etc/emulab/paths.sh
# echo "Informing the testbed that we've rebooted ..."
# $BINDIR/tmcc state TBSETUP
# 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
if [ -x /etc/testbed/tbshutdown ]; then if [ -x $BINDIR/tbshutdown ]; then
echo "Setting up shutdown notification (tbshutdown)..." echo "Starting up shutdown notification daemon ..."
/etc/testbed/tbshutdown $BINDIR/tbshutdown
fi fi
if [ -x /etc/testbed/setup ]; then echo "Doing Testbed bootsetup configuration ..."
echo "Doing Testbed setup configuration ..." $BINDIR/bootsetup
/etc/testbed/setup
fi
if [ -x /etc/testbed/setipod ]; then if [ -x $BINDIR/rc.ipod ]; then
echo "Setting up IPOD ... " echo "Setting up IPOD ... "
/etc/testbed/setipod $BINDIR/rc.ipod
fi fi
if [ -x /etc/testbed/rc.tunnel ]; then if [ -x $BOOTDIR/rc.tunnel ]; then
echo "Setting up Testbed tunnels ..." echo "Setting up Testbed tunnels ..."
/etc/testbed/rc.tunnel $BOOTDIR/rc.tunnel
fi fi
if [ -x /etc/testbed/rc.ifc ]; then if [ -x $BOOTDIR/rc.ifc ]; then
echo "Setting up Testbed interfaces ..." echo "Setting up Testbed interfaces ..."
/etc/testbed/rc.ifc $BOOTDIR/rc.ifc
fi fi
# Note: no routing on delay nodes # 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 ..." echo "Setting up Testbed delay configuration ..."
/etc/testbed/rc.delay $BOOTDIR/rc.delay
elif [ -x /etc/testbed/rc.route ]; then elif [ -x $BOOTDIR/rc.route ]; then
echo "Setting up Testbed interface routing ..." echo "Setting up Testbed interface routing ..."
/etc/testbed/rc.route enable $BOOTDIR/rc.route enable
fi fi
if [ -x /etc/testbed/rc.rpm ]; then if [ -x $BOOTDIR/rc.rpm ]; then
echo "Installing RPMs ..." echo "Installing RPMs ..."
/etc/testbed/rc.rpm $BOOTDIR/rc.rpm
fi fi
if [ -x /etc/testbed/rc.tarballs ]; then if [ -x $BOOTDIR/rc.tarballs ]; then
echo "Installing Tarballs ..." echo "Installing Tarballs ..."
/etc/testbed/rc.tarballs $BOOTDIR/rc.tarballs
fi fi
if [ -x /etc/testbed/rc.healthd ]; then if [ -x $BINDIR/rc.healthd ]; then
echo "Starting node health monitoring ..." echo "Starting node health monitoring ..."
/etc/testbed/rc.healthd start $BINDIR/rc.healthd start
fi fi
if [ -x /etc/testbed/slothd ]; then if [ -x $BINDIR/slothd ]; then
echo "Starting usage detector ..." echo "Starting usage detector ..."
killall slothd killall slothd
rm -f /var/run/slothd.pid 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 fi
/bin/rm -f /var/at/jobs/S* /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 "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 fi
if [ -x /etc/testbed/rc.agents ]; then if [ -x $BINDIR/rc.agents ]; then
/etc/testbed/rc.agents $BINDIR/rc.agents
fi fi
# if [ -x $BOOTDIR/rc.traffic ]; then
# Inform TMCD that we're up and running echo "Starting traffic generators ..."
# $BOOTDIR/rc.traffic
if [ -x /etc/testbed/tmcc ]; then
echo "Informing the testbed that we're up and running ..."
/etc/testbed/tmcc state ISUP
fi fi
echo "Informing the testbed that we're up and running ..."
$BINDIR/tmcc state ISUP
...@@ -10,23 +10,18 @@ ...@@ -10,23 +10,18 @@
# if you sup this file, it won't take effect till the next reboot. # 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 on the MFS, skip this stuff and just do the MFS setup stuff.
# #
if [ -e /etc/testbed/ismfs ]; then if [ -e $ETCDIR/ismfs ]; then
/etc/testbed/rc.mfs $BINDIR/rc.mfs
exit 0 exit 0
fi fi
export HOME=/root if [ -x $BINDIR/runcvsup.sh ]; then
$BINDIR/runcvsup.sh
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
fi fi
if [ -x /etc/testbed/rc.setup ]; then $BINDIR/rc.setup
echo "Starting Testbed Setup ..."
/etc/testbed/rc.setup
fi
...@@ -4,34 +4,47 @@ ...@@ -4,34 +4,47 @@
# Copyright (c) 2000-2002 University of Utah and the Flux Group. # Copyright (c) 2000-2002 University of Utah and the Flux Group.
# All rights reserved. # All rights reserved.
# #
use English; use English;
use POSIX qw(setsid);
# # Drag in path stuff so we can find emulab stuff.
# Load the OS independent support library. It will load the OS dependent BEGIN { require "/etc/emulab/paths.pm"; import emulabpaths; }
# library and initialize itself.
#
use lib "/etc/testbed";
use libsetup;
# #
# Untaint path # Prototypes.
# #
$ENV{'PATH'} = '/bin:/sbin:/usr/bin:/usr/local/bin:/etc/testbed'; sub fatal($);
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'}; sub background();
# #
# Turn off line buffering on output # Turn off line buffering on output
# #
$| = 1; $| = 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 # Get the config parameters so we can open up a log file in the proper
# location. See below. # location. See below.
# #
my ($pid, $eid, $vname); if (JAILED()) {
if (! (($pid, $eid, $vname) = check_status())) { $logtemplate = "$VARDIR/logs/runlog.XXXXXX";
fatal("Could not determine pid/eid"); }
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()) { ...@@ -43,6 +56,7 @@ if (background()) {
# #
exit 0; exit 0;
} }
sleep(10);
# #
# Open up the command file, which tells us what to do. # Open up the command file, which tells us what to do.
...@@ -88,8 +102,8 @@ else { ...@@ -88,8 +102,8 @@ else {
$EGID = $GID = $gid; $EGID = $GID = $gid;
$EUID = $UID = $uid; $EUID = $UID = $uid;
exec($runcmd) or exec($runcmd);
fatal("Could not exec $runcmd: $!"); exit($!);
} }
print STDOUT "$runcmd returned $stat\n"; print STDOUT "$runcmd returned $stat\n";
...@@ -126,6 +140,7 @@ sub background() ...@@ -126,6 +140,7 @@ sub background()
if ($mypid) { if ($mypid) {
return $mypid; return $mypid;
} }
POSIX::setsid();
# #
# We have to disconnect from the caller by redirecting both STDIN and # We have to disconnect from the caller by redirecting both STDIN and
...@@ -138,9 +153,9 @@ sub background() ...@@ -138,9 +153,9 @@ sub background()
# #
# Create a temporary name for a log file and untaint it. # Create a temporary name for a log file and untaint it.
# #
$logname = `mktemp /proj/$pid/logs/runlog-$eid.$vname.XXXXXX`; $logname = `mktemp $logtemplate`;
if ($?) { if ($?) {
die("mktemp failed!"); die("mktemp failed!");
} }
# Note different taint check (allow /). # Note different taint check (allow /).
...@@ -154,6 +169,5 @@ sub background() ...@@ -154,6 +169,5 @@ sub background()
open(STDERR, ">> $logname") or die("opening $logname for STDERR: $!"); open(STDERR, ">> $logname") or die("opening $logname for STDERR: $!");
open(STDOUT, ">> $logname") or die("opening $logname for STDOUT: $!"); open(STDOUT, ">> $logname") or die("opening $logname for STDOUT: $!");
return 0; return 0;
} }
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
# Copyright (c) 2000-2002 University of Utah and the Flux Group. # Copyright (c) 2000-2002 University of Utah and the Flux Group.
# All rights reserved. # All rights reserved.
# #
use English; use English;
# #
...@@ -13,18 +12,8 @@ use English; ...@@ -13,18 +12,8 @@ use English;
# usage: sendevent <event> # usage: sendevent <event>
# #
# # Drag in path stuff so we can find emulab stuff.
# Untaint path BEGIN { require "/etc/emulab/paths.pm"; import emulabpaths; }
#
$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;
# #
# We use the tmcc to figure out where the Testbed Event Daemon is running. # 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.
#