source: trunk/debathena/scripts/installer/pxe/natty/debathena/installer.sh @ 25452

Revision 25452, 7.5 KB checked in by jdreed, 12 years ago (diff)
A better solution for the Vostro/r8169 problem.
Line 
1#!/bin/sh
2
3# Sigh.  check-missing-firmware is too stupid to reconfigure the NIC after
4# removing and reloading the module.  So we lose network in the middle
5# of the install.  The card works just fine without firmware, so we
6# just convince hwdetect and friends that there is no missing firmware.
7# NOTE: Although the nic-firmware udeb does not include the Realtek
8# firmware, shipping the firmware ourselves does not fix the problem,
9# because check-missing-firmware still insists on reloading the module
10# and we lose the network configuration.
11if grep -q "^Vostro 320" /sys/class/dmi/id/product_name || lsmod | grep -q r8169; then
12    rm -f /dev/.udev/firmware-missing/*
13fi
14
15cd /debathena
16
17touch preseed
18
19pxetype=""
20
21# Using debconf here will hang, so parse the command line manually.
22# old options:
23#   debathena/clusterforce: implies pxetype=cluster, don't recheck net
24#   debathena/clusteraddr: address to use with above
25# new options:
26#   debathena/pxetype: could be cluster, but could be other things
27
28# support for clusteraddr should be removed sometime in Spring 2012
29# Be sure to remove the conditional around line 115 too.
30clusteraddr=`sed -e 's/ /\n/g' < /proc/cmdline | grep debathena/clusteraddr | sed -e 's/.*=//'`
31pxetype=`sed -e 's/ /\n/g' < /proc/cmdline | grep da/pxe= | sed -e 's/.*=//'`
32if [ -z "$pxetype" ]; then
33    # Fallback to old-style option for very old machines that haven't
34    # updated.  This conditional should be removed sometime in Spring 2012
35    pxetype=`sed -e 's/ /\n/g' < /proc/cmdline | grep debathena/pxetype | sed -e 's/.*=//'`
36fi
37installertype=`sed -e 's/ /\n/g' < /proc/cmdline | grep da/i= | sed -e 's/.*=//'`
38mirrorsite=`sed -e 's/ /\n/g' < /proc/cmdline | grep da/m= | sed -e 's/.*=//'`
39partitioning=`sed -e 's/ /\n/g' < /proc/cmdline | grep da/part= | sed -e 's/.*=//'`
40nodhcp=`sed -e 's/ /\n/g' < /proc/cmdline | grep netcfg/disable_dhcp= | sed -e 's/.*=//'`
41
42
43echo "Picked up values from command line:
44clusteraddr=$clusteraddr
45pxetype=$pxetype
46installertype=$installertype
47mirrorsite=$mirrorsite"
48
49# Apply some sane defaults
50if [ -z "$installertype" ]; then installertype=production ; fi
51if [ -z "$mirrorsite" ]; then mirrorsite="mirrors.mit.edu" ; fi
52
53# Sanity check
54if [ -z "$pxetype" ]; then
55  echo "ERROR: No pxetype on the command line."
56  echo "Cannot proceed.  Reboot now, please."
57  read dummy
58fi
59
60
61netconfig () {
62  echo "Configuring network..."
63  mp=/debathena
64  export IPADDR NETMASK GATEWAY SYSTEM CONTROL
65  while [ -z "$IPADDR" ] ; do
66    echo -n "Enter IP address: "
67    read IPADDR
68  done
69  NETMASK=`$mp/athena/netparams -f $mp/athena/masks $IPADDR|cut -d\  -f 1`
70  net=`$mp/athena/netparams -f $mp/athena/masks $IPADDR|cut -d\  -f 2`
71  bc=`$mp/athena/netparams -f $mp/athena/masks $IPADDR|cut -d\  -f 3`
72  GATEWAY=`$mp/athena/netparams -f $mp/athena/masks $IPADDR|cut -d\  -f 4`
73  maskbits=`$mp/athena/netparams -f $mp/athena/masks $IPADDR|cut -d\  -f 5`
74
75  echo "Address: $IPADDR"
76  echo
77  echo "Autoconfigured settings:"
78  echo "  Netmask bits: $maskbits"
79  echo "  Broadcast: $bc"
80  echo "  Gateway: $GATEWAY"
81
82  echo "Killing dhcp client."
83  killall dhclient
84  echo "Running: ip addr flush dev eth0"
85  ip addr flush dev eth0
86  echo "Running: ip addr add $IPADDR/$maskbits broadcast $bc dev eth0"
87  ip addr add $IPADDR/$maskbits broadcast $bc dev eth0
88  echo "Flushing old default route."
89  route delete default 2> /dev/null
90  echo "Running: route add default gw $GATEWAY"
91  route add default gw $GATEWAY
92  echo "Replacing installer DHCP nameserver with MIT nameservers."
93  sed -e '/nameserver/s/ .*/ 18.72.0.3/' < /etc/resolv.conf > /etc/resolv.conf.new
94  echo "nameserver      18.70.0.160" >> /etc/resolv.conf.new
95  echo "nameserver      18.71.0.151" >> /etc/resolv.conf.new
96  mv -f /etc/resolv.conf.new /etc/resolv.conf
97  echo "Saving preseed netcfg values"
98  cat >> preseed <<EOF
99d-i netcfg/get_nameservers string 18.72.0.3
100d-i netcfg/get_ipaddress string $IPADDR
101d-i netcfg/get_netmask string $NETMASK
102d-i netcfg/get_gateway string $GATEWAY
103d-i netcfg/confirm_static boolean true
104EOF
105}
106
107# Color strings. I'd like to use tput, but the installer doesn't have it.
108esc=""
109nnn="${esc}[m"          # Normal
110ccc="${esc}[36m"        # Cyan
111rrr="${esc}[1;31m"      # Bold and red
112ddd="${esc}[1;31;47m"   # Plus gray background
113ddb="${esc}[1;31;47;5m" # Plus blinking
114
115# OK, we can arrive at this point in the installer through two
116# ways:  from the stage1 installer or from athena-auto-upgrade
117# Anything else is an error and will not be supported.
118# The stage1 installer takes care of sanity-checking networking
119# so if we have a DHCP address here, it's either valid, or we got here
120# from an old athena-auto-upgrade that doesn't do full networking.
121
122if [ -n "$clusteraddr" ] && [ "$nodhcp" != "true" ]; then
123  IPADDR=$clusteraddr
124  netconfig
125else
126  # We're not running netconfig here, but install-debathena.sh still
127  # uses the information from the preseed. So convert information from
128  # the kernel command line to the preseed file format.
129  sed "s/ /\n/g" < /proc/cmdline | grep "^netcfg" | sed -e "s/^/d-i /" -e "s/=/ string /" >> preseed
130fi
131
132# We're at a point in the install process where we can be fairly sure
133# that nothing else is happening, so "killall wget" should be safe.
134(sleep 5; killall wget >/dev/null 2>&1) &
135if wget -s http://$mirrorsite/ubuntu ; then
136  if ip address show to 18.0.0.0/8 | grep -q . && ! ip address show to 18.2.0.0/16 | grep -q . ; then
137    echo "Network config checks out.  Proceeding..."
138  else
139    echo "Your computer seems not to be registered on MITnet, but the mirror"
140    echo "site $mirrorsite is accessible. Continuing anyway."
141  fi
142else
143  echo "${rrr}The mirror site $mirrorsite is NOT accessible in your current"
144  echo "network configuration.  Cannot continue."
145  echo "Reboot now."
146  read dummy
147fi
148
149# Perferred hostname of mirror site
150# We want this here even for vanilla installs
151cat >> preseed <<EOF
152d-i apt-setup/hostname string $mirrorsite
153d-i mirror/http/hostname string $mirrorsite
154d-i mirror/country string manual
155d-i mirror/http/directory string /ubuntu
156d-i mirror/http/proxy string
157EOF
158
159if [ vanilla = "$pxetype" ] ; then
160  echo "Starting normal Ubuntu install in five seconds."
161  sleep 5
162  exit 0
163fi
164
165if [ cluster = "$pxetype" ]; then
166  if [ "$partitioning" != "manual" ]; then
167    cat << EOF
168************************************************************
169               ${ddb}DESTROYS${nnn}
170${rrr}THIS PROCEDURE ${ddd}DESTROYS${nnn}${rrr} THE CONTENTS OF THE HARD DISK.${nnn}
171               ${ddb}DESTROYS${nnn}
172
173IF YOU DO NOT WISH TO CONTINUE, REBOOT NOW.
174
175************************************************************
176
177EOF
178    echo "Installing autoinstall preseed file."
179    egrep -v '(^$|^#)' < preseed.autoinstall >> preseed
180  else
181    echo "Installing autoinstall preseed file without automated partitioning."
182    egrep -v '(^$|^#|partman)' < preseed.autoinstall >> preseed
183  fi
184fi
185
186# Shovel in the generically useful preseed stuff regardless.
187egrep -v '(^$|^#)' < preseed.common >> preseed
188
189
190# This is used by the final installer step.
191# A hardcoded number is used as DNS may still be iffy.
192echo "Fetching Debathena postinstaller."
193# 18.92.2.195 = OLD athena10.mit.edu
194# 18.9.60.73 = NEW athena10.mit.edu
195if [ "$installertype" = "beta" ]; then
196  wget http://18.9.60.73/install-debathena.beta.sh
197  mv install-debathena.beta.sh install-debathena.sh
198else
199  wget http://18.9.60.73/install-debathena.sh
200fi
201
202# Let the postinstall know what we are up to.
203echo "$pxetype" > pxe-install-flag
204
205echo "Initial Debathena installer complete; exiting preconfig to start main install."
206if [ "$pxetype" != "cluster" ] || [ "$installertype" = "beta" ]; then
207  echo "Hit return to continue."
208  read r
209fi
210exit 0
Note: See TracBrowser for help on using the repository browser.