rc.cygwinxp 2.33 KB
Newer Older
1
2
3
4
5
6
#!/bin/bash
#
# EMULAB-COPYRIGHT
# Copyright (c) 2004 University of Utah and the Flux Group.
# All rights reserved.
#
7
# rc.cygwinxp - CygWin-specific startup.  Run by rc.bootsetup on CygWin.
8

9
# Enable logging.
Russ Fish's avatar
Russ Fish committed
10
logfile=/var/log/EmulabStartup.log
11
12
13
14
chmod -f g+w $logfile

# Enable WINDOWS() in libsetup.pm .
iscygwin=/etc/emulab/iscygwin
15
chmod -f g+w /etc/emulab
16
17
18
chmod -f g+w $iscygwin
uname -r > $iscygwin
chmod g+w $iscygwin
19
chmod -f g-w /etc/emulab
20

21
22
# Set up for autologin as the swapin user after reboot.
# Also run rc.cygwinxp-user as part of all logins.
23
24
25
tmcc=/usr/local/etc/emulab/tmcc.bin
swapper=`$tmcc creator | sed 's|.*SWAPPER=\([^ ]*\).*|\1|'`
echo "`date`: Set to autologin as $swapper." >> $logfile
26
27
28
alogdir=/var/emulab/boot
autologin=$alogdir/autologin.reg
chmod -f g+w $alogdir
29
rm -f $autologin
30
# Note the double-doubled backslashes below.  Bash and regedit each eat a level.
31
32
33
34
35
36
cat <<EOF > $autologin
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon]
"AutoAdminLogon"="1"
"DefaultUserName"="$swapper"
37
38
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]
"EmulabLogin"="C:\\\\cygwin\\\\bin\\\\bash /usr/local/etc/emulab/rc/rc.cygwinxp-user"
39
40
EOF
chmod g+rw $autologin
41
42
chmod -f g-w $alogdir
winautologin=`cygpath -w $autologin`
43
44
45
regedit=/cygdrive/c/WINDOWS/regedit
if ! $regedit -s "$winautologin" ; then
    echo "`date`: $regedit -s $winautologin failed with code $?." >> $logfile
46
fi
47
48
49
50

# Make sure the computer name is right, reboots to change it if necessary.
nodeid=`$tmcc nodeid`
hostname=`/bin/hostname`
Russ Fish's avatar
Russ Fish committed
51
datehost="`date`: Host name '$hostname'"
52
if [ $nodeid == $hostname ]; then
Russ Fish's avatar
Russ Fish committed
53
    echo "$datehost matches nodeid '$nodeid'." >> $logfile
54
else
Russ Fish's avatar
Russ Fish committed
55
    echo "$datehost differs from nodeid '$nodeid'." >> $logfile
56
57
58
59

    # Change hostname and computername, rename My Computer, reboot on success.
    /usr/local/etc/emulab/WSName /N:$nodeid /REBOOT /MCN
fi
60
61
62
63
64
65
66
67
68
69

# 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 a /etc/resolv.h, which tmcc needs for bossinfo.
# Make one from nslookup output.
ipconfig /all | awk \
    '/^ *Connection-specific DNS Suffix/{print "search", $NF} \
     /^ *DNS Servers/{print "nameserver", $NF}' > /etc/resolv.conf