From 7d67d6bd5b303deb6b8ae628be44013de373c92d Mon Sep 17 00:00:00 2001
From: "Leigh B. Stoller" <stoller@flux.utah.edu>
Date: Thu, 15 Aug 2002 23:56:38 +0000
Subject: [PATCH] Random tweaks I made while getting things going for pcwa
 nodes.

---
 tmcd/freebsd/setipod |  5 +++--
 tmcd/makefile        | 29 +++++++++++++++++++++++++----
 tmcd/ron/install.sh  |  1 +
 tmcd/ron/watchdog    | 20 +++++++++++++++++++-
 tmcd/ssl.c           |  1 +
 5 files changed, 49 insertions(+), 7 deletions(-)

diff --git a/tmcd/freebsd/setipod b/tmcd/freebsd/setipod
index c6e3e35164..4ab76fba04 100755
--- a/tmcd/freebsd/setipod
+++ b/tmcd/freebsd/setipod
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -wT
+#!/usr/bin/perl -w
 #
 # EMULAB-COPYRIGHT
 # Copyright (c) 2000-2002 University of Utah and the Flux Group.
@@ -21,7 +21,8 @@ use Socket;
 #
 # Untaint path
 #
-$ENV{'PATH'} = '/bin:/sbin:/usr/bin:/usr/local/bin:/etc/testbed';
+$ENV{'PATH'}  = "/bin:/sbin:/usr/bin:/usr/local/bin";
+$ENV{'PATH'} .= ":/usr/local/etc/emulab:/etc/testbed";
 delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
 
 #
diff --git a/tmcd/makefile b/tmcd/makefile
index 11ad465f48..7b746d037a 100644
--- a/tmcd/makefile
+++ b/tmcd/makefile
@@ -1,7 +1,9 @@
 #
 # Testbed TMCD client program
 #
-CFLAGS	       += -O -g -Wall -DUDP -DSTANDALONE -DBOSSNODE='"boss.emulab.net"'
+BOSSNODE        = boss.emulab.net
+#BOSSNODE        = golden-gw.ballmoss.com
+CFLAGS	       += -O -g -Wall -DUDP -DSTANDALONE -DBOSSNODE='"$(BOSSNODE)"'
 SRCDIR          = .
 DESTDIR		=
 INSTALL_DIR	= $(DESTDIR)/usr/local/etc/emulab
@@ -11,6 +13,7 @@ DISTFILES	= makefile decls.h libsetup.pm ssl.c ssl.h tmcc.c
 WAFILES		= liblocsetup-linux.pm liblocsetup-freebsd.pm install.sh \
 			emulabctl rc.testbed update vnodesetup watchdog \
 			reinstall.sh emulabkey
+BSDFILES	= setipod
 DISTDIR		= /tmp/emulab
 
 #
@@ -28,7 +31,7 @@ ssl.o:	ssl.c ssl.h decls.h
 clean: 
 	rm -f *.o core tmcc
 
-install:	misc-install script-install bin-install
+force-install:	misc-install script-install bin-install
 
 dir-install:
 	-mkdir -p $(INSTALL_DIR)
@@ -45,6 +48,9 @@ script-install:	dir-install
 	for file in $(WAFILES); do \
 		$(INSTALL_PROG) $(SRCDIR)/$$file $(INSTALL_DIR)/$$file; \
 	done
+	for file in $(BSDFILES); do \
+		$(INSTALL_PROG) $(SRCDIR)/$$file $(INSTALL_DIR)/$$file; \
+	done
 	$(INSTALL_PROG) $(SRCDIR)/libsetup.pm $(INSTALL_DIR)/libsetup.pm
 	$(INSTALL) -m 440 $(SRCDIR)/client.pem $(INSTALL_DIR)/client.pem
 	$(INSTALL) -m 440 $(SRCDIR)/emulab.pem $(INSTALL_DIR)/emulab.pem
@@ -65,13 +71,28 @@ post-install:
 	chown emulabman $(INSTALL_DIR)/client.pem $(INSTALL_DIR)/emulab.pem
 	chmod 640 $(INSTALL_DIR)/client.pem $(INSTALL_DIR)/emulab.pem
 
-dist:
+dist:	trafgen pemfile
 	rm -rf $(DISTDIR)
 	mkdir $(DISTDIR)
 	cp -p $(DISTFILES) $(DISTDIR)
+	cp -p $(BSDFILES) $(DISTDIR)
 	for file in $(WAFILES); do cp ron/$$file $(DISTDIR); done
 	cp /usr/testbed/etc/emulab.pem $(DISTDIR)
-	cp /usr/testbed/etc/pcplab.pem $(DISTDIR)/client.pem
+	cp /usr/testbed/etc/$(PEMFILE) $(DISTDIR)/client.pem
+	cp /usr/local/sbin/vtund $(DISTDIR)
+	cp $(TRAFGEN) $(DISTDIR)
 	rm -f $(DISTDIR).tar
 	tar cf $(DISTDIR).tar -C $(DISTDIR) .
 
+trafgen:
+ifndef	TRAFGEN
+	@echo "You must define TRAFGEN (path to trafgen binary)."
+	@false
+endif
+
+pemfile:
+ifndef	PEMFILE
+	@echo "You must define PEMFILE (name of the pem file)."
+	@false
+endif
+
diff --git a/tmcd/ron/install.sh b/tmcd/ron/install.sh
index 9e511b4630..6857b298b3 100755
--- a/tmcd/ron/install.sh
+++ b/tmcd/ron/install.sh
@@ -31,6 +31,7 @@ else
 	rm -f /etc/rc5.d/S99emulab
 	ln -s ../init.d/emulab /etc/rc5.d/S99emulab
 endif
+cp /dev/null isrem
 chown emulabman . *
 chgrp bin . *
 chown root update vnodesetup
diff --git a/tmcd/ron/watchdog b/tmcd/ron/watchdog
index 65d08b8692..dc53c39f25 100755
--- a/tmcd/ron/watchdog
+++ b/tmcd/ron/watchdog
@@ -43,7 +43,7 @@ use lib "/usr/local/etc/emulab";
 use libsetup;
 
 # Locals
-my $timeout = (60 * 30);	# In seconds of course. 
+my $timeout = (60 * 60);	# In seconds of course. 
 my $logname = "/tmp/emulab-watchdog.debug";
 my $vndir   = "/var/emulab";
 my $pidfile = "/var/run/emulab-watchdog.pid";
@@ -132,6 +132,14 @@ close(PFILE);
 print "Informing Emulab Operations that we've rebooted ...\n";
 system("tmcc state REBOOTED");
 
+#
+# Do Apod.
+#
+if (-x "/usr/local/etc/emulab/setipod") {
+    print "Setting up APOD ... \n";
+    system("/usr/local/etc/emulab/setipod");
+}
+
 # At bootup, look for new accounts.
 print "Looking for new Emulab accounts ...\n";
 system("update -i");
@@ -221,6 +229,15 @@ sub bootvnodes() {
     my %curvnodelist;
     my @vnodes;
 
+    #
+    # Don't want tmcc errors to really kill us.
+    #
+    my $newpid = fork();
+    if ($newpid) {
+	waitpid($newpid, 0);
+	return ($? >> 8);
+    }
+    
     #
     # Get the current set of vnodes that are supposed to be running on
     # this node.
@@ -256,6 +273,7 @@ sub bootvnodes() {
 	system("vnodesetup $vnode");
 	sleep(5);
     }
+    exit(0);
 }
 
 exit(0);
diff --git a/tmcd/ssl.c b/tmcd/ssl.c
index dd7deed5e1..29abaee782 100644
--- a/tmcd/ssl.c
+++ b/tmcd/ssl.c
@@ -61,6 +61,7 @@ static char	*clientcertdirs[] = {
 	"/etc/testbed",
 	"/etc/rc.d/testbed",
 	"/usr/local/etc/testbed",
+	"/usr/local/etc/emulab",
 	ETCDIR,
 	0
 };
-- 
GitLab