Commit 7bdb3fdb authored by Mike Hibler's avatar Mike Hibler

Client side for the HP Moonshots.

parent 1d87bf24
......@@ -4534,6 +4534,7 @@ outfiles="Makeconf GNUmakefile setversion \
tmcc/ubuntu10/GNUmakefile \
tmcc/ubuntu11/GNUmakefile \
tmcc/ubuntu14/GNUmakefile \
tmcc/linux-ms/GNUmakefile \
tmcc/freebsd5/GNUmakefile tmcc/freebsd5/supfile \
tmcc/freebsd6/GNUmakefile tmcc/freebsd6/supfile \
tmcc/freebsd6/netif-emulab \
......
......@@ -271,6 +271,7 @@ outfiles="Makeconf GNUmakefile setversion \
tmcc/ubuntu10/GNUmakefile \
tmcc/ubuntu11/GNUmakefile \
tmcc/ubuntu14/GNUmakefile \
tmcc/linux-ms/GNUmakefile \
tmcc/freebsd5/GNUmakefile tmcc/freebsd5/supfile \
tmcc/freebsd6/GNUmakefile tmcc/freebsd6/supfile \
tmcc/freebsd6/netif-emulab \
......
......@@ -99,6 +99,9 @@ endif
ifeq ($(MDSUBDIR),ubuntu14)
MDSUBDIR = ubuntu14
endif
ifeq ($(MDSUBDIR),Moonshot)
MDSUBDIR = linux-ms
endif
ifeq ($(MDSUBDIR),ubuntu12)
MDSUBDIR = ubuntu11
endif
......
#
# Copyright (c) 2000-2014 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/>.
#
# }}}
#
#
# XXX ONLY RUN THIS INSTALL ON AN UBUNTO LINUX TESTBED NODE!
#
# Trivial. These things just need to be installed into the right place
# on a testbed node before cutting an image.
#
#
SRCDIR = @srcdir@
TESTBED_SRCDIR = @top_srcdir@
OBJDIR = @top_builddir@
SUBDIR = $(subst $(TESTBED_SRCDIR)/,,$(SRCDIR))
include $(OBJDIR)/Makeconf
SCRIPTS =
#
# Force dependencies on the scripts so that they will be rerun through
# configure if the .in file is changed.
#
all: supfile ifcfgs
include $(TESTBED_SRCDIR)/GNUmakerules
SYSETCDIR = $(DESTDIR)/etc
ETCDIR = $(DESTDIR)$(CLIENT_ETCDIR)
BINDIR = $(DESTDIR)$(CLIENT_BINDIR)
VARDIR = $(DESTDIR)$(CLIENT_VARDIR)
RCDIR = $(SYSETCDIR)
RRCDIR = /etc
INSTALL = /usr/bin/install -c
COMMON = $(SRCDIR)/../common
DEFRUNLVLDIR ?= $(SYSETCDIR)/rc3.d
install client-install: common-install etc-install \
script-install bin-install sysetc-fixup
@echo "Remember to install the PEM files if necessary"
simple-install: common-install script-install bin-install
dir-install:
$(INSTALL) -m 755 -o root -g root -d $(SYSETCDIR)/dhcp
$(INSTALL) -m 755 -o root -g root -d $(SYSETCDIR)/dhcp/dhclient-exit-hooks.d
$(INSTALL) -m 755 -o root -g root -d $(SYSETCDIR)/init
$(INSTALL) -m 755 -o root -g root -d $(SYSETCDIR)/network
$(INSTALL) -m 755 -o root -g root -d $(SYSETCDIR)/rsyslog.d
$(INSTALL) -m 755 -o root -g root -d $(SYSETCDIR)/sudoers.d
common-install: dir-install
(cd ../common; $(MAKE) DESTDIR=$(DESTDIR) local-install)
bin-install: dir-install
(cd ../linux; $(MAKE) DESTDIR=$(DESTDIR) RCDIR=$(RCDIR) bin-install)
$(INSTALL) -m 755 $(SRCDIR)/findcnet $(BINDIR)/findcnet
rm -f $(BINDIR)/rc/rc.linktest $(BINDIR)/rc/rc.topomap
etc-install: dir-install common-sysetc-install
$(INSTALL) -m 644 $(SRCDIR)/group $(ETCDIR)/group
$(INSTALL) -m 644 $(SRCDIR)/passwd $(ETCDIR)/passwd
$(INSTALL) -m 600 $(SRCDIR)/shadow $(ETCDIR)/shadow
$(INSTALL) -m 600 $(SRCDIR)/gshadow $(ETCDIR)/gshadow
$(INSTALL) -m 644 $(SRCDIR)/hosts $(ETCDIR)/hosts
common-sysetc-install: dir-install
(cd ../linux; $(MAKE) DESTDIR=$(DESTDIR) RCDIR=$(RCDIR) RRCDIR=$(RRCDIR) sysetc-install)
sysetc-fixup:
rm -rf $(SYSETCDIR)/modules.conf $(SYSETCDIR)/cron.pend $(SYSETCDIR)/sysconfig $(SYSETCDIR)/init.d/ntpd
rm -f $(SYSETCDIR)/dhclient-enter-hooks \
$(SYSETCDIR)/dhclient-exit-hooks
$(INSTALL) -m 755 $(SRCDIR)/dhclient-exit-hook \
$(SYSETCDIR)/dhcp/dhclient-exit-hooks.d/emulab
rm -f $(SYSETCDIR)/rc.local
$(INSTALL) -m 644 $(SRCDIR)/rc-sysinit.conf $(SYSETCDIR)/init/rc-sysinit.conf
$(INSTALL) -m 644 $(SRCDIR)/rsyslog-emulab.conf $(SYSETCDIR)/rsyslog.d/60-emulab.conf
$(INSTALL) -m 755 $(SRCDIR)/rc.local $(SYSETCDIR)/rc.local
$(INSTALL) -m 644 $(SRCDIR)/interfaces $(SYSETCDIR)/network/interfaces
$(INSTALL) -m 644 $(SRCDIR)/sudoers $(SYSETCDIR)/sudoers.d/99-emulab
$(INSTALL) -m 644 $(SRCDIR)/ntp $(SYSETCDIR)/init.d/ntp
script-install: dir-install $(SCRIPTS)
(cd ../linux; $(MAKE) DESTDIR=$(DESTDIR) RCDIR=$(RCDIR) script-install)
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
#
# The frisbee MFS is more like the BSD version, all shell all the time.
# We also build static binaries for now.
#
frisbee-mfs: destdircheck
sfs-install:
DEFAULT menu.c32
PROMPT 0
TIMEOUT 30
ONTIMEOUT %default%
MENU TITLE Emulab node boot
LABEL diskboot
MENU label Local disk
LOCALBOOT 0
LABEL mfsboot
MENU label Frisbee MFS
KERNEL mfs/uImage
INITRD mfs/uInitrd
#APPEND debug=y ip=dhcp break=init console=ttyS0,9600
APPEND ip=dhcp console=ttyS0,9600
LABEL pxewait
MENU label Wait for further instructions
KERNEL mfs/uImage
INITRD mfs/uInitrd
APPEND pxewait ip=dhcp console=ttyS0,9600
LABEL pxefail
MENU label Boot MFS to shell prompt
KERNEL mfs/uImage
INITRD mfs/uInitrd
APPEND pxefail ip=dhcp console=ttyS0,9600
LABEL nfsboot
MENU LABEL NFS-based MFS
KERNEL nfs/uImage
INITRD nfs/uInitrd
APPEND boot=nfs root=/dev/nfs nfsroot=128.110.156.34:/nfsroot/m400/%nodeid% rw ip=dhcp panic=1 console=ttyS0,9600
#!/bin/sh
#
# Copyright (c) 2000-2014 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/>.
#
# }}}
#
. /etc/emulab/paths.sh
echo "`date`: ${interface}: ${reason}" >>$LOGDIR/dhclient-exit.log 2>&1
if [ x$reason != xREBOOT -a x$reason != xBOUND -a x$reason != xRENEW -a x$reason != xREBIND ]
then
exit 0
fi
#
# Remember our server IP, real hostname, router IP, etc.
#
echo $new_domain_name_servers > $BOOTDIR/bossip
echo $new_host_name > $BOOTDIR/realname
echo $new_routers > $BOOTDIR/routerip
echo $new_ip_address > $BOOTDIR/myip
echo $new_subnet_mask > $BOOTDIR/mynetmask
echo $new_domain_name > $BOOTDIR/mydomain
if [ -n "$interface" ]; then
echo $interface > $BOOTDIR/controlif
fi
#
# See if the Testbed configuration software wants to change the hostname.
#
if [ -x $BINDIR/sethostname.dhclient ]; then
$BINDIR/sethostname.dhclient >>$LOGDIR/dhclient.log 2>&1
fi
echo "`date`: ${interface}: ${reason}: done" >>$LOGDIR/dhclient-exit.log 2>&1
exit 0
#!/bin/sh
#
# Find the Emulab control network interface.
#
# When called the first time (an invocation on any interface when
# /var/emulab/boot/controlif does not exist) we run DHCP and find the
# control network.
#
# On all invocations, we check the contents of that file against the
# interface we were called with and return "cnet" if we are the control
# net. Otherwise we just return the physical interface name.
#
static_widearea_config()
{
local iface=$1
if [ -e /etc/emulab/isrem -a -e /etc/emulab/waconfig ]; then
echo "Found Emulab widearea config info..."
. /etc/emulab/waconfig
else
return 1
fi
# XXX check WA_MAC?
if [ "$WA_BOOTMETHOD" != static ]; then
return 1
fi
cnetif=`/sbin/ifconfig -a | \
sed -n 's/^\([^ ]*\) *Link encap:Ethernet *HWaddr '$WA_MAC' *$/\1/ip'`
if [ -z "$cnetif" ]; then
echo "Could not find iface with MAC $WA_MAC; trying DHCP!"
return 1
elif [ -z "$WA_HOSTNAME" -o -z "$WA_DOMAIN" -o \
-z "$WA_IP_ADDR" -o -z "$WA_IP_NETMASK" -o \
-z "$WA_IP_GATEWAY" -o -z "$WA_IP_DNS1" ]; then
echo "Missing static IP config vars; trying DHCP!"
return 1
fi
# Make sure ifup passed us the correct interface. If not,
# exit successfully so that the DHCP client isn't run
if [ "$cnetif" != "$iface" ]; then
return 0
fi
# We're going ahead with the static config
echo "Statically configuring control net on $cnetif ..."
/sbin/ifconfig "$cnetif" inet "$WA_IP_ADDR" netmask "$WA_IP_NETMASK" up
/sbin/route add default gateway "$WA_IP_GATEWAY"
# setup resolv.conf
echo "search $WA_DOMAIN" > /etc/resolv.conf
echo "nameserver $WA_IP_DNS1" >> /etc/resolv.conf
if [ -n "$WA_IP_DNS2" ]; then
echo "nameserver $WA_IP_DNS2" >> /etc/resolv.conf
fi
# set hostname
hosts_str="$WA_HOSTNAME"
if echo "$WA_HOSTNAME" | grep -q \\.; then
hostname "$WA_HOSTNAME"
else
hostname "${WA_HOSTNAME}.${WA_DOMAIN}"
hosts_str="${WA_HOSTNAME}.${WA_DOMAIN} ${hosts_str}"
fi
# setup hosts file
echo "$WA_IP_ADDR ${hosts_str}" >> /etc/hosts
# setup a few necessary emulab files...
echo "$cnetif" > $BOOTDIR/controlif
if [ -e "/etc/emulab/bossnode" ]; then
bossnode=`cat /etc/emulab/bossnode`
i=0
while [ $i -lt 6 ]; do
bossip=`host -t A "$bossnode"`
[ $? -eq 0 ] && break
i=`expr $i + 1`
sleep 5
done
echo `echo "$bossip" | sed -n -e 's/.*has address\s*\(.*\)/\1/p'` \
> $BOOTDIR/bossip
fi
echo "$WA_HOSTNAME" > $BOOTDIR/realname
echo "$WA_IP_GATEWAY" > $BOOTDIR/routerip
echo "$WA_IP_ADDR" > $BOOTDIR/myip
echo "$WA_IP_NETMASK" > $BOOTDIR/mynetmask
return 0
}
export LANG=C
iface="$1"
cnetfile="/var/run/cnet"
cnetif=''
# We only need the lock if the file doesn't exist.
# XXX keep this lightweight as it can be called many times from
# ifquery in the udev path.
if [ -f $cnetfile ]; then
cnetif=`cat $cnetfile`
if [ "$cnetif" = $iface ]; then
echo cnet
else
echo $iface
fi
exit 0
fi
lockdir=/var/lock/findcnet
. /etc/emulab/paths.sh
while ! mkdir $lockdir 2> /dev/null; do
sleep 1
done
echo "`date`: $iface: starting" >>$LOGDIR/dhclient.log
#
# We use /var/run to store the current idea of the cnet interface
# because we want it to go away on reboot.
#
if [ -f $cnetfile ]; then
cnetif=`cat $cnetfile`
echo "`date`: $iface: $cnetfile already had $cnetif" >>$LOGDIR/dhclient.log
elif static_widearea_config $iface; then
#
# Make sure that static_widearea_config matched $iface to the target WA_MAC.
#
if [ "$cnetif" = "$iface" ]; then
echo $iface > $cnetfile
cnetif=`cat $cnetfile`
/sbin/initctl emit -n 'emulab-findcnet-done'
else
#
# If not, don't fail; there was widearea config info; but also don't
# succeed in the final check at the end of the script. This $iface is
# not the control net.
#
cnetif=''
fi
else
#
# Find a list of candidate interfaces
#
_iflist=`ifconfig -a | grep '^eth' | awk '{ print $1 }'`
echo "`date`: $iface: findcnet running dhclient on: $_iflist"
#
# If dhclient returns success, then it has configured the first interface
# and gone into background mode. At that point we don't care about it any
# more and just kill it. We also shutdown all the other interfaces (which
# dhclient will leave "up").
#
if [ -x /sbin/dhclient ] && /sbin/dhclient -q $_iflist ; then
killall dhclient
rm -f /var/run/dhclient.pid
echo "`date`: $iface: findcnet dhclient returned"
[ -f $BOOTDIR/controlif ] && cp $BOOTDIR/controlif $cnetfile
cnetif=`cat $cnetfile`
for _if in $_iflist; do
[ $_if = $cnetif ] && continue
echo "`date`: taking $_if down"
ifconfig $_if down
done
fi
# Emit this upstart event to allow boot to continue, even
# if we couldn't get a dhcp lease.
/sbin/initctl emit -n 'emulab-findcnet-done'
fi >>$LOGDIR/dhclient.log 2>&1
#
# In case ifup/ifdown try to feed us anything
#
while read foo bar; do
echo "`date`: $iface: findcnet got \"$foo $bar\" from caller"
done >>$LOGDIR/dhclient.log 2>&1
if [ -z "$cnetif" ]; then
echo "`date`: $iface: findcnet got empty $cnetfile" >>$LOGDIR/dhclient.log
fi
echo "`date`: $iface: cnet is $cnetif" >>$LOGDIR/dhclient.log
if [ "$cnetif" = $iface ]; then
echo cnet
else
echo $iface
fi
rm -rf $lockdir
exit 0
root:x:0:
daemon:x:1:
bin:x:2:
sys:x:3:
adm:x:4:syslog
tty:x:5:
disk:x:6:
lp:x:7:
mail:x:8:
news:x:9:
uucp:x:10:
man:x:12:
proxy:x:13:
kmem:x:15:
dialout:x:20:
fax:x:21:
voice:x:22:
cdrom:x:24:
floppy:x:25:
tape:x:26:
sudo:x:27:
audio:x:29:
dip:x:30:
www-data:x:33:
backup:x:34:
operator:x:37:
list:x:38:
irc:x:39:
src:x:40:
gnats:x:41:
shadow:x:42:
utmp:x:43:
video:x:44:
sasl:x:45:
plugdev:x:46:
staff:x:50:
games:x:60:
users:x:100:
nogroup:x:65534:
libuuid:x:101:
netdev:x:102:
crontab:x:103:
syslog:x:104:
fuse:x:105:
messagebus:x:106:
mlocate:x:107:
ssh:x:108:
admin:x:110:
utempter:x:111:
root:*::
daemon:*::
bin:*::
sys:*::
adm:*::syslog
tty:*::
disk:*::
lp:*::
mail:*::
news:*::
uucp:*::
man:*::
proxy:*::
kmem:*::
dialout:*::
fax:*::
voice:*::
cdrom:*::
floppy:*::
tape:*::
sudo:*::
audio:*::
dip:*::
www-data:*::
backup:*::
operator:*::
list:*::
irc:*::
src:*::
gnats:*::
shadow:*::
utmp:*::
video:*::
sasl:*::
plugdev:*::
staff:*::
games:*::
users:*::
nogroup:*::
libuuid:!::
netdev:!::
crontab:!::
syslog:!::
fuse:!::
messagebus:!::
mlocate:!::
ssh:!::
admin:!::
utempter:!::
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
#
# XXX abuse of mapping function follows.
# The findcnet script DHCPs on all interfaces the first time it is invoked
# and uses the results of that for every other invocation. The script
# returns "cnet" for the interface that is the control net, and the physical
# interface name for all others.
#
mapping eth*
script /usr/local/etc/emulab/findcnet
#
# The control network has been identified and configured indirectly
# via the mapping above. Here we just make sure that if shutdown, we
# remove the indicator file so that we will re-DHCP next time.
#
auto eth0 eth1 eth2 eth3 eth4 eth5 eth6 eth7 eth8 eth9
iface cnet inet manual
up echo "Emulab control net is $IFACE"
down rm -f /var/run/cnet
down ifconfig $IFACE down
......@@ -45,6 +45,7 @@ export BOOT=
export BOOTIF=
export UBIMTD=
export break=
export preinit=
export init=/usr/local/etc/emulab/rc.frisbee
export quiet=n
export readonly=y
......@@ -74,6 +75,12 @@ for x in $(cat /proc/cmdline); do
init=*)
init=${x#init=}
;;
pxewait)
preinit="/usr/local/etc/emulab/pxewait"
;;
pxefail)
preinit="/usr/local/etc/emulab/pxewait fail"
;;
root=*)
ROOT=${x#root=}
case $ROOT in
......@@ -331,8 +338,12 @@ unset readonly
unset resume
unset resume_offset
if [ -n "${preinit}" ]; then
${preinit} "$@" </dev/console >/dev/console 2>&1
fi
${init} "$@" </dev/console >/dev/console 2>&1
if [ $? -ne 0 ]; then
panic "${init} failed, dropping to shell."
panic "${init} failed, dropping to shell."
fi
exit 0
......@@ -21,6 +21,9 @@ mountroot()
wait_for_udev 10
configure_networking
# XXX ugh! give dhcpd a chance to report its BOOTING state
sleep 1
[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/mfs-bottom"
run_scripts /scripts/mfs-bottom
[ "$quiet" != "y" ] && log_end_msg
......
#!/bin/sh
#
# Copyright (c) 2014 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/>.
#
# }}}
#
MFS_DEBUG=${MFS_DEBUG:-'n'}
if [ "$MFS_DEBUG" = "y" ]; then
set -x
fi
if [ -r /etc/emulab/paths.sh ]; then
. /etc/emulab/paths.sh
else
BINDIR=/etc/testbed
BOOTDIR=/etc/testbed
ETCDIR=/etc/testbed
fi
if [ "$1" = "fail" ]; then
echo "Emulab pxeboot process failed, dropping to shell. Exit to retry."
PS1='(pxeboot) ' /bin/sh -i </dev/console >/dev/console 2>&1
fi
BOSSIP=`$BINDIR/tmcc bossinfo | awk '{ print $2 }'`
# XXX setup ipod some day
echo "`date`: entering pxewait"
bootwhat=`$BINDIR/bootinfoclient -s $BOSSIP`
echo "`date`: pxewait returns: $bootwhat"
case $bootwhat in
mfs:*frisbee)
echo "continuing with frisbee..."
exit 0
;;
*)
echo "rebooting..."
reboot
;;
esac
exit 0
......@@ -150,6 +150,16 @@ tweakgpt() {
fi
}
find_disks() {
local disks
for d in /sys/block/[sh]d*; do
disks="$disks ${d##*/}"
done
echo $disks
}
#
# Wipe out the superblocks on any partitions by zeroing the first 16 sectors.
# This implementation doesn't suffer the limitations of the FreeBSD one in
......@@ -509,9 +519,10 @@ case $STATUS in
disks=`find_disks`
for d in $disks; do
#[ $d = $DISK ] && continue
mount | grep "^/dev/$d" > /dev/null && continue
mount | grep "^/dev/$d" >/dev/null && continue
zapsuperblocks $d
echo "Invalidating MBR on $d"
sgdisk -Z /dev/$d >/dev/null 2>&1
dd if=/dev/zero of=/dev/$d bs=512 count=16
done
......@@ -613,11 +624,7 @@ fi
if [ $reboot -eq 1 ]; then
$BINDIR/tmcc state RELOADDONEV2
echo "`date`: Waiting for server to reboot us ..."
if [ $isrem -eq 1 ]; then
sleep 30
else
sleep 300
fi
sleep 30
echo "`date`: No response from server, rebooting myself ..."
reboot
sleep 100
......
#!/usr/bin/perl -w
#
# Copyright (c) 2007-2014 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.
#