Commit 90f6cac6 authored by Dan Reading's avatar Dan Reading
Browse files

moving files

parent f1127939
#!/usr/bin/perl -w
#
# Copyright (c) 2004-2012 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
# This file is part of the Emulab network testbed software.
#
# This file is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
#
# This file is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
# License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this file. If not, see <http://www.gnu.org/licenses/>.
#
# }}}
#
use English;
use Getopt::Std;
#
# This is the entrypoint to running the config scripts. It would be nice
# to just stick these in a directory and run them all, but order matters
# and I hate naming things so that the order comes up the way I want it!
# Anyway, this script fires off the rc scripts in the proper order.
#
# All of the scripts accept a -j argument since in some cases we run these
# on behalf of a vnode, and the script needs to tell the tmcc library the
# vnodeid for when it talks to tmcd. Otherwise, libtmcc knows when it is
# running *inside* a vnode and sets things up properly for talking to tmcd.
#
sub usage()
{
print "Usage: " .
scriptname() . " [-j vnodeid] boot|shutdown|reconfig|reset\n";
exit(1);
}
my $optlist = "j:dM";
my %options = ();
my $action = "boot";
my $debug = 0;
my $vnodeid;
my $updatemasterpasswdfiles = 0;
# 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");
}
#
# 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{'j'})) {
$vnodeid = $options{'j'};
libsetup_setvnodeid($vnodeid);
}
if (defined($options{'d'})) {
$debug++;
}
if (defined($options{'M'})) {
$updatemasterpasswdfiles = 1;
}
# Allow default above.
if (@ARGV) {
$action = $ARGV[0];
}
#
# The master list of scripts. Add in the right order! To speed things up
# specify a shorter set for the MFS.
#
my @bootscripts;
my %bootscript_args = ( 'rc.accounts' => $updatemasterpasswdfiles ?
'-M' : '' );
if (MFS()) {
@bootscripts = ("rc.misc", "rc.localize", "rc.mounts", "rc.accounts",
"rc.hostnames", "rc.keys", "rc.tarfiles", "rc.rpms",
"rc.tpmsetup");
}
elsif (FAKEJAILED()) {
@bootscripts = ("rc.misc", "rc.keys", "rc.route", "rc.tunnels",
"rc.ifconfig", "rc.progagent");
}
elsif (WINDOWS()) {
@bootscripts = ("rc.misc", "rc.localize", "rc.keys", "rc.mounts",
"rc.accounts", "rc.topomap",
"rc.route", "rc.ifconfig",
"rc.hostnames", "rc.lmhosts", "rc.syncserver",
# rc.progagent is run by a separate service named ProgAgent.
# It's started by EmulabStartup after rc.bootsetup runs.
"rc.tarfiles", "rc.rpms");
}
else {
@bootscripts = ("rc.firewall", "rc.tpmsetup",
"rc.misc", "rc.localize", "rc.keys", "rc.mounts",
"rc.blobs",
"rc.topomap", "rc.accounts",
"rc.route", "rc.tunnels", "rc.ifconfig", "rc.delays",
"rc.hostnames", "rc.trace",
"rc.syncserver", "rc.trafgen",
"rc.tarfiles", "rc.rpms", "rc.progagent", "rc.linkagent",
"rc.tiptunnels", "rc.motelog", "rc.simulator", "rc.diskagent",
"rc.nodecheck"
);
}
# 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");
}
exit(0);
sub doaction($@)
{
my ($what, @scripts) = @_;
#
# Run all the scripts. We run them all, not worrying about individual
# failure. Right thing to do? Maybe stop on failure?
#
my $optarg = (defined($vnodeid) ? "-j $vnodeid" : "");
#
# Grab our manifest so we can enable/disable/replace this script and
# run (or not) its hooks.
#
my %manifest = ();
getmanifest(\%manifest);
foreach my $script (@scripts) {
my $bargs = '';
if (exists($bootscript_args{$script})
&& defined($bootscript_args{$script})) {
$bargs = $bootscript_args{$script};
}
# No need to install all this cruft on the MFS or other small envs.
next
if (!-x "$BINDIR/rc/$script");
runbootscript(\%manifest,"$BINDIR/rc",$script,$what,"$optarg $bargs $what");
}
}
#
# Boot Action.
#
sub doboot()
{
doaction("boot", @bootscripts);
}
#
# Shutdown Action.
#
sub doshutdown()
{
doaction("shutdown", reverse(@bootscripts));
}
#
# Node Reconfig Action (without rebooting).
#
sub doreconfig()
{
doshutdown();
#
# Must tell tmcc to reload its cache!
#
tmccgetconfig();
return doboot();
}
#
# Node cleanup action (node is reset to completely clean state).
#
sub docleanup()
{
doaction("reset", @bootscripts);
}
#!/usr/bin/perl -w
#
# Copyright (c) 2004, 2006 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
# This file is part of the Emulab network testbed software.
#
# This file is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
#
# This file is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
# License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this file. If not, see <http://www.gnu.org/licenses/>.
#
# }}}
#
use English;
use Getopt::Std;
# 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; }
#LINUX
#@checkscripts = ("disk", "cpu", "mem", "time", "nic", "diskspeed");
# do not run timecheck for MFS hw gather mode
@checkscripts = ("disk", "cpu", "mem", "time", "nic");
$host = `/usr/local/etc/emulab/tmcc.bin nodeid`;
#$host = `hostname`;
#if ( -r '/var/emulab/boot/realname' ) {
# $host = `cat /var/emulab/boot/realname`;
#} elsif ( -f '/var/emulab/boot/nodeid' ) {
# $host = `cat /var/emulab/boot/nodeid`;
#}
chomp($host);
if ( -r '/etc/emulab/ismfs' ) {
if ( ! -r '/proj/emulab-ops/nodecheck' ) {
system("mount -o bg,soft,intr fs.emulab.net:/q/proj/emulab-ops /proj/emulab-ops");
}
my $os = `uname -s`;
chomp($os);
if ($os eq "Linux") {
$ENV{'PATH'} = "/usr/local/bin:/proj/emulab-ops/nodecheck/Linux/bin:$ENV{'PATH'}";
}
if ($os eq "FreeBSD") {
$ENV{'PATH'} = "/usr/local/bin:/proj/emulab-ops/nodecheck/FreeBSD/bin:$ENV{'PATH'}";
}
system("echo 'Running Hardware Inventory Gather'");
system("bash /usr/local/etc/emulab/gatherinv");
system("echo 'Done Running Hardware Inventory'");
exit (0);
}
system("echo 'Running nodechecks'");
if (!$ARGV[0]) {
$action = "noboot";
} else
{
$action = "boot"
}
# truncate file at boot time
if ($action eq "boot") {
system("echo '-- Start boot_time_node_check --' > /var/emulab/logs/nodecheck.log");
}
foreach my $i (@checkscripts) {
system("bash /usr/local/etc/emulab/${i}check /var/emulab/logs/nodecheck.log");
}
if ($action eq "boot") {
system("echo '-- Finish boot_time_node_check --' >> /var/emulab/logs/nodecheck.log");
}
system("echo 'Done with nodechecks'");
exit(0);
#! /bin/sh
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2005 University of Utah and the Flux Group.
# All rights reserved.
#
#
# This is a shell script instead of a perl script since we want to use this
# in the frisbee MFS which does not include perl.
#
if [ -r /etc/emulab/paths.sh ]; then
. /etc/emulab/paths.sh
else
BINDIR=/etc/testbed
fi
# FREEBSD
host=`/usr/local/etc/emulab/tmcc.bin nodeid`
#checks="disk cpu mem time nic diskspeed"
# do not run timecheck for MFS hw gather mode
#checks="disk cpu mem time nic"
checks="disk cpu mem nic gather"
if [ -f '/etc/emulab/ismfs' ] ; then
if [ ! -d '/proj/emulab-ops/nodecheck' ] ; then
$("mount -o soft,intr,bg fs.emulab.net:/q/proj/emulab-ops /proj/emulab-ops")
fi
os=`uname -s`
if [ "$os" = "Linux" ] ; then
export PATH="/usr/local/bin:/proj/emulab-ops/nodecheck/Linux/bin:$PATH"
elif [ "$os" = "FreeBSD" ] ; then
export PATH="/usr/local/bin:/proj/emulab-ops/nodecheck/FreeBSD/bin:$PATH"
fi
echo 'Running Hardware Inventory Gather'
bash /usr/local/etc/emulab/gatherinv
echo 'Done Running Hardware Inventory'
exit 0
fi
echo "Running nodechecks"
# truncate file at boot time
if [ "$1" = "boot" ] ; then
$(echo "-- Start boot_time_node_check --" > /var/emulab/logs/nodecheck.log)
$(cp /dev/null /tmp/nodecheck.log.tb)
for i in $checks
do
bash /usr/local/etc/emulab/${i}check /var/emulab/logs/nodecheck.log /tmp/nodecheck.log.tb
done
$(echo "-- Finish boot_time_node_check --" >> /var/emulab/logs/nodecheck.log)
if [ -f /tmp/nodecheck.log.tb ] ; then
cp /tmp/nodecheck.log.tb /proj/emulab-ops/nodecheck/$host
cp /tmp/nodecheck.log.inv /proj/emulab-ops/nodecheck/$host.full
chmod a+r /proj/emulab-ops/nodecheck/$host*
fi
else
$(rm -f /tmp/nodecheck.log.tb)
for i in $checks
do
bash /usr/local/etc/emulab/${i}check /var/emulab/logs/nodecheck.log
done
fi
echo "Done with nodechecks"
exit 0
Supports Markdown
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