Commit 779f2dfd authored by Kirk Webb's avatar Kirk Webb Committed by Kirk Webb

Initial changes required to compile / install the Emulab client-side on

Windows 7 under Cygwin 1.7.  Mostly tweaks to makefiles to recognize Win7 in
addition to Windows XP.

New directory for Win7-specific files: clientside/tmcc/cygwinseven
parent 69bfe81b
......@@ -242,7 +242,7 @@ outfiles="Makeconf GNUmakefile \
tmcc/freebsd10/GNUmakefile tmcc/freebsd10/netif-emulab \
tmcc/cygwinxp/GNUmakefile tmcc/dp/GNUmakefile \
tmcc/openbsd/GNUmakefile tmcc/ron/GNUmakefile \
tmcc/plab/GNUmakefile \
tmcc/plab/GNUmakefile tmcc/cygwinseven/GNUmakefile \
os/GNUmakefile os/syncd/GNUmakefile \
os/dijkstra/GNUmakefile os/genhostsfile/GNUmakefile \
os/frisbee.redux/GNUmakefile \
......
......@@ -62,8 +62,8 @@ YCFLAGS += -I. -I$(TGSRCDIR) -DUSEEVENTS -DFREEBSD
LIBS += -ll -lcompat
endif
ifeq ($(SYSTEM),CYGWIN_NT-5.1)
# Cygwin on Windows XP (a.k.a. NT 5.1) - resembles the Linux case.
ifeq ($(findstring CYGWIN_NT,$(SYSTEM)),CYGWIN_NT)
# Cygwin on Windows XP/7 - resembles the Linux case.
CFLAGS += -DCYGWIN -DLINUX
YCFLAGS += -I. -I$(TGSRCDIR) -DUSEEVENTS -DCYGWIN -DLINUX
......
......@@ -52,7 +52,7 @@
#define TPM_CERTFILE "tpm.cert"
#define TPM_KEYFILE "tpm.key"
#ifdef linux
#if defined(linux) || defined(__CYGWIN__)
#define EAUTH EPERM
#endif
......
......@@ -17,6 +17,13 @@ SUBDIRS = syncd dijkstra genhostsfile imagezip frisbee.redux
ifeq ($(SYSTEM),FreeBSD)
SUBDIRS += growdisk
endif
# XXX: Remove dijkstra from win7 for now as g++4 doesn't like Boost
# XXX: also remove imagezip and frisbee - oy vey...
ifeq ($(findstring CYGWIN_NT,$(SYSTEM)),CYGWIN_NT)
SUBDIRS := $(filter-out dijkstra imagezip frisbee.redux,$(SUBDIRS))
endif
all: all-subdirs
include $(TESTBED_SRCDIR)/GNUmakerules
......@@ -42,13 +49,16 @@ client-install: client
$(INSTALL) -m 644 $(SRCDIR)/install-tarfile.1 $(DESTDIR)$(CLIENT_MANDIR)/man1/install-tarfile.1
$(INSTALL_PROGRAM) $(SRCDIR)/install-rpm $(LBINDIR)/install-rpm
$(MAKE) -C syncd client-install
ifneq ($(findstring CYGWIN_NT,$(SYSTEM)),CYGWIN_NT) # Filter out again...
$(MAKE) -C dijkstra client-install
$(MAKE) -C genhostsfile client-install
$(MAKE) -C imagezip client-install
$(MAKE) -C frisbee.redux client-install
endif
$(MAKE) -C genhostsfile client-install
ifeq ($(SYSTEM),FreeBSD)
$(MAKE) -C growdisk client-install
endif
$(MAKE) -C frisbee.redux client-install
subboss: client
......
......@@ -27,8 +27,8 @@ SDLIBS+= -ltb -lmysqlclient
LIBS= $(MLIBS)
CP= cp -pf
ifeq ($(SYSTEM),CYGWIN_NT-5.1)
# Cygwin on Windows XP (a.k.a. NT 5.1).
ifeq ($(findstring CYGWIN_NT,$(SYSTEM)),CYGWIN_NT)
# Cygwin on Windows XP/7
MLIBS += -liphlpapi
WINCLIENT = idlemon
......@@ -70,7 +70,7 @@ boss-install: $(addprefix $(INSTALL_SBINDIR)/, $(SBIN_SCRIPTS) sdcollectd) webfe
client-install: client
$(INSTALL_PROGRAM) slothd$(EXE) $(DESTDIR)$(CLIENT_BINDIR)/slothd$(EXE)
ifeq ($(SYSTEM),CYGWIN_NT-5.1)
ifeq ($(findstring CYGWIN_NT,$(SYSTEM)),CYGWIN_NT)
# If there are any RDP logins active, idlemon will be busy. Try moving it.
-mv $(IDLEMONEXE) $(IDLEMONEXE).prev
$(INSTALL_PROGRAM) idlemon$(EXE) $(IDLEMONEXE)
......
......@@ -104,9 +104,14 @@ endif
ifeq ($(SYSTEM),Cygwin)
# Cygwin on Windows XP (a.k.a. NT 5.1) - resembles the Linux case.
ifeq ($(MDSUBDIR),CYGWIN_NT-5.1)
ifeq ($(MDREL),5.1)
MDSUBDIR = cygwinxp
TMSLIBS += -lminires
else
# Cygwin on Windows 7 (a.k.a. NT 6.1) - resembles the Linux case.
ifeq ($(MDREL),6.1)
MDSUBDIR = cygwinseven
endif
endif
endif
......
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2011 University of Utah and the Flux Group.
# All rights reserved.
#
#
# XXX ONLY RUN THIS INSTALL ON A CYGWIN / WINDOWS XP NODE!
# Similar to linux9, cygwinxp is an overlay on linux, which is an overlay
# on common.
#
# 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: $(SCRIPTS)
include $(TESTBED_SRCDIR)/GNUmakerules
DESTDIR =
SYSETCDIR = $(DESTDIR)/etc
ETCDIR = $(DESTDIR)$(CLIENT_ETCDIR)
BINDIR = $(DESTDIR)$(CLIENT_BINDIR)
VARDIR = $(DESTDIR)$(CLIENT_VARDIR)
RCDIR = $(SYSETCDIR)/rc.d
INSTALL = /usr/bin/install -c
COMMON = $(SRCDIR)/../common
install client-install: baselinux-install common-install etc-install \
sup-install script-install ##bin-install
@echo "Remember to install the PEM files if necessary"
simple-install: common-install script-install ##bin-install
dir-install:
baselinux-install: dir-install
(cd ../linux; $(MAKE) DIRGROUP=wheel client-install)
rm -f $(BINDIR)/rc/rc.healthd
rm -f $(BINDIR)/rc/rc.slothd
common-install: dir-install
(cd ../common; $(MAKE) local-install)
sup-install: dir-install
SYSTEM32 = /cygdrive/c/Windows/System32
WBEM = $(SYSTEM32)/Wbem
bin-install: dir-install
# These are found in the /share/windows directory.
$(INSTALL) -m 755 $(SRCDIR)/WSName.exe $(BINDIR)/WSName.exe
$(INSTALL) -m 755 $(SRCDIR)/addusers.exe $(BINDIR)/addusers.exe
$(INSTALL) -m 755 $(SRCDIR)/usrtogrp.exe $(BINDIR)/usrtogrp.exe
# Setx is run under CMD early in the user login to make HOME for Emacs.
$(INSTALL) -m 755 $(SRCDIR)/setx.exe $(SYSTEM32)/setx.exe
# Devcon is used by rc.cygwin and rc.ifc to disable/enable NIC's.
$(INSTALL) -m 755 $(SRCDIR)/devcon.exe $(BINDIR)/devcon.exe
# These are used by tmcd/findif.
$(INSTALL) -m 755 $(SYSTEM32)/getmac.exe $(BINDIR)/getmac.exe
$(INSTALL) -m 755 $(WBEM)/framedyn.dll $(BINDIR)/framedyn.dll
etc-install: dir-install sysetc-install
sysetc-install: dir-install ###ifcfgs
# Watchdog assumes the ssh keys are in /etc/ssh.
mkdir -p /etc/ssh
ln -f -s /etc/ssh* /etc/ssh
# Boot log files have to be writable by root under rc.cygwin .
$(INSTALL) -c -m 775 -o root -d /var/log
$(INSTALL) -c -m 775 -o root -d /var/db
script-install: dir-install $(SCRIPTS)
$(INSTALL) -m 755 $(SRCDIR)/liblocsetup.pm $(BINDIR)/liblocsetup.pm
$(INSTALL) -m 755 $(SRCDIR)/prepare $(BINDIR)/prepare
$(INSTALL) -m 755 $(SRCDIR)/tbshutdown $(BINDIR)/tbshutdown
$(INSTALL) -c -m 755 -o root -d /sbin
#$(INSTALL) -m 755 $(SRCDIR)/reboot /sbin/reboot
# Put the tcsh desktop startup script in the CygWin root directory.
#$(INSTALL) -m 755 $(SRCDIR)/cygwin-tcsh.bat /
ln -f -s /bin/shutdown /sbin/shutdown
ln -f -s /bin/reboot /sbin/reboot
# Everybody is in the Administrators group already, so sudo is irrelevant.
$(INSTALL) -m 755 $(SRCDIR)/sudo.dummy /bin/sudo
$(INSTALL) -m 755 $(SRCDIR)/rc.firstboot $(BINDIR)/rc/rc.firstboot
$(INSTALL) -m 755 $(SRCDIR)/rc.cygwinxp $(BINDIR)/rc/rc.cygwin
#$(INSTALL) -m 755 $(SRCDIR)/clean_logonui $(BINDIR)/clean_logonui
$(INSTALL) -m 755 $(SRCDIR)/rc.reboot $(BINDIR)/rc/rc.reboot
$(INSTALL) -m 755 $(SRCDIR)/rc.lmhosts $(BINDIR)/rc/rc.lmhosts
$(INSTALL) -m 755 $(SRCDIR)/netbt $(BINDIR)/netbt
sfs-install:
# create ifcfg-eth? files
ifcfgs: $(SRCDIR)/mkifcfgs $(SRCDIR)/ifcfg.template
$(SRCDIR)/mkifcfgs $(SRCDIR)/ifcfg.template
This diff is collapsed.
<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
<settings pass="oobeSystem">
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<OOBE>
<HideEULAPage>true</HideEULAPage>
<HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE>
<NetworkLocation>Work</NetworkLocation>
<ProtectYourPC>3</ProtectYourPC>
</OOBE>
<ShowWindowsLive>false</ShowWindowsLive>
<TimeZone>Mountain Standard Time</TimeZone>
<RegisteredOrganization>University of Utah</RegisteredOrganization>
<RegisteredOwner>Flux Research Group</RegisteredOwner>
<UserAccounts>
<LocalAccounts>
<LocalAccount wcm:action="add">
<Password>
<Value>TgBvAG4AZQAxADIAMwBQAGEAcwBzAHcAbwByAGQA</Value>
<PlainText>false</PlainText>
</Password>
<Description>Emulab Root Account</Description>
<DisplayName>Root</DisplayName>
<Group>Administrators;Users</Group>
<Name>root</Name>
</LocalAccount>
</LocalAccounts>
</UserAccounts>
</component>
<component name="Microsoft-Windows-International-Core" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<InputLocale>en-US</InputLocale>
<SystemLocale>en-US</SystemLocale>
<UILanguage>en-US</UILanguage>
<UILanguageFallback>en-US</UILanguageFallback>
<UserLocale>en-US</UserLocale>
</component>
</settings>
<settings pass="specialize">
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ProductKey>FCWRH-CQMYD-GC3G2-MFKKC-M96W7</ProductKey>
<RegisteredOrganization>Emulab</RegisteredOrganization>
<RegisteredOwner></RegisteredOwner>
<ShowWindowsLive>false</ShowWindowsLive>
<TimeZone>Mountain Standard Time</TimeZone>
<ComputerName>*</ComputerName>
<CopyProfile>true</CopyProfile>
</component>
<component name="Microsoft-Windows-UnattendedJoin" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Identification>
<JoinWorkgroup>EMULAB</JoinWorkgroup>
</Identification>
</component>
<component name="Microsoft-Windows-Security-SPP-UX" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SkipAutoActivation>true</SkipAutoActivation>
</component>
<component name="Microsoft-Windows-IE-InternetExplorer" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Home_Page>about:blank</Home_Page>
<DisableFirstRunWizard>true</DisableFirstRunWizard>
</component>
</settings>
<settings pass="generalize">
<component name="Microsoft-Windows-Security-SPP" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SkipRearm>1</SkipRearm>
</component>
</settings>
<cpi:offlineImage cpi:source="wim:d:/sources/install.wim#Windows 7 PROFESSIONAL" xmlns:cpi="urn:schemas-microsoft-com:cpi" />
</unattend>
#! /bin/bash
#
# EMULAB-COPYRIGHT
# Copyright (c) 2006 University of Utah and the Flux Group.
# All rights reserved.
#
function usage () {
echo "Usage: netbt [-r] off|on"
exit
}
# The NetBT (Netbios over TCP) protocol is used to announce shared directories
# (folders) from one Windows machine to others. (See the Name and Session
# services in http://en.wikipedia.org/wiki/Netbios)
#
# The SMB (Server Message Block) protocol is used to actually serve
# files. (See http://en.wikipedia.org/wiki/Server_Message_Block)
#
# In Emulab, we normally disable NetBT on experiment nodes, because it
# chatters and messes up slothd network idle detection, and is not needed for
# the usual SMB mounts of /users, /proj, and /share dirs, which are served
# from a Samba service on "fs".
#
# However, NetBT *does* have to be enabled on the experiment nodes if you want
# to make Windows file shares between them. The netbt script sets the registry
# keys on the Windows interface objects. Run it on the server nodes (the ones
# containing directories which you want to share) and reboot them afterwards
# to activate. There is an optional -r argument to reboot the node.
#
# If you use netbt to turn on NetBT, it persists across reboots.
#
# No reboot is necessary if you use Network Connections in the Control Panel
# to turn on NetBT. It takes effect immediately, but is turned off at reboot.
# Right-click Local Area Connection (or the name of another connection, if
# appropriate), click Properties, click Internet Protocol (TCP/IP), and then
# click the Properties button. On the Internet Protocol (TCP/IP) Properties
# page, click the Advanced button, and click the WINS tab. Select Enable or
# Disable NetBIOS over TCP/IP.
#
# "ipconfig /all" reports "NetBIOS over Tcpip . . . : Disabled" on interfaces
# where NetBT is disabled, and says nothing where NetBT is enabled.
#
# To start sharing a directory, on the node, use the "net share" command, or
# turn on network sharing on the Sharing tab of the Properties of a directory
# (folder.) On XP-SP2 or above, when you first do this, the "Network sharing
# and security" subdialog says:
# As a security measure, Windows has disabled remote
# access to this computer. However, you can enable
# remote access and safely share files by running
# the _Network_Setup_Wizard_.
#
# _If_you_understand_the_security_risks_but_want_to_share_
# _files_without_running_the_wizard,_click_here._"
# Skip the wizard and click the latter link. Then click "Just enable file
# sharing", and "OK". Then you finally get the click-box to "Share this
# folder on the network".
#
# The machine names for UNC paths sharing are the same as in shell prompts:
# pcXXX, where XXX is the machine number. These will show up in My Network
# Places / Entire Network / Microsoft Windows Network / Emulab .
#
# IP addresses can also be used, giving you a way to share across experimental
# network links. LMHOSTS file lookup will be implemented soon, to provide the
# usual node aliases within an experiment.
ccs=/HKLM/SYSTEM/CurrentControlSet svcs=$ccs/Services cntl=$ccs/Control
nbtp=$svcs/NetBT/Parameters nbtif=$nbtp/Interfaces
if (( "$#" == 0 )); then
usage
fi
if (( "$#" >= 1 )); then
if [ "$1" == "-r" ]; then
reboot=1
shift
fi
fi
if (( "$#" > 1 )); then
usage
fi
# Set or unset a regkey to make it persistent.
if [ "$1" == "on" ]; then
able=1
regtool set -i $nbtp/EmulabOn 1
elif [ "$1" == "off" ]; then
able=2
regtool unset -q $nbtp/EmulabOn
else
usage
fi
for ifc in `regtool list $nbtif`; do
# Set the NetBT interface NetbiosOptions to Enable (1) or Disable (2.)
regtool set -i $nbtif/$ifc/NetbiosOptions $able
done
if [ $reboot ]; then /usr/local/etc/emulab/rc/rc.reboot; fi
This diff is collapsed.
#!/bin/bash
#
# EMULAB-COPYRIGHT
# Copyright (c) 2004, 2005 University of Utah and the Flux Group.
# All rights reserved.
#
# rc.cygwinxp - CygWin-specific startup. Run by rc.bootsetup on CygWin.
PATH=/usr/local/etc/emulab:/bin:$SYSTEMROOT/system32:$PATH
export PATH
# Enable logging.
logfile=/var/log/EmulabStartup.log
chmod -f g+w $logfile
function logit () {
msg="`date`: $1"
echo "$msg" >> $logfile
echo "$msg"
}
logit "----------------------------------------------------------------"
logit "Entering rc.cygwin"
# Stop the sshd service during setup, because it sometimes loops, eating 100% of the
# CPU. It will be restarted after rc.bootsetup by EmulabStartup. Make sure below.
cygrunsrv -E sshd
# Make sure there isn't a dangling slothd lock file.
rm -f /var/run/slothd.pid
# Get the desired node name from tmcc, and make sure we have a connection.
# There is a swap-in race condition where tmcc nodeid at first returns nothing.
nodeid=
while [ -z $nodeid ]; do
nodeid=`tmcc nodeid`
if [ -z $nodeid ]; then
logit "Null nodeid returned from tmcc. Trying again."
sleep 5
elif [ "$nodeid" == UNKNOWN ]; then
logit "UNKNOWN nodeid returned from tmcc. Trying again."
nodeid=
sleep 5
fi
done
logit "nodeid = $nodeid"
# Sometimes the network stack gets out of sync: 'ipconfig /all' reports different
# status on the interfaces than 'netsh interface show interface'. This might help.
netsh interface reset all
# Windows DHCP doesn't make an /etc/resolv.conf, which tmcc needs for bossinfo.
# Make one from ipconfig output.
ipconfig /all | tr -d '\r' | awk \
'/^ *Connection-specific DNS Suffix.*: ./{print "search", $NF} \
/^ *DNS Servers/{print "nameserver", $NF}' > /etc/resolv.conf
# Set the primary domain, so the Windows resolver won't be confused when there are
# multiple interfaces.
domain=`tmcc bossinfo | sed -n 's/[^.]*\.\([^ ]*\) .*/\1/p'`
svcs=/HKLM/SYSTEM/CurrentControlSet/Services
tp=$svcs/Tcpip/Parameters
regtool set -s $tp/Domain $domain
logit "domain = $domain"
bd=/var/emulab/boot
# Cache getmac output while all interfaces are still enabled, otherwise we get lines
# with nothing but 'Disabled Disconnected'. Used by rc.ifconfig .
#
# getmac /v /fo csv gives us comma-separated lines containing these double-quoted items:
# Local Area Connection #, device type (but without the # suffix that makes it a Device
# Description), dash-separated MAC address, and the \Device\Tcpip_{GUID} Transport Name.
#
# Squash out the ^M's and blank line in the getmac output.
gmc=$bd/getmac-cache
getmac /nh /v /fo csv | tr -d '\r' | sed '/^$/d' > $gmc
nifc=`wc -l < $gmc`
logit "number of interfaces = $nifc"
# 'devcon find' returns device_instance_ID: Device Description pairs.
# Squash out the ^M's and the space following the colon, and the summary line.
dfc=$bd/devcon-find-cache
devcon find =net 'PCI*' | tr -d '\r' | \
sed -e 's/ *: */:/' -e '/matching device/d' | sort -t : +1 > $dfc
# In spite of enabling all interfaces with devcon in rc.firstboot, sometimes an
# experimental net interface is omitted from ipconfig, but visible in devcon and
# getmac. Specifically disabling it and re-enabling it fixes the problem. (Yuck.)
icc=$bd/ipconfig-cache icd=$bd/ipconfig-descrs
ipconfig /all | tr -d '\r' > $icc
sed -n '/Description/s/.*: //p' $icc | sort > $icd
nipc=`wc -l < $icd`
logit "number of interfaces in ipconfig = $nipc"
if [[ $nipc < $nifc ]]; then
# Ignore the ones that are in ipconfig already.
logit "Fixing interface(s):"
logit "`join -v 2 -t : -2 2 -o 2.2 $icd $dfc`"
# 'devcon' takes PCI_device_instance_ID args with leading @ signs.
ids=`join -v 2 -t : -2 2 -o 2.1 $icd $dfc | sed 's/^/@/'`
devcon disable $ids
sleep 5
devcon enable $ids
sleep 5
# Should be fixed.
ipconfig /all | tr -d '\r' > $icc
sed -n '/Description/s/.*: //p' $icc | sort > $icd
nipc=`wc -l < $icd`
logit "number of interfaces in ipconfig now = $nipc"
if [[ $nipc < $nifc ]]; then
logit '*** There are still one or more interfaces missing! ***'
fi
fi
# Remember the control net interface MAC address and Local Area Connection name for
# slothd. It's the one whose IP address is returned by looking up the nodeid (pc%d).
cif=$bd/controlif cmac=$bd/controlmac
ipaddr=`nslookup $nodeid.$domain | awk '/Address:/{print $2}' | tail -1`
logit "ipaddr = $ipaddr"
if [ -z "$ipaddr" ]; then
logit "$host- No ip address found for '$nodeid.$domain'."
else
# Remember the non-control net interface device descriptions, etc. as well.
xid=$bd/xif_descrs xim=$bd/xif_macs xin=$bd/xif_names xii=$bd/xif_ids
awk '/^Ethernet adapter/{ ifc = gensub("Ethernet adapter (.*):", "\\1", 1); next }\
/Description/{ gsub("^[^:]*: ", ""); descr = $0; next }\
/Physical Address/{ gsub("-", ":"); mac = tolower($NF); next }\
/IP Address/ && $NF=="'$ipaddr'"{ ctl=1; print mac, ifc > "'$cif'"; \
gsub(":", "", mac); print mac > "'$cmac'"; next }\
# Blank lines separate the device sections in ifconfig output.\
/^$/ && descr != "" { if (!ctl) do_xif(); descr = ctl = ""; next }\
END{ if (!ctl) do_xif() }\
function do_xif() {\
print mac > "'$xim'"; print ifc > "'$xin'"; print descr > "'$xid'" }' $icc
nxifc=`wc -l < $xim`
logit "number of experimental net interfaces = $nxifc"
if (( $nxifc >= $nifc )); then
logit "$host - Can't find control net interface. Bad ip address '$ipaddr'?"
else
# Map from device names to PCI instance id's for liblocsetup.pm:os_ifconfig_line().
# Make the device id order the same as ipconfig for pasting files together.
awk -F : < $dfc \
'BEGIN{ while ((getline descr < "'$xid'") > 0) descrs[++n] = descr }\
{ ids[$2] = $1 }\
END { for (i=1; i<=n; i++) print "@"ids[descrs[i]] > "'$xii'" }'
# devcon takes PCI_device_instance_ID args with leading @ signs.
ximap=$bd/xif_map
paste -d: $xin $xii > $ximap
# Disable NICs that won't be used. Addresses, etc for experimental net
# interfaces will be configured by rc.ifc later (generated by rc.ifconfig .)
mim=$bd/mac-id-map mnm=$bd/mac-name-map umac=$bd/used_macs
# mac-id-map is MAC:PCI_device_instance_ID.
tr -d : < $xim | paste -d: - $xii | sort > $mim
# mac-name-map is MAC:Local Area Connection #
tr -d : < $xim | paste -d: - $xin | sort > $mnm
# Make a list of NIC macs that will be used.
tmcc ifconfig | sed -e 's/.*MAC=//' -e 's/ .*//' | cat $cmac - | sort > $umac
# The others.
unused=`join -v 2 -t : -o 2.1 $umac $mim`
if [ ! -z "$unused" ]; then
logit "Disabling unused interface(s):"
logit "`join -v 2 -t : -o 2.1 $umac $mnm`"
devcon disable `join -v 2 -t : -o 2.2 $umac $mim`
fi
fi
fi
# Make double-sure that the sshd service is stopped during setup, because it
# sometimes loops, eating 100% of the CPU. It will be restarted after rc.bootsetup
# by EmulabStartup.
cygrunsrv -E sshd
# Start up the service which will deliver a SHUTDOWN state event on reboot.
cygrunsrv -S EmulabShutdown
# Done.
logit "rc.cygwin finished."
exit 0
#!/bin/bash
#
# EMULAB-COPYRIGHT
# Copyright (c) 2004, 2005 University of Utah and the Flux Group.
# All rights reserved.
#
# rc.firstboot - CygWin-specific startup.
# Run by EmulabStartup before rc.bootsetup on CygWin. Since Windows needs a
# reboot to change some network settings (including the host name), do this
# first and force the reboot. It was separated out from rc.cygwinxp, which is
# run by rc.bootsetup, because of a race condition on the required reboot: if
# the rc.cygwin child process is killed before rc.bootsetup, rc.bootsetup may
# get a chance to report TBFAILED to Emulab, killing off the whole swap-in.
PATH=/usr/local/etc/emulab:/bin:$SYSTEMROOT/system32:$PATH
export PATH
# Enable logging.
logfile=/var/log/EmulabStartup.log
chmod -f g+w $logfile
function logit () {
msg="`date`: $1"
echo "$msg" >> $logfile
echo "$msg"
}
logit "----------------------------------------------------------------"
logit "Entering rc.firstboot $*"
# Enable WINDOWS() in libsetup.pm .
iscygwin=/etc/emulab/iscygwin
chmod -f g+w /etc/emulab
chmod -f g+w $iscygwin
uname -r > $iscygwin
chmod g+w $iscygwin
chmod -f g-w /etc/emulab
# If 'prepare' wasn't executed before pulling an image, tmcc will be confused
# by the cached info from tmcd. Clean up like bootsetup()/tmccclrconfig().
rm -rf /var/emulab/boot/tmcc
# Capture the hostname early on, for use later. This avoids confusion in the
# case where we are going to the same node as the image was saved from.
hostname=`/bin/hostname`
# Special case while running "rc.firstboot -mini" from Cmdlines.txt under
# Mini-Setup after Sysprep.
if [ "$#" == 1 ] && [ "$1" == "-mini" ]; then
mini=1
# Record the network interface state.
logit "================ Mini-Setup network state"
logit "id "`id`
ipconfig /all >> $logfile
getmac >> $logfile
ipconfig /all
getmac
logit "================"
# The network is set up but not running yet, so we can't contact tmcc to
# find out the host name.
#
# While running "prepare", before doing Sysprep we cached a static mapping
# of node names and the MAC addresses of their interfaces. We can use it
# to set the host name, so that when XP is booted for the first time,
# rc.firstboot will find that the host name has already been set to the
# right thing and go on without rebooting.
#
# Worst case, if the majority of the NICs on the node have been moved
# since the image was made, the static table will be wrong and we'll still
# have to change the hostname and reboot again.
nodeid= intfcmap=/var/emulab/boot/intfcmap
if [[ -r $intfcmap && -s $intfcmap ]]; then
# We're running as SYSTEM under Mini-Setup. Can't write /var/emulab/boot.
macs=/tmp/macs
# Grab the MAC addresses from ipconfig, without dashes and lowercased.
ipconfig /all | tr -d '\r' | grep 'Physical Address' |\
sed -e 's/.*: //' -e 's/-//g' -e 'y/ABCDEF/abcdef/' > $macs
# NIC's may have been physically moved, take a majority vote.
for intfc in `cat $macs`; do grep $intfc $intfcmap; done | \
cut -d ' ' -f 1 | uniq -c | sort -rn | tr -s ' ' > $macs.pc
logit "Mac addresses `cat $macs`"
logit "Node id votes `cat $macs.pc`"
nodeid=`cut -d ' ' -f 3 $macs.pc | head -1`
if [ "$nodeid" != "" ]; then
logit "Node id = $nodeid"
else
logit "Didn't get a nodeid."
exit 1
fi
fi
else
# Make sure all NIC's are up at the start, so they show up on ipconfig.
devcon enable =net 'PCI*'
# Make sure DHCP is enabled on all connected interfaces. Windows only enables
# it on the first one to come up. Otherwise tmcc will fail on the control net
# interface, and we don't know which one that is yet.
#
# Unused interfaces will be disabled below. DHCP will be disabled on the
# experimental net interfaces by "netsh interface ip set address
# ... source=static ..." in BOOTDIR/rc.ifc, which is generated in
# liblocsetup.pm os_ifconfig_line() $IFCONFIG, invoked by rc.ifconfig .
ipconfig /all | tr -d '\r' | awk \
'/^Ethernet adapter/{ ifc = gensub("Ethernet adapter (.*):", "\\1", 1); next }\
/Dhcp Enabled.*No/{ \
cmd = sprintf("netsh interface ip set address \"%s\" dhcp", ifc);\
print cmd; stat = system(cmd);\
printf("Enabled DHCP on %s, status %d.\n", ifc, stat) }'
# Get the desired node name from tmcc, and make sure we have a connection.
# There is a swap-in race condition where tmcc nodeid at first returns nothing.
nodeid=
while [ -z $nodeid ]; do
nodeid=`tmcc nodeid`
if [ -z $nodeid ]; then
logit "Null nodeid returned from tmcc. Trying again."
sleep 5
elif [ "$nodeid" == UNKNOWN ]; then
logit "UNKNOWN nodeid returned from tmcc. Trying again."
nodeid=
sleep 5
fi
done
logit "nodeid = $nodeid"
fi
# NetBT (Netbios over TCP) chatters, messes up slothd, and is not needed for
# SMB, so disable it by default. This doesn't take effect until TCP/IP is
# restarted, so do it before the computer name change below, which reboots the
# first time.
ccs=/HKLM/SYSTEM/CurrentControlSet svcs=$ccs/Services cntl=$ccs/Control
nbtp=$svcs/NetBT/Parameters nbtif=$nbtp/Interfaces
for ifc in `regtool list $nbtif`; do
# Set the NetBT interface NetbiosOptions to Disable (2) or Enable (1.)
if regtool get -q $nbtp/EmulabOn; then able=1; else able=2; fi
regtool set -i $nbtif/$ifc/NetbiosOptions $able
# Also turn off outgoing DNS registration traffic.
regtool set -i $nbtif/$ifc/DisableDynamicUpdate 1
done
# Enable LMHOSTS file lookup on the client side, in case the user runs "netbt"
# to turn NetBT back on again on a server node to share files between nodes.
# rc.lmhosts transforms the /etc/hosts file into a Windows lmhosts file.
regtool set -i $nbtp/EnableLMHOSTS 1
# Turn on IP forwarding if there is more than one experimental net interface.
# Also requires a reboot to take effect.
tp=$svcs/Tcpip/Parameters
if [ `tmcc ifconfig | wc -l` \> 1 ]; then
regtool set -i $tp/IPEnableRouter 1
else
regtool set -i $tp/IPEnableRouter 0
fi
logit "IPEnableRouter set to `regtool get $tp/IPEnableRouter`."
# I'd rather not have it put MSN and Windows Media Player icons on my desktop...
logit "Clearing the MSN and WMP Desktop shortcuts."
rm -f /cygdrive/c/"Documents and Settings/All Users/Desktop/MSN Explorer.lnk"
rm -f /cygdrive/c/"Documents and Settings/Default User/Desktop"/*.lnk
regtool -s set /HKLM/SOFTWARE/Microsoft/Windows/CurrentVersion/Run/CleanWMP \