Commit 4f4bd9d4 authored by Leigh B. Stoller's avatar Leigh B. Stoller

Checkpoint the RON/WA version of the client side stuff. This had

suffered some bitrot, but its now in sync and running on wa44, which
is destined to be the source of the next image.
parent ab08326a
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2002 University of Utah and the Flux Group.
# Copyright (c) 2000-2003 University of Utah and the Flux Group.
# All rights reserved.
#
......@@ -22,42 +22,93 @@ all: bossnode
include $(TESTBED_SRCDIR)/GNUmakerules
DESTDIR =
INSTALL_DIR = $(DESTDIR)/usr/local/etc/emulab
INSTALL = /usr/bin/install -c
INSTALL_PROG = /usr/bin/install -c -m 755
DISTDIR = /var/tmp/emulab
DESTDIR =
SYSETCDIR = $(DESTDIR)/etc
ETCDIR = $(DESTDIR)$(CLIENT_ETCDIR)
BINDIR = $(DESTDIR)$(CLIENT_BINDIR)
VARDIR = $(DESTDIR)$(CLIENT_VARDIR)
RCDIR = $(DESTDIR)/usr/local/etc/rc.d
INSTALL = /usr/bin/install -c
install: misc-install script-install bin-install
wa-install: wa-stuff doinstall
ron-install: ron-stuff doinstall
doinstall: common-install etc-install sysetc-install other-install \
sup-install script-install bin-install
@echo "Remember to install the PEM files if necessary"
@echo "Don't forget to do a post-install as root"
dir-install:
-mkdir -p $(INSTALL_DIR)
cp /dev/null $(INSTALL_DIR)/isrem
$(INSTALL) -m 755 -o root -g wheel -d $(ETCDIR)
$(INSTALL) -m 755 -o root -g wheel -d $(BINDIR)
$(INSTALL) -m 755 -o root -g wheel -d $(RCDIR)
$(INSTALL) -m 755 -o root -g wheel -d $(VARDIR)
$(INSTALL) -m 755 -o root -g wheel -d $(VARDIR)/db
$(INSTALL) -m 755 -o root -g wheel -d $(VARDIR)/jails
$(INSTALL) -m 755 -o root -g wheel -d $(VARDIR)/logs
$(INSTALL) -m 755 -o root -g wheel -d $(VARDIR)/sup
$(INSTALL) -m 755 -o root -g wheel -d $(VARDIR)/boot
$(INSTALL) -m 755 -o root -g wheel -d $(VARDIR)/lock
$(INSTALL) -m 755 -o root -g wheel -d $(DESTDIR)/var/log/vtund
$(INSTALL) -m 755 -o root -g wheel -d $(DESTDIR)/var/lock/vtund
$(INSTALL) -m 755 -o root -g wheel -d $(SYSETCDIR)
$(INSTALL) -m 755 -o root -g wheel -d $(SYSETCDIR)/jail
-rm -rf $(DESTDIR)/etc/testbed
ln -s emulab $(DESTDIR)/etc/testbed
-rm -rf $(DESTDIR)/usr/local/etc/testbed
ln -s emulab $(DESTDIR)/usr/local/etc/testbed
misc-install: dir-install bossnode
$(INSTALL) bossnode $(INSTALL_DIR)/bossnode
common-install: dir-install
(cd ../common; $(MAKE) DESTDIR=$(DESTDIR) remote-install)
other-install: dir-install
(cd ../../event/trafgen; $(MAKE) DESTDIR=$(DESTDIR) client-install)
(cd ../freebsd; $(MAKE) DESTDIR=$(DESTDIR) remote-install)
(cd ../../os; $(MAKE) DESTDIR=$(DESTDIR) remote-install)
sup-install: dir-install
$(INSTALL) -m 755 -o root -g wheel -d $(DESTDIR)/root
$(INSTALL) -m 750 -o root -g wheel -d $(DESTDIR)/root/.cvsup
$(INSTALL) -m 600 $(SRCDIR)/cvsup.auth $(DESTDIR)/root/.cvsup/auth
bin-install: dir-install
$(INSTALL_PROG) ../tmcc $(INSTALL_DIR)/tmcc
$(INSTALL_PROGRAM) ../tmcc $(BINDIR)/tmcc
etc-install: dir-install bossnode
cp /dev/null $(ETCDIR)/isrem
$(INSTALL) bossnode $(ETCDIR)/bossnode
$(INSTALL) -m 644 $(SRCDIR)/group $(ETCDIR)/group
$(INSTALL) -m 600 $(SRCDIR)/master.passwd $(ETCDIR)/master.passwd
$(INSTALL) $(SRCDIR)/emulabkey $(ETCDIR)/emulabkey
sysetc-install:
$(INSTALL) -m 644 $(SRCDIR)/ntp.conf $(SYSETCDIR)/ntp.conf
script-install: dir-install
$(INSTALL_PROG) $(SRCDIR)/update $(INSTALL_DIR)/update
$(INSTALL_PROG) $(SRCDIR)/vnodesetup $(INSTALL_DIR)/vnodesetup
$(INSTALL_PROG) $(SRCDIR)/watchdog $(INSTALL_DIR)/watchdog
$(INSTALL_PROG) $(SRCDIR)/../libsetup.pm $(INSTALL_DIR)/libsetup.pm
$(INSTALL_PROG) $(SRCDIR)/liblocsetup-freebsd.pm \
$(INSTALL_DIR)/liblocsetup-freebsd.pm
$(INSTALL_PROG) $(SRCDIR)/liblocsetup-linux.pm \
$(INSTALL_DIR)/liblocsetup-linux.pm
$(INSTALL_PROG) $(SRCDIR)/rc.testbed $(INSTALL_DIR)/rc.testbed
$(INSTALL_PROG) $(SRCDIR)/emulabctl $(INSTALL_DIR)/emulabctl
$(INSTALL_PROG) $(SRCDIR)/install.sh $(INSTALL_DIR)/install.sh
$(INSTALL_PROG) $(SRCDIR)/reinstall $(INSTALL_DIR)/reinstall.sh
$(INSTALL_PROGRAM) $(SRCDIR)/emulabctl $(BINDIR)/emulabctl
$(INSTALL_PROGRAM) $(SRCDIR)/mkemuman.sh $(BINDIR)/mkemuman.sh
$(INSTALL_PROGRAM) $(SRCDIR)/webserver.pl $(BINDIR)/webserver.pl
$(INSTALL_PROGRAM) $(SRCDIR)/prepare $(BINDIR)/prepare
ifndef NORCD
rm -f $(RCDIR)/testbed.sh
rm -f $(RCDIR)/emulab.sh
rm -f $(RCDIR)/z.emulab.sh
$(INSTALL_PROGRAM) $(SRCDIR)/cvsup.sh $(RCDIR)/0.cvsup.sh
$(INSTALL_PROGRAM) $(SRCDIR)/emulab.sh $(RCDIR)/z.emulab.sh
endif
post-install:
chown root $(INSTALL_DIR)/update
chmod u+s $(INSTALL_DIR)/update
chown root $(INSTALL_DIR)/vnodesetup
chmod u+s $(INSTALL_DIR)/vnodesetup
$(BINDIR)/mkemuman.sh
(chown emulabman $(BINDIR) $(BINDIR)/*)
(chgrp bin $(BINDIR) $(BINDIR)/*)
(chown emulabman $(ETCDIR) $(ETCDIR)/*)
(chgrp bin $(ETCDIR) $(ETCDIR)/*)
chown root $(BINDIR)/update
chmod u+s $(BINDIR)/update
chown root $(BINDIR)/vnodesetup
chmod u+s $(BINDIR)/vnodesetup
-chown root $(DESTDIR)/usr/bin/suidperl
-chmod u+s $(DESTDIR)/usr/bin/suidperl
#
# We build the bossnode file from config info
......@@ -65,5 +116,20 @@ post-install:
bossnode: GNUmakefile
echo >$@ "$(BOSSNODE)"
wa-stuff: dir-install
$(INSTALL) -m 755 $(SRCDIR)/supfile.wa $(ETCDIR)/supfile
ron-stuff: dir-install
$(INSTALL) -m 755 $(SRCDIR)/supfile.ron $(ETCDIR)/supfile
ron-dist: distdir
($(MAKE) DESTDIR=$(DISTDIR)/root ron-install)
rm -f /tmp/emulab-ron.tar
tar cf /tmp/emulab-ron.tar -C $(DISTDIR) .
distdir:
rm -rf $(DISTDIR)
mkdir -p $(DISTDIR)
clean:
rm -f bossnode
......@@ -12,12 +12,12 @@
case "$1" in
start)
if [ -f $BINDIR/emulabctl ]; then
$BINDIR/emulabctl start
$BINDIR/emulabctl start && echo -n ' Emulab'
fi
;;
stop)
if [ -f $BINDIR/emulabctl ]; then
$BINDIR/emulabctl stop
$BINDIR/emulabctl stop && echo -n ' Emulab'
fi
;;
restart)
......
#!/bin/sh
#!/usr/bin/perl -w
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2002 University of Utah and the Flux Group.
# Copyright (c) 2000-2003 University of Utah and the Flux Group.
# All rights reserved.
#
. /etc/emulab/paths.sh
#
# Boottime initialization.
#
case "$1" in
start)
$BINDIR/watchdog > /dev/null 2>&1 && echo -n ' Emulab'
#
# Do not start the mini server on RON nodes yet.
#
if [ -x $BINDIR/webserver.pl -a -e /etc/emulab.pkey ]
then
$BINDIR/webserver.pl && echo -n ' Webserver'
fi
;;
stop)
if [ -f /var/run/emulab-watchdog.pid ]; then
kill `cat /var/run/emulab-watchdog.pid` && echo -n ' Emulab'
fi
if [ -f /var/run/webserver.pid ]; then
kill `cat /var/run/webserver.pid` && echo -n ' Webserver'
fi
;;
*)
echo "Usage: `basename $0` {start|stop}" >&2
;;
esac
exit 0
use Getopt::Std;
use English;
use Errno;
use POSIX qw(strftime);
#
# Start/Stop the emulab support. Since we do not want to hold up the boot
# on a remote node, this goes into the background, and exits when done.
# The stop event kills one on progress.
#
sub usage()
{
print "Usage: emulabctl [-n] <start | stop>\n";
exit(1);
}
my $optlist = "nd";
#
# Must be root.
#
if ($UID != 0) {
die("*** $0:\n".
" Must be root to run this script!\n");
}
#
# 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; }
#
# Load the OS independent support library. It will load the OS dependent
# library and initialize itself.
#
use libsetup;
# Locals
my $logname = "$LOGDIR/emulab-boot.debug";
my $pidfile = "/var/run/emulab-boot.pid";
my $noboot = 0;
my $debug = 0;
#
# Parse command arguments. Once we return from getopts, all that should be
# left are the required arguments.
#
%options = ();
if (! getopts($optlist, \%options)) {
usage();
}
if (defined($options{"n"})) {
$noboot = 1;
}
if (defined($options{"d"})) {
$debug = 1;
}
if (@ARGV != 1) {
usage();
}
my $action = $ARGV[0];
if ($action ne "start" && $action ne "stop") {
usage();
}
#
# For stop, look to see if the pid file exists. If so, kill it and exit.
#
if ($action eq "stop") {
if (-e "/etc/emulab.pkey") {
system("webserver.pl stop");
}
system("watchdog stop");
if (! -e $pidfile) {
exit(0);
}
system("kill `cat $pidfile`");
exit($? >> 8);
}
#
# Go to background.
#
#
# Put this into the background and log its output. We *must* do this cause
# we do not want to halt the boot if the testbed is down!
#
if (!$debug && TBBackGround($logname)) {
#
# Parent exits normally
#
exit(0);
}
#
# Write our pid into the pid file so we can be killed later (when the
# experiment is torn down). We must do this first so that we can be
# killed before we change the sig handlers.
#
system("echo '$PID' > $pidfile") == 0
or die("Could not create $pidfile!");
#
# Setup a handler to catch TERM, and kill our process group. Generally,
# you do not want to send this a TERM, but use the stop argument instead.
#
my $pgrp = getpgrp(0);
sub handler () {
$SIG{TERM} = 'IGNORE';
$SIG{INT} = 'IGNORE';
unlink($pidfile);
kill('TERM', -$pgrp);
sleep(1);
exit(0);
}
$SIG{TERM} = \&handler;
$SIG{INT} = \&handler;
#
# Run the tmcc commands in blocking mode. No point in continuing if we
# cannot get a tmcd connection formed to tell it we are rebooting.
#
print "Informing Emulab Operations that we've rebooted ...\n";
system("tmcc state TBSETUP");
#
# Do a cvsup to get updated software.
#
print "Looking for software updates ... \n";
system("runcvsup.sh");
#
# Do Apod.
#
print "Setting up APOD ... \n";
system("rc.ipod");
#
# At bootup, look for new accounts.
#
print "Looking for new Emulab accounts ...\n";
system("update -i");
#
# Do not start the mini server on RON nodes yet.
#
if (-e "/etc/emulab.pkey") {
print "Starting up stub webserver ...\n";
system("webserver.pl start");
}
# Startup vnodes.
if (! $noboot) {
print "Booting up vnodes ...\n";
system("bootvnodes -f");
}
# And the watchdog.
print "Starting up the watchdog ...\n";
system("watchdog");
#
# Inform TMCD that we are up and running.
#
print "Informing Emulab Operations that we're up and running ...\n";
system("tmcc state ISUP");
# Done!
print "Done! Exiting ...\n";
unlink($pidfile);
exit(0);
wheel:*:0:root,dga
daemon:*:1:daemon
kmem:*:2:root
sys:*:3:root
tty:*:4:root
operator:*:5:root
mail:*:6:
bin:*:7:
news:*:8:
man:*:9:
games:*:13:
staff:*:20:root
smmsp:*:25:
mailnull:*:26:
guest:*:31:root
bind:*:53:
uucp:*:66:
xten:*:67:xten
dialer:*:68:
network:*:69:
www:*:80:
nogroup:*:65533:
nobody:*:65534:
sfs:*:65531:
root:$1$jaWoIhGi$Syh2lEoAbQkUy3D8YDjW4.:0:0::0:0:Charlie &:/root:/bin/tcsh
toor:*:0:0::0:0:Bourne-again Superuser:/root:
daemon:*:1:1::0:0:Owner of many system processes:/root:/sbin/nologin
operator:*:2:5::0:0:System &:/:/sbin/nologin
bin:*:3:7::0:0:Binaries Commands and Source:/:/sbin/nologin
tty:*:4:65533::0:0:Tty Sandbox:/:/sbin/nologin
kmem:*:5:65533::0:0:KMem Sandbox:/:/sbin/nologin
games:*:7:13::0:0:Games pseudo-user:/usr/games:/sbin/nologin
news:*:8:8::0:0:News Subsystem:/:/sbin/nologin
man:*:9:9::0:0:Mister Man Pages:/usr/share/man:/sbin/nologin
smmsp:*:25:25::0:0:Sendmail Submission User:/var/spool/clientmqueue:/sbin/nologin
mailnull:*:26:26::0:0:Sendmail Default User:/var/spool/mqueue:/sbin/nologin
bind:*:53:53::0:0:Bind Sandbox:/:/sbin/nologin
uucp:*:66:66::0:0:UUCP pseudo-user:/var/spool/uucppublic:/usr/libexec/uucp/uucico
xten:*:67:67::0:0:X-10 daemon:/usr/local/xten:/sbin/nologin
pop:*:68:6::0:0:Post Office Owner:/nonexistent:/sbin/nologin
www:*:80:80::0:0:World Wide Web Owner:/nonexistent:/sbin/nologin
nobody:*:65534:65534::0:0:Unprivileged user:/nonexistent:/sbin/nologin
sfs:*:65531:65531::0:0:SFS user:/usr/local/sfs:/sbin/nologin
emulabman:*:65520:7::0:0:Emulab Man:/home/emulabman:/bin/tcsh
### Servers
# Local refclock, if we have one.
server 127.127.29.0 prefer
fudge 127.127.29.0 refid CDMA
# Remote servers. Please customize for each RON box.
server mit-main.ron.lcs.mit.edu maxpoll 8
server 155.101.134.253
server 18.31.0.144
### Files
driftfile /etc/ntp.drift
### Authentication ###
keys /etc/ntp.keys
requestkey 15
controlkey 15
trustedkey 15
#!/usr/bin/perl -w
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2003 University of Utah and the Flux Group.
# All rights reserved.
#
use English;
require 'ctime.pl';
# Drag in path stuff so we can find emulab stuff.
BEGIN { require "/etc/emulab/paths.pm"; import emulabpaths; }
#
# Prepare the node for cutting a new image. Should be run just prior, on
# each of the FreeBSD and Linux partitions.
#
my $DUMPDATES = "/etc/dumpdates";
my @VARDIRS = ("logs", "db", "jails", "boot", "lock");
my $FSTAB = "/etc/fstab";
my $LOGDIR = "/var/log";
my $RUNDIR = "/var/run";
my $ACCTDIR = "/var/account";
my $HISTORY = "/root/.history";
my $MAILDIR = "/var/mail";
my $LEASES = "/var/db/dhclient.leases";
my $NTPDRIFT = "/etc/ntp.drift";
my $SFSUSERS = "/etc/sfs/sfs_users";
my $SFSHOSTKEY = "/etc/sfs/sfs_host_key";
my $MOUNTINFO = "/var/db/mounttab";
my @ETCFILES = ("rc.conf.local", "resolv.conf", "namedb/localhost.rev",
"emulab.pkey", "emulab-hard.txt", "emulab-soft.txt");
my $USERS = "/users";
#
# 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;
#
# First clean up the node as it would be if free.
#
cleanup_node(1);
#
# Build the locate database. I hate that its never there!
#
if (-x "/usr/libexec/locate.updatedb") {
print "Building the locate database ... Be patient, will ya!\n";
system("/usr/libexec/locate.updatedb");
}
#
# Generate a dumpdates file. Use fstab to find out what filesystems
# need entries, and then put in entries for each filesystem using
# the current date.
#
print "Removing old /etc/dumpdates file ...\n";
if (-e $DUMPDATES) {
unlink($DUMPDATES) or
die("Could not unlink $DUMPDATES");
}
print "Creating stub /etc/dumpdates file ...\n";
open(TAB, "$FSTAB") or
die("Could not open $FSTAB: $!");
open(DMP, ">$DUMPDATES") or
die("Could not open $DUMPDATES: $!");
while (<TAB>) {
if ($_ =~ /^([\w\/]+).*(\d).*\d$/) {
if ($2 != 0) {
my $t = localtime(time);
print DMP "$1 0 $t\n";
}
}
}
close(DMP);
close(TAB);
print "Cleaning logfiles ...\n";
opendir(LOG,$LOGDIR) or
die("Could not open directory $LOGDIR: $!");
while ($dirent = readdir(LOG)) {
my $file = $LOGDIR . "/" . $dirent;
if (-f $file) {
if (($file =~ /\.\d+$/) || ($file =~ /\.\d\.gz$/) ||
($file =~ /\.(today|yesterday)$/)) {
# Remove archived logfiles
unlink($file) or
die("Could not unlink $file: $!");
} elsif (-s $file) {
# Truncate other logfiles - many do not get re-created
truncate($file,0) or
die("Could not truncate $file: $!");
}
}
}
closedir(LOG);
#
# Must remove /var/db/mounttab or else at boot time the node will attempt
# to contact all the servers listed in the file to tell them that the
# indicated filesystems are no longer mounted by this node. Normally this
# is harmless however, if the listed server is not reachable in the image's
# new environment (e.g., you are making an image for another testbed), each
# and every one of the listed server/fs pairs will hang for 5 minutes or so.
#
print "Removing $MOUNTINFO ...\n";
if (-f $MOUNTINFO) {
unlink($MOUNTINFO) or
die("Could not unlink $MOUNTINFO: $!");
}
print "Removing root's history ...\n";
if (-f $HISTORY) {
unlink($HISTORY) or
die("Could not unlink $HISTORY: $!");
}
print "Cleaning mail spool files ...\n";
system("rm -rf $MAILDIR/*");
#
# Just removing the drift file results in no drift being tracked,
# so set it to zero instead. Not ideal, but at least the clock will
# stabilize eventually this way.
#
print "Resetting drift in $NTPDRIFT ...\n";
if (-f $NTPDRIFT) {
open(DRIFT, ">$NTPDRIFT") or
die("Could not open $NTPDRIFT: $!");
print DRIFT "0\n";
close(DRIFT);
}
print "Cleaning .pid files ...\n";
system("rm -rf $RUNDIR/*.pid");
print "Clearing utmp file ...\n";
system("rm -rf $RUNDIR/utmp");
print "Cleaning out /tmp ...\n";
system("rm -rf /tmp/* /tmp/.??*");
print "Removing dhclient leases ...\n";
system("rm -f $LEASES");
print "Cleaning out old accounting files ...\n";
system("rm -rf $ACCTDIR/*");
#
# Urk. Old copies of passwd files are stored here...
#
print "Cleaning out /var/backups ...\n";
system("rm -rf /var/backups/*");
print "Removing SFS files ...\n";
if (-f $SFSUSERS) {
system("rm -f $SFSUSERS ${SFSUSERS}.pub");
system("rm -f $SFSUSERS.old ${SFSUSERS}.pub.old");
}
if (-f $SFSHOSTKEY) {
system("rm -f $SFSHOSTKEY");
}
print "Clearing out directories in $VARDIR ...\n";
foreach my $dir (@VARDIRS) {
if (-d "$VARDIR/$dir") {
system("rm -rf $VARDIR/$dir/*");
}
}
print "Clearing localization files from /etc ...\n";
foreach my $file (@ETCFILES) {
if (-f "/etc/$file") {
system("rm -f /etc/$file");
}
}
print "Clearing out /users ...\n";
system("rm -rf $USERS/*");
print "Recreating ~emulabman after clearing /users ...\n";
system("$BINDIR/mkemuman.sh");
print "Clearing out old SFS links ... \n";
system("rm -f /netbed/*");