Commit 9c15cefb authored by Russ Fish's avatar Russ Fish

More hacking around Windows network setup bugs.

parent dc484fcf
......@@ -98,6 +98,7 @@ script-install: dir-install $(SCRIPTS)
$(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)/rc.reboot $(BINDIR)/rc/rc.reboot
sfs-install:
......
......@@ -235,21 +235,13 @@ sub os_accounts_sync()
return 0;
}
#
# Generate and return an ifconfig line that is approriate for putting
# into a shell script (invoked at bootup).
#
# Import the mapping from non-control interface names, e.g. "Local Area
# Connection #4" to the Device Instance ID's used as devcon arguments, e.g.
# "@PCI\VEN_8086&DEV_1010&SUBSYS_10128086&REV_01\5&2FA58B96&0&210030".
my %dev_map = ();
sub os_ifconfig_line($$$$$$$;$$)
sub get_dev_map()
{
my ($iface, $inet, $mask, $speed, $duplex, $aliases,
$iface_type, $settings, $rtabid) = @_;
my ($uplines, $downlines);
if (! $dev_map) {
# Map from non-control interface names, e.g. "Local Area Connection #4"
# to the Device Instance ID's used as devcon arguments, e.g.
# "@PCI\VEN_8086&DEV_1010&SUBSYS_10128086&REV_01\5&2FA58B96&0&210030".
if (! open(DEVMAP, $XIMAP)) {
warning("Cannot open $XIMAP $!\n");
}
......@@ -262,6 +254,35 @@ sub os_ifconfig_line($$$$$$$;$$)
close(DEVMAP);
}
}
}
#
# Generate and return an ifconfig line that is approriate for putting
# into a shell script (invoked at bootup).
#
sub os_ifconfig_line($$$$$$$;$$)
{
my ($iface, $inet, $mask, $speed, $duplex, $aliases,
$iface_type, $settings, $rtabid) = @_;
my ($uplines, $downlines);
# Handle interfaces missing from ipconfig.
get_dev_map();
if ( ! defined( $dev_map{$iface} ) ) {
# Try rc.cygwin again to disable/re-enable the interface object.
system("$BINDIR/rc.cygwin");
# Reboot if it still fails, in hope that the interface comes back.
#
# We dare not proceed, because using netsh to try to set the IP
# address on one of the missing addresses will blow away the IP on
# *another* interface, sometimes the control net interface. Then
# we would really be in the soup...
get_dev_map();
if ( ! defined( $dev_map{$iface} ) ) {
system("$BINDIR/rc.reboot");
}
}
if ($inet ne "") {
# Startup.
......
......@@ -18,13 +18,11 @@ function logit () {
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
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
......@@ -169,8 +167,14 @@ else
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
# The status 0 from this echo masks any failure of the above cygrunsrv.
echo rc.cygwin finished.
# Done.
logit "rc.cygwin finished."
exit 0
......@@ -25,6 +25,8 @@ function logit () {
echo "$msg"
}
logit "Entering rc.firstboot"
# Enable WINDOWS() in libsetup.pm .
iscygwin=/etc/emulab/iscygwin
chmod -f g+w /etc/emulab
......@@ -40,7 +42,14 @@ rm -rf /var/emulab/boot/tmcc
# 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. Otherwise tmcc will fail.
# 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 by logic
# 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/{ stat = system("netsh interface ip set address \"$ifc\" dhcp");\
......@@ -104,11 +113,6 @@ if [ $nodeid = $hostname ]; then
logit "$host matches nodeid '$nodeid'."
else
logit "$host differs from nodeid '$nodeid'."
# A reboot will be required.
tmcc state SHUTDOWN
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
......@@ -119,27 +123,7 @@ else
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, ask for power cycle, and wait until timeout if that fails.
logit "$host - Failed to reboot changing to '$nodeid' Asking for power cycle."
tmcc state WEDGED
sleep 1200
# Should never get here!
logit "$host - Failed power cycle too. Network stack is not reset."
/usr/local/etc/emulab/rc/rc.reboot
fi
logit "rc.firstboot finished."
#!/bin/bash
#
# EMULAB-COPYRIGHT
# Copyright (c) 2004, 2005 University of Utah and the Flux Group.
# All rights reserved.
#
# rc.reboot - CygWin-specific reboot script.
#
# Run by rc.firstboot when it needs to change the hostname, and rc.ifconfig
# when a needed experimental-net network interface can't be made to work.
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 "Entering rc.reboot"
# Tell Emulab that a reboot is required.
tmcc state SHUTDOWN
logit "Remove a redirect switch to make sure we come back with a serial console."
bootcfg /ems OFF /id 1
# You wouldn't think that rebooting would be hard, but like everything else
# on Windows, the obvious doesn't always work reliably.
/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 "*** /sbin/reboot didn't work. 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 "*** /bin/shutdown didn't work. Trying tsshutdn."
tsshutdn 1 /REBOOT /DELAY:1
sleep 10
# Give up, log it, ask for power cycle, and wait until timeout if that fails.
logit "*** Failed to reboot. Asking for power cycle."
tmcc state
sleep 1200
# Should never get here!
logit "*** Failed power cycle too. Network stack is not reset."
sleep 9999
\ No newline at end of file
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