Commit 7581d2d8 authored by Russ Fish's avatar Russ Fish

Add a -mini arg to rc.firstboot, invoked by Cmdlines.txt under Mini-Setup.

parent f69b4721
[Commands]
"C:\cygwin\bin\bash.exe -c /usr/local/etc/emulab/rc/rc.firstboot"
......@@ -39,37 +39,82 @@ chmod -f g-w /etc/emulab
# by the cached info from tmcd. Clean up like bootsetup()/tmccclrconfig().
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. 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");\
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
# 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 ================"
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 macs=/var/emulab/boot/macs
if [[ -r $intfcmap && -s $intfcmap ]]; then
ipconfig /all | tr -d '\r' | grep 'Physical Address' |\
sed -e 's/.*: //' -e 's/-//g' -e 'y/ABCDEF/abcdef/' > $macs
# NIC's may have been 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
done
logit "nodeid = $nodeid"
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 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");\
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. This doesn't take effect until TCP/IP is restarted, so
......
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