Commit 19fe1c6d authored by Russ Fish's avatar Russ Fish
Browse files

Tweak Windows boot process to avoid races.

parent 293d4dcc
......@@ -39,70 +39,12 @@ while [ -z $nodeid ]; do
sleep 5
elif [ "$nodeid" == UNKNOWN ]; then
logit "UNKNOWN nodeid returned from tmcc. Trying again."
nodeid=
sleep 5
fi
done
logit "nodeid = $nodeid"
# NetBT (Netbios over TCP) chatters, messes up slothd, and is not needed for
# SMB, so disable it. This doesn't take effect until TCP/IP is restarted, so
# do it before the computer name change below, which reboots the first time.
svcs=/HKLM/SYSTEM/CurrentControlSet/Services pi=Parameters/Interfaces
nbtif=$svcs/NetBT/$pi
for ifc in `regtool list $nbtif`; do
# Set the NetBT interface NetbiosOptions to Disable (2.)
regtool set -i $nbtif/$ifc/NetbiosOptions 2
# Also turn off outgoing DNS registration traffic.
regtool set -i $nbtif/$ifc/DisableDynamicUpdate 1
done
# 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`."
hostname=`/bin/hostname`
host="Host name '$hostname'"
if [ $nodeid = $hostname ]; then
logit "$host matches nodeid '$nodeid'."
else
logit "$host differs from nodeid '$nodeid'."
# Change hostname and computername, rename My Computer, reboot on success.
/usr/local/etc/emulab/WSName /N:$nodeid /REBOOT /MCN
# Does WSName return to the shell? Log it and give it a minute to take effect.
newhost=`/bin/hostname`
logit "$host - WSName returned to shell as '$newhost' after WSName '$nodeid'."
sleep 60
# # Should never get here! Try /sbin/reboot.
# logit "$host - Didn't reboot changing to '$nodeid'! Trying reboot."
# /sbin/reboot
# # Reboot returns to the shell. Give it a few seconds to take effect.
# sleep 10
#
# # Should never get here either!! Try /bin/shutdown.
# logit "$host - Didn't /sbin/reboot changing to '$nodeid'! Trying shutdown."
# /bin/shutdown -r -f now
# # Shutdown returns to the shell. Give it a few seconds to take effect.
# sleep 10
# Last resort!!! tsshutdn
# logit "$host - Didn't /bin/shutdown changing to '$nodeid'! Trying tsshutdn."
logit "$host - Didn't reboot changing to '$nodeid'! Trying tsshutdn."
tsshutdn 1 /REBOOT /DELAY:1
# Shutdown shouldn't return to the shell. Give it a few seconds to take effect.
sleep 10
# Give up, log it, and go on.
logit "$host - Failed to reboot changing to '$nodeid'."
fi
# 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
......@@ -116,6 +58,8 @@ ipconfig /all | tr -d '\r' | awk \
# 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"
......@@ -124,7 +68,7 @@ devcon enable =net 'PCI*'
# Cache getmac output while all interfaces are still enabled. Used by rc.ifconfig .
bootdir=/var/emulab/boot
getmac /nh /v /fo csv > $bootdir/getmac-cache
nifc=`awk '/./{lines++} END{print lines}' $bootdir/getmac-cache` nxifc=0
nifc=`awk '/./{lines++} END{print lines}' $bootdir/getmac-cache`
logit "number of interfaces = $nifc"
# Remember the control net interface MAC address and Local Area Connection name for
......
#!/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"
}
# 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
# 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"
# NetBT (Netbios over TCP) chatters, messes up slothd, and is not needed for
# SMB, so disable it. 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
pi=Parameters/Interfaces nbtif=$svcs/NetBT/$pi
for ifc in `regtool list $nbtif`; do
# Set the NetBT interface NetbiosOptions to Disable (2.)
regtool set -i $nbtif/$ifc/NetbiosOptions 2
# Also turn off outgoing DNS registration traffic.
regtool set -i $nbtif/$ifc/DisableDynamicUpdate 1
done
# 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`."
hostname=`/bin/hostname`
host="Host name '$hostname'"
if [ $nodeid = $hostname ]; then
logit "$host matches nodeid '$nodeid'."
else
logit "$host differs from nodeid '$nodeid'."
logit "Remove a redirect switch to make sure we come back with a serial console."
bootcfg /ems OFF /id 1
# Mash the hostname in all the places it shows up in the registry.
regtool set -s $tp/Hostname $nodeid
regtool set -s $tp/"NV Hostname" $nodeid
cn=ComputerName NODEID=`echo $nodeid | tr 'a-z' 'A-Z'`
regtool set -s $cntl/$cn/Active$cn/$cn $NODEID
regtool set -s $cntl/$cn/$cn/$cn $NODEID
regtool set -s $svcs/Eventlog/$cn $NODEID
logit "Rebooting as '$nodeid'/'$NODEID'."
/sbin/reboot
# Reboot shouldn't return to the shell. Give it a few seconds to take effect.
sleep 10
# Should never get here. Try /bin/shutdown.
logit "$host - Didn't /sbin/reboot changing to '$nodeid'! Trying shutdown."
/bin/shutdown -r -f now
# Shutdown returns to the shell. Give it a few seconds to take effect.
sleep 10
# Last resort!!! tsshutdn
logit "$host - Didn't /bin/shutdown changing to '$nodeid'! Trying tsshutdn."
tsshutdn 1 /REBOOT /DELAY:1
sleep 10
# Give up, log it, and go on.
logit "$host - Failed to reboot changing to '$nodeid'."
fi
# -*- mode: text; indent-tabs-mode: nil -*-
#
# Directions for setting up an XP image from scratch.
# These are raw notes and commands to paste into a shell.
# Mostly Bash shell commands for Windows, some tcsh commands for Boss or Ops.
......@@ -145,9 +147,9 @@ alias v='ls -lsF'
. Download site mirror is http://mirrors.xmission.com .
. Click [View] to "Not Installed" (alphabetical.)
Click on the Skip in the "New" column to add a binary version of:
agetty, bison, cvs, cygrunsrv, ed, file, flex, gcc, gdb, inetutils,
agetty (with src), bison, cvs, cygrunsrv, ed, file, flex, gcc, gdb, inetutils,
make, minires-devel, more, nano, openssh (with src), openssl-devel,
patch, perl, perl-libwin32, psmisc, python, rpm, rsync,
patch, perl, perl-libwin32, ping, psmisc, python, rpm, rsync,
shutdown, sysvinit, tcsh, vim, wget, zip .
Click in the "src" column for openssh and agetty, so patches can be applied.
. At the end, don't "Create an icon on the Desktop", do "Add icon to Start Menu".
......@@ -595,9 +597,11 @@ q
# Set up to run the program-agent service. Notice the -i (interactive) argument.
cygrunsrv -R ProgAgent
progagent=/usr/local/etc/emulab/rc/rc.progagent
cygrunsrv -I ProgAgent -d "Emulab Program Agent" -i -p /cygdrive/c/cygwin/bin/bash \
proglog=/var/log/program-agent.log
cygrunsrv -I ProgAgent -d "Emulab Program Agent" -i \
--type manual \
-a "--norc --noprofile -c '$progagent >& /var/log/program-agent.log'"
-p /cygdrive/c/cygwin/bin/bash \
-a "--norc --noprofile -c '$progagent >& $proglog &'"
regtool -v list /HKLM/SYSTEM/CurrentControlSet/Services/ProgAgent/Parameters
cygrunsrv -VQ ProgAgent
## This won't work until you build the Emulab programs, including program-agent, below.
......@@ -828,15 +832,17 @@ if [ ]; then
. Set up the boot script to run as a service.
# Start up after DHCP and Elvin, run ProgAgent and SlothD afterwards.
# Start up after DHCP, Elvin, and W32Time (for watchdog), run ProgAgent afterwards.
cygrunsrv -R EmulabStartup
rootpwd='daFluxGroup'
firstboot=/usr/local/etc/emulab/rc/rc.firstboot
bootsetup=/usr/local/etc/emulab/rc/rc.bootsetup
progrun="cygrunsrv -S ProgAgent"
bootlog=/var/log/bootsetup.log
cygrunsrv -I EmulabStartup -u root -w $rootpwd --dep DHCP --dep elvinsvc.exe \
cygrunsrv -I EmulabStartup -u root -w $rootpwd \
--dep DHCP --dep elvinsvc.exe --dep W32Time \
-p /cygdrive/c/cygwin/bin/bash \
-a "--norc --noprofile -c '( $bootsetup; $progrun ) >& $bootlog'"
-a "--norc --noprofile -c '( $firstboot; $bootsetup; $progrun ) >& $bootlog'"
cygrunsrv -VQ EmulabStartup
## If you run this, and the node name hasn't been changed yet, it will reboot.
......@@ -1239,11 +1245,14 @@ Updating a set of existing images.
set date=2005-09-29
set updates=/proj/testbed/fish/winxp
set nodes="SP0 SP1 SP2 UPDATE"
# Choose ONE of the following hardware types:
# pc850, IDE disk (pc1 - pc178)
set hw=pc850 disk=/dev/ad0
# pc3000, SCSI disk. (pc201 - pc360)
set hw=pc3000 disk=/dev/da0
set pid=testbed eid=new-windows-$hw
## set pid=testbed eid=test-windows-$hw
set exp=$eid.$pid.emulab.net
......@@ -1459,8 +1468,8 @@ Updating a set of existing images.
# First, -new symlinks for testing.
cd /usr/testbed/images
set pctype; if ( "$hw" != pc850 ) set pctype="-$hw"
v WINXP-{SP[012],UPDATE}$pctype-new.ndz
v WINXP-{SP[012],UPDATE}-$hw"_"$date.ndz
ls -lt WINXP-{SP[012],UPDATE}$pctype-new.ndz
ls -lt WINXP-{SP[012],UPDATE}-$hw"_"$date.ndz
foreach node ( $nodes )
set link=WINXP-$node$pctype-new.ndz file=WINXP-$node-$hw"_"$date.ndz
echo "$link -> $file"
......@@ -1475,6 +1484,7 @@ Updating a set of existing images.
# Convert from "Oct 1 18:24:27 2005" to "2005-10-01 18:24:27" date format. \
"date -j -f \"%b %d %T %Y\" \""$6" "$7" "$8" "$9"\" +\"%F %T\"" | getline date; \
image = gensub("\.ndz", "", 1, $NF); \
image = gensub("UPDATE-pc3000-new", "UPD-pc3000-new", 1, image); # Special case.\
print "update images set created=" sq date sq " where imagename=" sq image sq ";" }' \
| tee ~/imgdates.sql
......@@ -1482,6 +1492,9 @@ Updating a set of existing images.
mysql tbdb < ~/imgdates.sql
echo "select imagename, created, path from images where imagename like 'WINXP-%$pctype-new';" | mysql tbdb
# Check before installing the non -new versions. (WINXP will always be in partition 1.)
echo "select part1_osid from images where imageid like 'emulab-ops-WINXP%';" | mysql tbdb
# Then the regular symlinks.
cd /usr/testbed/images
set pctype; if ( "$hw" != pc850 ) set pctype="-$hw"
......@@ -1504,7 +1517,7 @@ Updating a set of existing images.
print "update images set created=" sq date sq " where imagename=" sq image sq ";" }' \
| tee ~/imgdates.sql
echo "select imagename, created, path from images where imagename like 'WINXP-%$pctype';" | mysql tbdb
echo "select imagename, created, path from images where imagename like 'WINXP-%$pctype';" | mysql tbdb | sort +1
mysql tbdb < ~/imgdates.sql
echo "select imagename, created, path from images where imagename like 'WINXP-%$pctype';" | mysql tbdb
echo "select imagename, created, path from images where imagename like 'WINXP-%$pctype';" | mysql tbdb| sort +1
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment