From dfcb2a88adc1259d3e92022517392bee65228d3e Mon Sep 17 00:00:00 2001
From: Mike Hibler <hibler@cs.utah.edu>
Date: Thu, 13 Sep 2012 13:32:01 -0600
Subject: [PATCH] Changes to make MFS installs a little more automated.

Mostly added a taget for the newnode MFS.
---
 GNUmakefile.in                                | 12 +++++
 clientside/GNUmakefile.in                     |  2 +
 clientside/event/GNUmakefile.in               |  2 +
 clientside/lib/GNUmakefile.in                 |  4 +-
 clientside/os/GNUmakefile.in                  |  3 ++
 clientside/sensors/GNUmakefile.in             |  4 +-
 clientside/tmcc/GNUmakefile.in                |  5 ++
 clientside/tmcc/freebsd6/GNUmakefile.in       | 36 +++++++++++--
 clientside/tmcc/freebsd6/master.passwd        |  4 +-
 .../tmcc/freebsd6/mfs-newnode-testbed.sh      | 42 +++++++++++++++
 clientside/tmcc/freebsd7/GNUmakefile.in       | 14 ++++-
 clientside/tmcc/freebsd7/mfs-frisbee-rc.conf  | 49 +++++++++++++++++
 .../tmcc/freebsd7/mfs-newnode-testbed.sh      | 29 +++++++++++
 clientside/tmcc/freebsd7/mfs-rc.conf          | 52 +++++++++++++++++++
 clientside/tools/GNUmakefile.in               |  4 +-
 15 files changed, 253 insertions(+), 9 deletions(-)
 create mode 100755 clientside/tmcc/freebsd6/mfs-newnode-testbed.sh
 create mode 100644 clientside/tmcc/freebsd7/mfs-frisbee-rc.conf
 create mode 100644 clientside/tmcc/freebsd7/mfs-newnode-testbed.sh
 create mode 100644 clientside/tmcc/freebsd7/mfs-rc.conf

diff --git a/GNUmakefile.in b/GNUmakefile.in
index d8edf261a5..3d367cdec6 100644
--- a/GNUmakefile.in
+++ b/GNUmakefile.in
@@ -298,6 +298,18 @@ frisbee-mfs-nostatic-install: destdircheck frisbee-mfs-nostatic
 	@$(MAKE) -C os frisbee-mfs-install
 	@$(MAKE) -C clientside frisbee-mfs-install
 
+newnode-mfs: mfsoscheck
+	@$(MAKE) -C clientside newnode-mfs
+
+newnode-mfs-nostatic: mfsoscheck
+	@NOSTATIC=1 $(MAKE) -C clientside newnode-mfs
+
+newnode-mfs-install: destdircheck newnode-mfs client-mkdirs
+	@$(MAKE) -C clientside newnode-mfs-install
+
+newnode-mfs-nostatic-install: destdircheck newnode-mfs-nostatic client-mkdirs
+	@$(MAKE) -C clientside newnode-mfs-install
+
 cdboot: mfsoscheck client
 	@echo "CD/Dongle files built"
 
diff --git a/clientside/GNUmakefile.in b/clientside/GNUmakefile.in
index d351f5c4b5..447332a420 100644
--- a/clientside/GNUmakefile.in
+++ b/clientside/GNUmakefile.in
@@ -37,6 +37,8 @@ mfs:		mfs-subdirs
 mfs-install:	client-mkdirs mfs-install-subdirs
 frisbee-mfs:	frisbee-mfs-subdirs
 frisbee-mfs-install:	client-mkdirs frisbee-mfs-install-subdirs
+newnode-mfs:	newnode-mfs-subdirs
+newnode-mfs-install:	client-mkdirs newnode-mfs-install-subdirs
 
 TARBALLDESTDIR = /var/tmp/emulab-client
 client-tarball:
diff --git a/clientside/event/GNUmakefile.in b/clientside/event/GNUmakefile.in
index 1b3fa7f236..d1652e64b3 100644
--- a/clientside/event/GNUmakefile.in
+++ b/clientside/event/GNUmakefile.in
@@ -51,6 +51,8 @@ mfs:
 mfs-install:
 frisbee-mfs:
 frisbee-mfs-install:
+newnode-mfs:
+newnode-mfs-install:
 
 # How to recursively descend into subdirectories to make general
 # targets such as `all'.
diff --git a/clientside/lib/GNUmakefile.in b/clientside/lib/GNUmakefile.in
index cda12ad070..65376f9ab2 100644
--- a/clientside/lib/GNUmakefile.in
+++ b/clientside/lib/GNUmakefile.in
@@ -1,6 +1,6 @@
 #
 # EMULAB-COPYRIGHT
-# Copyright (c) 2000-2011 University of Utah and the Flux Group.
+# Copyright (c) 2000-2012 University of Utah and the Flux Group.
 # All rights reserved.
 #
 SRCDIR		= @srcdir@
@@ -29,6 +29,8 @@ mfs:
 mfs-install:
 frisbee-mfs:
 frisbee-mfs-install:
+newnode-mfs:
+newnode-mfs-install:
 
 # How to recursively descend into subdirectories to make general
 # targets such as `all'.
diff --git a/clientside/os/GNUmakefile.in b/clientside/os/GNUmakefile.in
index 8df81fce8e..0da73d237d 100644
--- a/clientside/os/GNUmakefile.in
+++ b/clientside/os/GNUmakefile.in
@@ -102,6 +102,9 @@ mfs-install:
 	CLIENT_BINDIR=/usr/local/bin $(MAKE) -e -C growdisk client-install
 	CLIENT_BINDIR=/usr/local/bin $(MAKE) -e -C frisbee.redux client-install
 
+newnode-mfs: mfs
+newnode-mfs-install: mfs-install
+
 cdboot-install: mfs-install
 
 subdir-distclean:
diff --git a/clientside/sensors/GNUmakefile.in b/clientside/sensors/GNUmakefile.in
index f7cc470373..7c2aa94712 100644
--- a/clientside/sensors/GNUmakefile.in
+++ b/clientside/sensors/GNUmakefile.in
@@ -1,6 +1,6 @@
 #
 # EMULAB-COPYRIGHT
-# Copyright (c) 2000-2011 University of Utah and the Flux Group.
+# Copyright (c) 2000-2012 University of Utah and the Flux Group.
 # All rights reserved.
 #
 SRCDIR		= @srcdir@
@@ -36,6 +36,8 @@ mfs:		client
 mfs-install:	client-install
 frisbee-mfs:
 frisbee-mfs-install:
+newnode-mfs:
+newnode-mfs-install:
 
 # How to recursively descend into subdirectories to make general
 # targets such as `all'.
diff --git a/clientside/tmcc/GNUmakefile.in b/clientside/tmcc/GNUmakefile.in
index fe953e7349..59916a0cd3 100644
--- a/clientside/tmcc/GNUmakefile.in
+++ b/clientside/tmcc/GNUmakefile.in
@@ -156,6 +156,11 @@ frisbee-mfs: client
 frisbee-mfs-install: frisbee-mfs
 	@$(MAKE) -C $(MDSUBDIR) frisbee-mfs-install
 
+newnode-mfs: client
+
+newnode-mfs-install: newnode-mfs
+	@$(MAKE) -C $(MDSUBDIR) newnode-mfs-install
+
 #
 # XXX argh!  assumes FreeBSD inner boss
 #
diff --git a/clientside/tmcc/freebsd6/GNUmakefile.in b/clientside/tmcc/freebsd6/GNUmakefile.in
index d3352b5d62..04e13f56fd 100644
--- a/clientside/tmcc/freebsd6/GNUmakefile.in
+++ b/clientside/tmcc/freebsd6/GNUmakefile.in
@@ -1,6 +1,6 @@
 #
 # EMULAB-COPYRIGHT
-# Copyright (c) 2000-2011 University of Utah and the Flux Group.
+# Copyright (c) 2000-2012 University of Utah and the Flux Group.
 # All rights reserved.
 #
 
@@ -37,6 +37,16 @@ RCDIR		= $(DESTDIR)/usr/local/etc/rc.d
 ISMFS		= $(ETCDIR)/ismfs
 INSTALL		= /usr/bin/install -c
 
+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:	bincheck basefbsd-install etc-install \
 			sup-install script-install bin-install
 
@@ -103,18 +113,38 @@ script-install:	dir-install
 #  * We still use rc.conf.d/dhclient right now
 #    (til we switch to 6.x rc.d files)
 #
-frisbee-mfs-install:
+frisbee-mfs-install: destdircheck
 	$(INSTALL) -m 755 -o root -g wheel -d $(DESTDIR)/usr/local/etc
 	(cd ../freebsd5; $(MAKE) all frisbee-mfs-install)
 	rm -f $(SYSETCDIR)/testbed/dhclient
 	rm -f $(DESTDIR)/usr/local/etc/dhclient*
 	ln -s /etc/dhclient* $(DESTDIR)/usr/local/etc/
+	@if [ -r $(SRCDIR)/master.passwd ]; then \
+	    $(INSTALL) -m 600 $(SRCDIR)/master.passwd $(SYSETCDIR); \
+	    pwd_mkdb -d $(SYSETCDIR) $(SYSETCDIR)/master.passwd; \
+	fi
+	@if [ -r $(SRCDIR)/group ]; then \
+	    $(INSTALL) -m 644 $(SRCDIR)/group $(SYSETCDIR); \
+	fi
 
-mfs-install:
+mfs-install: destdircheck
 	(cd ../freebsd5; $(MAKE) all mfs-install)
+	rm -rf $(JAILDIR)
 	rm -f $(SYSETCDIR)/testbed/dhclient
 	rm -f $(DESTDIR)/usr/local/etc/dhclient*
 	ln -s /etc/dhclient* $(DESTDIR)/usr/local/etc/
+	@if [ -r $(SRCDIR)/master.passwd ]; then \
+	    $(INSTALL) -m 600 $(SRCDIR)/master.passwd $(SYSETCDIR); \
+	    pwd_mkdb -d $(SYSETCDIR) $(SYSETCDIR)/master.passwd; \
+	fi
+	@if [ -r $(SRCDIR)/group ]; then \
+	    $(INSTALL) -m 644 $(SRCDIR)/group $(SYSETCDIR); \
+	fi
+
+newnode-mfs-install: mfs-install
+	(cd ../../../tools/teachswitch; $(MAKE) DESTDIR=$(DESTDIR) client-install)
+	$(INSTALL) -m 755 $(SRCDIR)/../../../install/newclient $(BINDIR)/newclient
+	$(INSTALL) -m 755 $(SRCDIR)/mfs-newnode-testbed.sh $(RCDIR)/testbed.sh
 
 #
 # CD/Flash install DOES have the FreeBSD 6 stuff
diff --git a/clientside/tmcc/freebsd6/master.passwd b/clientside/tmcc/freebsd6/master.passwd
index ee6735265a..2a7c297bd3 100644
--- a/clientside/tmcc/freebsd6/master.passwd
+++ b/clientside/tmcc/freebsd6/master.passwd
@@ -1,7 +1,7 @@
 # $FreeBSD: src/etc/master.passwd,v 1.40 2005/06/06 20:19:56 brooks Exp $
 #
-root:kEi.I6fTKyJDg:0:0::0:0:Charlie &:/root:/bin/csh
-toor:kEi.I6fTKyJDg:0:0::0:0:Chaplin &:/root:/bin/csh
+root:$1$0DKicYf8$PsfF3uhmTrtuaJKH/rxtQ/:0:0::0:0:Charlie &:/root:/bin/csh
+toor:*:0:0::0:0:Chaplin &:/root:/bin/csh
 daemon:*:1:1::0:0:Owner of many system processes:/root:/usr/sbin/nologin
 operator:*:2:5::0:0:System &:/:/usr/sbin/nologin
 bin:*:3:7::0:0:Binaries Commands and Source:/:/usr/sbin/nologin
diff --git a/clientside/tmcc/freebsd6/mfs-newnode-testbed.sh b/clientside/tmcc/freebsd6/mfs-newnode-testbed.sh
new file mode 100755
index 0000000000..15be66a97a
--- /dev/null
+++ b/clientside/tmcc/freebsd6/mfs-newnode-testbed.sh
@@ -0,0 +1,42 @@
+#!/bin/sh
+#
+# Copyright (c) 2000-2004, 2007 University of Utah and the Flux Group.
+# All rights reserved.
+# This file is part of the Emulab network testbed software.
+# 
+# Emulab is free software, also known as "open source;" 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.
+# 
+# Emulab 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, which can be found in the file AGPL-COPYING at the root of
+# the source tree.
+# 
+# You should have received a copy of the GNU Affero General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+# PROVIDE: testbed
+#
+
+. /etc/emulab/paths.sh
+
+#
+# Boottime initialization. 
+#
+case "$1" in
+start|faststart)
+	echo ""
+	$BINDIR/newclient
+	;;
+stop)
+	# Foreground mode.
+	;;
+*)
+	echo "Usage: `basename $0` {start|stop}" >&2
+	;;
+esac
+
+exit 0
diff --git a/clientside/tmcc/freebsd7/GNUmakefile.in b/clientside/tmcc/freebsd7/GNUmakefile.in
index ef4c545eed..e4999f64d7 100644
--- a/clientside/tmcc/freebsd7/GNUmakefile.in
+++ b/clientside/tmcc/freebsd7/GNUmakefile.in
@@ -118,9 +118,12 @@ script-install:	dir-install
 #
 frisbee-mfs-install: destdircheck
 	(cd ../freebsd5; $(MAKE) all frisbee-mfs-install)
+	rm -rf $(SYSETCDIR)/rc.conf.d
 	rm -f $(SYSETCDIR)/testbed/dhclient
 	rm -f $(DESTDIR)/usr/local/etc/dhclient*
 	ln -s /etc/dhclient* $(DESTDIR)/usr/local/etc/
+	rmdir $(DESTDIR)/usr/local/etc/emulab
+	$(INSTALL) -m 644 $(SRCDIR)/mfs-frisbee-rc.conf $(SYSETCDIR)/rc.conf
 	@if [ -r $(SRCDIR)/master.passwd ]; then \
 	    $(INSTALL) -m 600 $(SRCDIR)/master.passwd $(SYSETCDIR); \
 	    pwd_mkdb -d $(SYSETCDIR) $(SYSETCDIR)/master.passwd; \
@@ -129,11 +132,15 @@ frisbee-mfs-install: destdircheck
 	    $(INSTALL) -m 644 $(SRCDIR)/group $(SYSETCDIR); \
 	fi
 
-mfs-install:
+mfs-install: destdircheck
 	(cd ../freebsd5; $(MAKE) all mfs-install)
+	rm -rf $(JAILDIR)
+	rm -rf $(SYSETCDIR)/rc.conf.d
+	rm -rf $(DESTDIR)/root/.cvsup
 	rm -f $(SYSETCDIR)/testbed/dhclient
 	rm -f $(DESTDIR)/usr/local/etc/dhclient*
 	ln -s /etc/dhclient* $(DESTDIR)/usr/local/etc/
+	$(INSTALL) -m 644 $(SRCDIR)/mfs-rc.conf $(SYSETCDIR)/rc.conf
 	@if [ -r $(SRCDIR)/master.passwd ]; then \
 	    $(INSTALL) -m 600 $(SRCDIR)/master.passwd $(SYSETCDIR); \
 	    pwd_mkdb -d $(SYSETCDIR) $(SYSETCDIR)/master.passwd; \
@@ -141,3 +148,8 @@ mfs-install:
 	@if [ -r $(SRCDIR)/group ]; then \
 	    $(INSTALL) -m 644 $(SRCDIR)/group $(SYSETCDIR); \
 	fi
+
+newnode-mfs-install: mfs-install
+	(cd ../../../tools/teachswitch; $(MAKE) DESTDIR=$(DESTDIR) client-install)
+	$(INSTALL) -m 755 $(SRCDIR)/../../../install/newclient $(BINDIR)/newclient
+	$(INSTALL) -m 755 $(SRCDIR)/mfs-newnode-testbed.sh $(RCDIR)/testbed.sh
diff --git a/clientside/tmcc/freebsd7/mfs-frisbee-rc.conf b/clientside/tmcc/freebsd7/mfs-frisbee-rc.conf
new file mode 100644
index 0000000000..f243389ac5
--- /dev/null
+++ b/clientside/tmcc/freebsd7/mfs-frisbee-rc.conf
@@ -0,0 +1,49 @@
+# Common to both MFSes
+sendmail_enable="NONE"
+inetd_enable="NO"
+ldconfig_paths=""
+ldconfig_paths_aout=""
+blanktime="NO"
+update_motd="NO"
+background_fsck="NO"
+rc_info="YES"
+
+# turn on syslogd for debugging
+syslogd_enable="NO"
+
+autoboot="no"
+varmfs="NO"
+ip6addrctl_enable="NO"
+moused_nondefault_enable="NO"
+cleanvar_enable="NO"
+clear_tmp_X="NO"
+virecover_enable="NO"
+newsyslog_enable="NO"
+gptboot_enable="NO"
+
+# Specific to frisbee MFS
+cron_enable="NO"
+devd_enable="NO"
+
+#
+# FreeBSD has no way to say "DHCP on all available interfaces" without
+# spelling out here what all those interfaces are.  So here we just say
+# to (statically) configure the loopback device.  The real network
+# interfaces are identified in rc.conf.d/dhclient for use by the
+# rc.d/dhclient script.
+#
+network_interfaces="lo0"
+
+#
+# Argh! dhclient in FreeBSD 5 has a new auto-background "feature",
+# it dives into the background after 10 seconds regardless of whether
+# it has received a response.  This is fubar for us.  Unfortunately,
+# we cannot just crank this number through the roof because it is based
+# on a polling interval which actually has a rational purpose.  The timeout
+# is actually (2 * polling_interval) where polling_interval is how often
+# dhclient rechecks an interface without link.  We need to keep this value
+# reasonable in the event that we boot up and don't immediately have link
+# on the control net.  So lets try 15 seconds (30 second auto-background
+# timeout) and see how things go.
+#
+dhclient_flags="-i 15"
diff --git a/clientside/tmcc/freebsd7/mfs-newnode-testbed.sh b/clientside/tmcc/freebsd7/mfs-newnode-testbed.sh
new file mode 100644
index 0000000000..be34f385c1
--- /dev/null
+++ b/clientside/tmcc/freebsd7/mfs-newnode-testbed.sh
@@ -0,0 +1,29 @@
+#!/bin/sh
+#
+# EMULAB-COPYRIGHT
+# Copyright (c) 2000-2012 University of Utah and the Flux Group.
+# All rights reserved.
+#
+# PROVIDE: testbed
+# REQUIRE: sshd
+#
+
+. /etc/emulab/paths.sh
+
+#
+# Boottime initialization. 
+#
+case "$1" in
+start|faststart)
+	echo ""
+	$BINDIR/newclient
+	;;
+stop)
+	# Foreground mode.
+	;;
+*)
+	echo "Usage: `basename $0` {start|stop}" >&2
+	;;
+esac
+
+exit 0
diff --git a/clientside/tmcc/freebsd7/mfs-rc.conf b/clientside/tmcc/freebsd7/mfs-rc.conf
new file mode 100644
index 0000000000..8e6f7c2734
--- /dev/null
+++ b/clientside/tmcc/freebsd7/mfs-rc.conf
@@ -0,0 +1,52 @@
+# Common to both MFSes
+sendmail_enable="NONE"
+inetd_enable="NO"
+ldconfig_paths=""
+ldconfig_paths_aout=""
+blanktime="NO"
+update_motd="NO"
+background_fsck="NO"
+rc_info="YES"
+
+# turn on syslogd for debugging
+syslogd_enable="NO"
+
+autoboot="no"
+varmfs="NO"
+ip6addrctl_enable="NO"
+moused_nondefault_enable="NO"
+cleanvar_enable="NO"
+clear_tmp_X="NO"
+virecover_enable="NO"
+newsyslog_enable="NO"
+gptboot_enable="NO"
+
+# Specific to admin MFS
+sshd_enable="YES"
+cron_enable="YES"
+ntpdate_enable="YES"
+ntpdate_flags="boss"
+nfs_client_enable="YES"
+
+#
+# FreeBSD has no way to say "DHCP on all available interfaces" without
+# spelling out here what all those interfaces are.  So here we just say
+# to (statically) configure the loopback device.  The real network
+# interfaces are identified in rc.conf.d/dhclient for use by the
+# rc.d/dhclient script.
+#
+network_interfaces="lo0"
+
+#
+# Argh! dhclient in FreeBSD 5 has a new auto-background "feature",
+# it dives into the background after 10 seconds regardless of whether
+# it has received a response.  This is fubar for us.  Unfortunately,
+# we cannot just crank this number through the roof because it is based
+# on a polling interval which actually has a rational purpose.  The timeout
+# is actually (2 * polling_interval) where polling_interval is how often
+# dhclient rechecks an interface without link.  We need to keep this value
+# reasonable in the event that we boot up and don't immediately have link
+# on the control net.  So lets try 15 seconds (30 second auto-background
+# timeout) and see how things go.
+#
+dhclient_flags="-i 15"
diff --git a/clientside/tools/GNUmakefile.in b/clientside/tools/GNUmakefile.in
index bb6b2a015a..c24d667530 100644
--- a/clientside/tools/GNUmakefile.in
+++ b/clientside/tools/GNUmakefile.in
@@ -1,6 +1,6 @@
 #
 # EMULAB-COPYRIGHT
-# Copyright (c) 2000-2011 University of Utah and the Flux Group.
+# Copyright (c) 2000-2012 University of Utah and the Flux Group.
 # All rights reserved.
 #
 SRCDIR		= @srcdir@
@@ -35,6 +35,8 @@ mfs:
 mfs-install:
 frisbee-mfs:
 frisbee-mfs-install:
+newnode-mfs:
+newnode-mfs-install:
 
 # How to recursively descend into subdirectories to make general
 # targets such as `all'.
-- 
GitLab