source: trunk/debathena/scripts/installer/pxe/jaunty/debathena-jaunty/installer.sh @ 24915

Revision 24915, 8.3 KB checked in by amb, 14 years ago (diff)
Desupport 32-bit installs.
Line 
1#!/bin/sh
2
3cd /debathena-jaunty
4
5touch preseed
6
7pxetype=""
8
9# Using debconf here will hang, so parse the command line manually.
10# Commented out in the belief that hackbooting *into* the jaunty installer is now always the wrong thing.
11# clusterforce=`sed -e 's/ /\n/g' < /proc/cmdline | grep debathena/clusterforce | sed -e 's/.*=//'`
12clusteraddr=`sed -e 's/ /\n/g' < /proc/cmdline | grep debathena/clusteraddr | sed -e 's/.*=//'`
13
14if [ "$clusteraddr" ] ; then IPADDR=$clusteraddr ; fi
15
16if [ "$clusteraddr" -a "$clusterforce" = yes ] ; then pxetype=cluster ; fi
17
18netconfig () {
19  echo "Configuring network..."
20  mp=/debathena-jaunty
21  export IPADDR NETMASK GATEWAY SYSTEM CONTROL
22  while [ -z "$IPADDR" ] ; do
23    echo -n "Enter IP address: "
24    read IPADDR
25  done
26  NETMASK=`$mp/athena/netparams -f $mp/athena/masks $IPADDR|cut -d\  -f 1`
27  net=`$mp/athena/netparams -f $mp/athena/masks $IPADDR|cut -d\  -f 2`
28  bc=`$mp/athena/netparams -f $mp/athena/masks $IPADDR|cut -d\  -f 3`
29  GATEWAY=`$mp/athena/netparams -f $mp/athena/masks $IPADDR|cut -d\  -f 4`
30  maskbits=`$mp/athena/netparams -f $mp/athena/masks $IPADDR|cut -d\  -f 5`
31
32  echo "Address: $IPADDR"
33  echo
34  echo "Autoconfigured settings:"
35  echo "  Netmask bits: $maskbits"
36  echo "  Broadcast: $bc"
37  echo "  Gateway: $GATEWAY"
38
39  if [ "$clusterforce" != yes ] ; then
40    echo -n "Are these OK? [Y/n]: "; read response
41    case $response in
42      y|Y|"") ;;
43      *)
44      echo -n "Netmask bits [$maskbits]: "; read r; if [ "$r" ] ; then maskbits=$r ; fi
45      echo -n "Broadcast [$bc]: "; read r; if [ "$r" ] ; then bc=$r ; fi
46      echo -n "Gateway [$GATEWAY]: "; read r; if [ "$r" ] ; then GATEWAY=$r ; fi
47    esac
48  fi
49
50  # We can not set the hostname here; running "debconf-set netcfg/get_hostname"
51  # causes fatal reentry problems.  Setting values directly with preseeding
52  # also fails, as the DHCP values override it.
53  echo "Killing dhcp client."
54  killall dhclient
55  echo "Running: ip addr flush dev eth0"
56  ip addr flush dev eth0
57  echo "Running: ip addr add $IPADDR/$maskbits broadcast $bc dev eth0"
58  ip addr add $IPADDR/$maskbits broadcast $bc dev eth0
59  echo "Flushing old default route."
60  route delete default 2> /dev/null
61  echo "Running: route add default gw $GATEWAY"
62  route add default gw $GATEWAY
63  echo "Replacing installer DHCP nameserver with MIT nameservers."
64  sed -e '/nameserver/s/ .*/ 18.72.0.3/' < /etc/resolv.conf > /etc/resolv.conf.new
65  echo "nameserver      18.70.0.160" >> /etc/resolv.conf.new
66  echo "nameserver      18.71.0.151" >> /etc/resolv.conf.new
67  mv -f /etc/resolv.conf.new /etc/resolv.conf
68}
69
70# Color strings. I'd like to use tput, but the installer doesn't have it.
71esc=""
72nnn="${esc}[m"          # Normal
73ccc="${esc}[36m"        # Cyan
74rrr="${esc}[1;31m"      # Bold and red
75ddd="${esc}[1;31;47m"   # Plus gray background
76ddb="${esc}[1;31;47;5m" # Plus blinking
77
78
79echo "Welcome to Athena."
80echo
81
82while [ -z "$pxetype" ] ; do
83  echo "Choose one:"
84  echo
85  echo "  1: Perform an unattended ${ccc}debathena-cluster${nnn} install, ${rrr}ERASING your"
86  echo "     ENTIRE DISK${nnn}. This option is only intended for people setting up"
87  echo "     public cluster machines maintained by IS&T/Athena. If you select"
88  echo "     this option, you hereby agree with the license terms at:"
89  echo "     <http://dlc.sun.com/dlj/DLJ-v1.1.txt>,"
90  echo "     Sun's Operating System Distributor License for Java version 1.1."
91  echo
92  echo "  2: Do a ${ccc}normal Debathena install${nnn} of Ubuntu 10.04${nnn} (Lucid Lynx)."
93  echo "     You'll need to answer normal Ubuntu install prompts, and then the"
94  echo "     Athena-specific prompts, including choosing which flavor of Debathena"
95  echo "     you'd like (e.g., private workstation)."
96  echo
97  echo "  3: Punt to a completely ${ccc}vanilla install of Ubuntu 10.04${nnn} (Lucid Lynx)."
98  echo "     (Note: locale and keyboard have already been set.)"
99  echo
100  echo "  4: /bin/sh (for rescue purposes)"
101  echo
102  echo -n "Choose: "
103  read r
104  case "$r" in
105    1|1a)
106      echo "Debathena CLUSTER it is."; pxetype=cluster ;;
107#    1a)
108#      echo "Debathena CLUSTER it is, forced to 32-bit."; pxetype=cluster ; arch=i386;;
109    2)
110      echo "Normal Debathena install it is."; pxetype=choose ;;
111    3)
112      echo "Vanilla Ubuntu it is."; pxetype=vanilla;;
113    4)
114      echo "Here's a shell.  You'll return to this prompt when done."
115      /bin/sh;;
116    9)
117      echo "There is no option 9.  Option 1 will do a Lucid cluster install.";;
118    *)
119      echo "Choose one of the above, please.";;
120  esac
121done
122
123##############################################################################
124
125if [ -z "$mirrorsite" ] ; then mirrorsite=ubuntu.media.mit.edu ; fi
126
127# Consider setting a static IP address, especially if we can't reach the mirror.
128if [ cluster != $pxetype ]; then
129  # We're at a point in the install process where we can be fairly sure
130  # that nothing else is happening, so "killall wget" should be safe.
131  (sleep 5; killall wget >/dev/null 2>&1) &
132  if wget -s http://$mirrorsite/ubuntu ; then
133    if ip address show to 18/8 | grep -q . && ! ip address show to 18.2/16 | grep -q . ; then
134      echo "Your computer seems to be registered on MITnet."
135    else
136      echo "Your computer seems not to be registered on MITnet, but the mirror"
137      echo "site $mirrorsite is accessible."
138    fi
139    echo
140    echo "${ccc}You can continue the install using your existing dynamic address.${nnn}"
141    echo -n "Configure a static address anyway?  [y/N]: "
142    while : ; do
143      read r
144      case "$r" in
145        N*|n*|"") break;;
146        y*|Y*) netconfig; break;;
147      esac
148      echo -n "Choose: [y/N]: "
149    done
150  else
151    echo "The mirror site $mirrorsite is NOT accessible in your current"
152    echo "dynamic configuration."
153    echo
154    echo "${rrr}You must specify a static address for the installation.${nnn}"
155    netconfig
156  fi
157else
158  netconfig
159fi
160
161if [ cluster = "$pxetype" ]; then
162  if [ notreally != "$destroys" ]; then
163    cat << EOF
164************************************************************
165               ${ddb}DESTROYS${nnn}
166${rrr}THIS PROCEDURE ${ddd}DESTROYS${nnn}${rrr} THE CONTENTS OF THE HARD DISK.${nnn}
167               ${ddb}DESTROYS${nnn}
168
169IF YOU DO NOT WISH TO CONTINUE, REBOOT NOW.
170
171************************************************************
172
173EOF
174    echo "Installing autoinstall preseed file."
175    egrep -v '(^$|^#)' < preseed.autoinstall >> preseed
176  else
177    echo "Installing autoinstall preseed file without automated partitioning."
178    egrep -v '(^$|^#|partman)' < preseed.autoinstall >> preseed
179  fi
180fi
181
182# Fetch secondary (real) installer, invoking as specified above:
183if [ -z "$arch" ] ; then
184  if egrep -q '^flags[  ].* lm( |$)' /proc/cpuinfo
185    then arch=amd64 ; else arch=i386
186  fi
187  echo "Autodetected architecture: $arch."
188else
189  echo "Forced architecture: $arch."
190fi
191
192echo "Initial Debathena setup complete; ready to reboot into main installer."
193if ! [ "$clusteraddr" -a "$clusterforce" = yes ] ; then
194  echo "Hit return to continue."
195  read r
196fi
197
198echo "Fetching next installer phase..."
199# Network config now done above.
200mkdir /h; cd /h
201wget http://debathena.mit.edu/net-install/kexec
202wget http://debathena.mit.edu/net-install/lucid/${arch}/initrd.gz
203wget http://debathena.mit.edu/net-install/lucid/${arch}/linux
204chmod 755 kexec
205# This is just the guts of the hackboot script:
206dkargs="DEBCONF_DEBUG=5"
207hname=install-target-host
208if [ "$IPADDR" = dhcp ] ; then
209  knetinfo="netcfg/get_hostname=$hname "
210else
211  # There's no good way to get a hostname here, but the postinstall will deal.
212  knetinfo="netcfg/disable_dhcp=true \
213    netcfg/get_domain=mit.edu \
214    netcfg/get_hostname=$hname \
215    netcfg/get_nameservers=18.72.0.3 \
216    netcfg/get_ipaddress=$IPADDR \
217    netcfg/get_netmask=$NETMASK \
218    netcfg/get_gateway=$GATEWAY \
219    netcfg/confirm_static=true"
220fi
221kargs="$knetinfo locale=en_US console-setup/layoutcode=us interface=auto \
222          url=http://18.9.60.73/installer/lucid/debathena.preseed \
223          debathena/pxetype=$pxetype debathena/clusteraddr=$IPADDR --"
224echo "Continuing in five seconds..."
225./kexec -l linux --append="$dkargs $kargs" --initrd=initrd.gz \
226          && sleep 3 && chvt 1 && sleep 2 && ./kexec -e
227echo "Secondary installed failed; please contact release-team@mit.edu"
228echo "with the circumstances of your install attempt.  Here's a shell for debugging:"
229# We don't want to let this fall through to an actual Jaunty install.
230while : ; do /bin/sh ; done
Note: See TracBrowser for help on using the repository browser.