Commit ede28955 authored by Ryan Jackson's avatar Ryan Jackson

Added scripts to support a Linux MFS. Also began modifications to rc.frisbee...

Added scripts to support a Linux MFS.  Also began modifications to rc.frisbee and slicefix to make them less FreeBSD-specific.
parent 9d803873
......@@ -41,10 +41,53 @@ DEFRUNLVLDIR ?= $(RCDIR)/rc3.d
# without DESTDIR, used for the value of symlinks
RRCDIR ?= /etc/rc.d
destdircheck:
@if [ -z "$(DESTDIR)" ]; then \
echo "You must define DESTDIR for this target!"; \
false; \
fi
@if [ "$(DESTDIR)" = "/" ]; then \
echo "DESTDIR is '/', really really bad idea!"; \
false; \
fi
install client-install: common-install etc-install \
sup-install script-install bin-install vserver-install
@echo "Remember to install the PEM files if necessary"
mfs-install: destdircheck common-install etc-install \
script-install bin-install
rm -f $(BINDIR)/rc/rc.mkelab
rm -f $(RCDIR)/elvind.sh
@if [ ! -f $(ISMFS) ]; then \
echo >$(ISMFS) "This file indicates its the MFS. DO NOT DELETE!"; \
fi
frisbee-mfs-install: destdircheck
$(INSTALL) -m 644 $(SRCDIR)/frisbee/rc.local $(SYSETCDIR)/rc.local
$(INSTALL) -m 755 $(SRCDIR)/dhclient-exit-hooks \
$(SYSETCDIR)/dhclient-exit-hooks
$(INSTALL) -m 755 $(SRCDIR)/dhclient-enter-hooks \
$(SYSETCDIR)/dhclient-enter-hooks
@if [ -r $(SRCDIR)/master.passwd ]; then \
$(INSTALL) -m 600 $(SRCDIR)/master.passwd $(SYSETCDIR); \
pwd_mkdb -d $(SYSETCDIR) $(SYSETCDIR)/master.passwd; \
if [ ! -e $(DESTDIR)/bin/csh ]; then \
ln $(DESTDIR)/bin/sh $(DESTDIR)/bin/csh; \
fi \
fi
@if [ -r $(SRCDIR)/group ]; then \
$(INSTALL) -m 644 $(SRCDIR)/group $(SYSETCDIR); \
fi
$(INSTALL) -m 755 $(SRCDIR)/control_interface $(SYSETCDIR)/testbed
$(INSTALL) -m 755 $(SRCDIR)/rc.frisbee $(SYSETCDIR)/testbed
$(INSTALL) -m 755 $(SRCDIR)/rc.ipod $(SYSETCDIR)/testbed
$(INSTALL) -m 755 $(SRCDIR)/slicefix $(SYSETCDIR)/testbed
$(INSTALL) -m 755 -s ../tmcc-nossl $(SYSETCDIR)/testbed/tmcc
$(INSTALL) -m 755 -s ../findif $(SYSETCDIR)/testbed
rm -f $(BINDIR)/rc/rc.mkelab
rm -f $(RCDIR)/elvind.sh
simple-install: common-install script-install bin-install
dir-install:
......@@ -138,6 +181,7 @@ script-install: dir-install $(SCRIPTS)
$(INSTALL) -m 755 $(SRCDIR)/nodetype $(BINDIR)/nodetype
$(INSTALL) -m 755 $(SRCDIR)/chipset.awk $(BINDIR)/chipset.awk
$(INSTALL) -m 755 $(SRCDIR)/cpuspeed.awk $(BINDIR)/cpuspeed.awk
$(INSTALL) -m 755 $(SRCDIR)/rc.mfs $(BINDIR)/rc/rc.mfs
sfs-install:
$(INSTALL) -m 755 -o root -g root -d $(DESTDIR)/etc/sfs
......
#! /bin/sh
disk=$1
part=$2
if [ $# -ne 2 ]; then
exit 1
fi
freebsd_slices=`fdisk -l /dev/$disk 2> /dev/null | \
sed -n '/a5 *FreeBSD/s#^/dev/'$disk'\([0-9]*\) .*$#\1#p'`
total_slices=`fdisk -l /dev/$disk | grep "^/dev/$disk[0-9]" | wc -l`
if [ $total_slices -eq 0 ]; then
exit 1;
fi
if [ -z "$freebsd_slices" ]; then
# No slices?
exit 1
fi
dmesg_output=`dmesg | grep " *$disk$part: <bsd: $disk[0-9]* "`
# Valid disklabels should be properly parsed by linux. If it didn't like
# the label, we can't mount anything.
if [ -z "$dmesg_output" ]; then
# invalid disklabel
exit 1
fi
(
# Change partition types to empty for all other FreeBSD slices
# so we can get the disklabel for the correct slice. These
# changes don't get written to disk. They're just here because
# Linux's fdisk sucks and doesn't let us specify which partition's
# disklabel to edit.
for slice in $freebsd_slices; do
[ $slice -eq $part ] && continue
echo t # Change slice type
if [ $total_slices -gt 1 ]; then
echo $slice # Specify slice
fi
echo 0 # Set to empty type
done
echo b # Change to BSD disklabel mode
echo p # Print disklabel
echo q # Quit (don't write to disk)
) | fdisk /dev/$disk 2> /dev/null | grep '^ *a:' > /dev/null
rc=$?
# Valid disklabel, but no 'a' partition.
if [ $rc -ne 0 ]; then
exit 1
fi
# We have a valid disklabel with an 'a' partition.
# Output the Linux device name for it.
echo $dmesg_output | cut -d' ' -f3
exit 0
#! /bin/sh
disk=$1
part=$2
if [ -z "$disk" ] || [ -z "$part" ]; then
echo "Usage: ${0##*/} disk partition"
exit 1
fi
# figure out the linux device name
dunit=`echo $disk | sed -e 's/..\([0-7]\)/\1/'`
case $disk in
# IDE
ad[0-3])
dtype="hd"
d=`echo $dunit | sed -e 'y/0123/048c/'`
lrootdev="3${d}${part}"
;;
# SATA
ad[4-7])
dtype="sd"
dunit=`expr $dunit - 4`
lrootdev="8${dunit}${part}"
;;
# SCSI
da[0-7])
dtype="sd"
lrootdev="8${dunit}${part}"
;;
# Megaraid
amrd[0-7])
dunit=`echo $disk | sed -e 's/amrd\([0-7]\)/\1/'`
dtype="sd"
lrootdev="8${dunit}${part}"
;;
*)
echo "${0##*/}: linux: unknown disk $disk" 1>&2
return 1
;;
esac
dunit=`echo $dunit | sed -e 'y/01234567/abcdefgh/'`;
ldisk=$dtype$dunit
echo $ldisk $lrootdev
This diff is collapsed.
#!/usr/bin/perl -w
#
# EMULAB-COPYRIGHT
# Copyright (c) 2004, 2005 University of Utah and the Flux Group.
# All rights reserved.
#
use English;
use Getopt::Std;
#
# This script is run directly from boot. It should NOT be run after
# that since some stuff is not setup to properly restart yet. For
# general reconfig or update, use rc.config instead.
#
sub usage()
{
print "Usage: " . scriptname() . "boot|shutdown|reconfig|reset\n";
exit(1);
}
my $optlist = "";
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 ($EUID != 0) {
die("*** $0:\n".
" Must be root to run this script!\n");
}
# Script specific goo.
my $RCDIR = "$BINDIR/rc";
#
# 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();
# Allow default above.
if (@ARGV) {
$action = $ARGV[0];
}
# 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()
{
#
# The MFS does a very restricted set of operations.
#
print("Doing Testbed Setup on an MFS\n");
print("Informing Emulab Control that we have rebooted\n");
if (tmcc(TMCCCMD_STATE, "MFSSETUP") < 0) {
fatal("Error sending MFSSETUP to Emulab Control!");
}
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.
}
# XXX enable the NFS client-side EACCES hack
if (-x "$RCDIR/rc.nfshack") {
print("Enabling client-side NFS EACCES hack\n");
system("$RCDIR/rc.nfshack");
# This is allowed to fail; the hack might not be supported.
}
# Now we get into the real work.
print("Checking Testbed reservation status\n");
my ($pid, $eid, $vname) = bootsetup();
#
# This stuff is run regardless of reservation status.
#
if (-x "$RCDIR/rc.slothd") {
print("Starting slothd usage detector\n");
system("$RCDIR/rc.slothd start");
if ($?) {
fatal("Error running $RCDIR/rc.slothd");
}
}
#
# This is where we run all of the config scripts. These talk to the
# DB and setup the node the way it is supposed to be.
#
if (!defined($pid)) {
print("Resetting node to a clean state\n");
system("$RCDIR/rc.config reset");
}
else {
print("Running config scripts\n");
system("$RCDIR/rc.config boot");
}
if ($?) {
fatal("Error running $RCDIR/rc.config");
}
print("Informing Emulab Control that we are up and running\n");
if (tmcc(TMCCCMD_STATE, "ISUP") < 0) {
fatal("Error sending ISUP to Emulab Control!");
}
#
# After everything is setup, run any startup command.
#
# Note that this mechanism is only used for the admin MFS now,
# regular user startup commands are run via the program agent.
#
if (-x "$RCDIR/rc.startcmd") {
TBDebugTimeStamp("running $RCDIR/rc.startcmd");
system("$RCDIR/rc.startcmd boot");
if ($?) {
fatal("Error running $RCDIR/rc.startcmd");
}
}
}
#
# Shutdown Action.
#
sub doshutdown()
{
}
#
# Node Reconfig Action (without rebooting).
#
sub doreconfig()
{
}
#
# Node cleanup action (node is reset to completely clean state).
#
sub docleanup()
{
}
This diff is collapsed.
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