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

Revision 24733, 9.3 KB checked in by amb, 14 years ago (diff)
Switch to lucid installs. (With architecture detection, even.)
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.
10clusterforce=`sed -e 's/ /\n/g' < /proc/cmdline | grep debathena/clusterforce | sed -e 's/.*=//'`
11clusteraddr=`sed -e 's/ /\n/g' < /proc/cmdline | grep debathena/clusteraddr | sed -e 's/.*=//'`
12
13if [ "$clusteraddr" ] ; then IPADDR=$clusteraddr ; fi
14
15if [ "$clusteraddr" -a "$clusterforce" = yes ] ; then pxetype=cluster ; fi
16
17netconfig () {
18  echo "Configuring network..."
19  mp=/debathena-jaunty
20  export IPADDR NETMASK GATEWAY SYSTEM CONTROL
21  while [ -z "$IPADDR" ] ; do
22    echo -n "Enter IP address: "
23    read IPADDR
24  done
25  NETMASK=`$mp/athena/netparams -f $mp/athena/masks $IPADDR|cut -d\  -f 1`
26  net=`$mp/athena/netparams -f $mp/athena/masks $IPADDR|cut -d\  -f 2`
27  bc=`$mp/athena/netparams -f $mp/athena/masks $IPADDR|cut -d\  -f 3`
28  GATEWAY=`$mp/athena/netparams -f $mp/athena/masks $IPADDR|cut -d\  -f 4`
29  maskbits=`$mp/athena/netparams -f $mp/athena/masks $IPADDR|cut -d\  -f 5`
30
31  echo "Address: $IPADDR"
32  echo
33  echo "Autoconfigured settings:"
34  echo "  Netmask bits: $maskbits"
35  echo "  Broadcast: $bc"
36  echo "  Gateway: $GATEWAY"
37
38  if [ "$clusterforce" != yes ] ; then
39    echo -n "Are these OK? [Y/n]: "; read response
40    case $response in
41      y|Y|"") ;;
42      *)
43      echo -n "Netmask bits [$maskbits]: "; read r; if [ "$r" ] ; then maskbits=$r ; fi
44      echo -n "Broadcast [$bc]: "; read r; if [ "$r" ] ; then bc=$r ; fi
45      echo -n "Gateway [$GATEWAY]: "; read r; if [ "$r" ] ; then GATEWAY=$r ; fi
46    esac
47  fi
48
49  # We can not set the hostname here; running "debconf-set netcfg/get_hostname"
50  # causes fatal reentry problems.  Setting values directly with preseeding
51  # also fails, as the DHCP values override it.
52  echo "Killing dhcp client."
53  killall dhclient
54  echo "Running: ip addr flush dev eth0"
55  ip addr flush dev eth0
56  echo "Running: ip addr add $IPADDR/$maskbits broadcast $bc dev eth0"
57  ip addr add $IPADDR/$maskbits broadcast $bc dev eth0
58  echo "Flushing old default route."
59  route delete default 2> /dev/null
60  echo "Running: route add default gw $GATEWAY"
61  route add default gw $GATEWAY
62  echo "Replacing installer DHCP nameserver with MIT nameservers."
63  sed -e '/nameserver/s/ .*/ 18.72.0.3/' < /etc/resolv.conf > /etc/resolv.conf.new
64  echo "nameserver      18.70.0.160" >> /etc/resolv.conf.new
65  echo "nameserver      18.71.0.151" >> /etc/resolv.conf.new
66  mv -f /etc/resolv.conf.new /etc/resolv.conf
67}
68
69# Color strings. I'd like to use tput, but the installer doesn't have it.
70esc=""
71nnn="${esc}[m"          # Normal
72ccc="${esc}[36m"        # Cyan
73rrr="${esc}[1;31m"      # Bold and red
74ddd="${esc}[1;31;47m"   # Plus gray background
75ddb="${esc}[1;31;47;5m" # Plus blinking
76
77
78echo "Welcome to Athena."
79echo
80
81while [ -z "$pxetype" ] ; do
82  echo "Choose one:"
83  echo
84  echo "  1: Perform an unattended ${ccc}debathena-cluster${nnn} install, ${rrr}ERASING your"
85  echo "     ENTIRE DISK${nnn}. This option is only intended for people setting up"
86  echo "     public cluster machines maintained by IS&T/Athena. If you select"
87  echo "     this option, you hereby agree with the license terms at:"
88  echo "     <http://dlc.sun.com/dlj/DLJ-v1.1.txt>,"
89  echo "     Sun's Operating System Distributor License for Java version 1.1."
90  echo
91  echo "  2: Do a ${ccc}normal Debathena install${nnn}.  You'll need to answer normal Ubuntu"
92  echo "     install prompts, and then the Athena-specific prompts, including"
93  echo "     choosing which flavor of Debathena you'd like (e.g., private workstation)."
94  echo
95  echo "  3: Punt to a completely ${ccc}vanilla install of Ubuntu 9.04${nnn} (Jaunty Jackalope)."
96  echo "     (Note: locale and keyboard have already been set.)"
97  echo
98  echo "  4: /bin/sh (for rescue purposes)"
99  echo
100  echo -n "Choose: "
101  read r
102  case "$r" in
103    1)
104      echo "Debathena CLUSTER it is."; pxetype=cluster ;;
105    1a)
106      # Yes, this is undocumented.
107      echo "Debathena CLUSTER it is."; pxetype=cluster
108      echo -n "...but choose a preferred mirror hostname, too: "
109      read mirrorsite
110      echo "Using mirror site $mirrorsite";;
111    1b)
112      # This too.
113      echo "Debathena CLUSTER it is."; pxetype=cluster
114      echo "...but you get to partition by hand. Your hard disk"
115      echo "will not be automatically reformatted."; destroys=notreally
116      echo
117      echo "The default cluster installer sets up:"
118      echo " - a 200MB ext3 /boot partition"
119      echo " - an LVM volume group named 'athena', containing"
120      echo "   - a (3x system RAM)-sized swap LV (at least 512 MB)"
121      echo "   - a root LV taking up half the remaining space (at least 10 GB)"
122      echo
123      echo "You probably want to set up something similar."
124      echo "Press enter to continue."
125      read r;;
126    2)
127      echo "Normal Debathena install it is."; pxetype=choose ;;
128    2a)
129      echo "Normal Debathena install it is."; pxetype=choose
130      echo -n "...but choose a preferred mirror hostname, too: "
131      read mirrorsite
132      echo "Using mirror site $mirrorsite";;
133    3)
134      echo "Vanilla Ubuntu it is."; pxetype=vanilla;;
135    4)
136      echo "Here's a shell.  You'll return to this prompt when done."
137      /bin/sh;;
138     
139    9) # switch to Lucid with architecture autodetect
140      if egrep -q '^flags[      ].* lm( |$)' /proc/cpuinfo
141        then arch=amd64 ; else arch=i386 ; fi
142      echo "OK, configuring net and then switching to a lucid $arch cluster install."
143      netconfig
144      mkdir /h; cd /h
145      wget http://debathena.mit.edu/net-install/kexec
146      wget http://debathena.mit.edu/net-install/lucid/${arch}/initrd.gz
147      wget http://debathena.mit.edu/net-install/lucid/${arch}/linux
148      chmod 755 kexec
149      # This is just the guts of the hackboot script:
150      dkargs="DEBCONF_DEBUG=5"
151      kargs="netcfg/get_hostname= locale=en_US console-setup/layoutcode=us interface=auto \
152          url=http://18.9.60.73/installer/lucid/debathena.preseed \
153          debathena/clusterforce=yes debathena/clusteraddr=$IPADDR --"
154      echo "Self-destruct in 5.  Bai!"
155      ./kexec -l linux --append="$dkargs $kargs" --initrd=initrd.gz \
156          && sleep 3 && chvt 1 && sleep 2 && ./kexec -e
157      echo "Well, that didn't work.  Here's a shell."
158      /bin/sh;;
159    *)
160      echo "Choose one of the above, please.";;
161  esac
162done
163
164##############################################################################
165
166if [ -z "$mirrorsite" ] ; then mirrorsite=ubuntu.media.mit.edu ; fi
167
168# Consider setting a static IP address, especially if we can't reach the mirror.
169if [ cluster != $pxetype ]; then
170  # We're at a point in the install process where we can be fairly sure
171  # that nothing else is happening, so "killall wget" should be safe.
172  (sleep 5; killall wget >/dev/null 2>&1) &
173  if wget -s http://$mirrorsite/ubuntu ; then
174    if ip address show to 18/8 | grep -q . && ! ip address show to 18.2/16 | grep -q . ; then
175      echo "Your computer seems to be registered on MITnet."
176    else
177      echo "Your computer seems not to be registered on MITnet, but the mirror"
178      echo "site $mirrorsite is accessible."
179    fi
180    echo
181    echo "${ccc}You can continue the install using your existing dynamic address.${nnn}"
182    echo -n "Configure a static address anyway?  [y/N]: "
183    while : ; do
184      read r
185      case "$r" in
186        N*|n*|"") break;;
187        y*|Y*) netconfig; break;;
188      esac
189      echo -n "Choose: [y/N]: "
190    done
191  else
192    echo "The mirror site $mirrorsite is NOT accessible in your current"
193    echo "dynamic configuration."
194    echo
195    echo "${rrr}You must specify a static address for the installation.${nnn}"
196    netconfig
197  fi
198else
199  netconfig
200fi
201
202if [ vanilla = $pxetype ] ; then
203  echo "Starting normal Ubuntu install in five seconds."
204  sleep 5
205  exit 0
206fi
207
208if [ cluster = "$pxetype" ]; then
209  if [ notreally != "$destroys" ]; then
210    cat << EOF
211************************************************************
212               ${ddb}DESTROYS${nnn}
213${rrr}THIS PROCEDURE ${ddd}DESTROYS${nnn}${rrr} THE CONTENTS OF THE HARD DISK.${nnn}
214               ${ddb}DESTROYS${nnn}
215
216IF YOU DO NOT WISH TO CONTINUE, REBOOT NOW.
217
218************************************************************
219
220EOF
221    echo "Installing autoinstall preseed file."
222    egrep -v '(^$|^#)' < preseed.autoinstall >> preseed
223  else
224    echo "Installing autoinstall preseed file without automated partitioning."
225    egrep -v '(^$|^#|partman)' < preseed.autoinstall >> preseed
226  fi
227fi
228
229# Shovel in the generically useful preseed stuff regardless.
230egrep -v '(^$|^#)' < preseed.common >> preseed
231
232if [ "$IPADDR" ] ; then
233  # ...and the specified network config.
234  cat >> preseed <<EOF
235d-i netcfg/get_nameservers string 18.72.0.3
236d-i netcfg/get_ipaddress string $IPADDR
237d-i netcfg/get_netmask string $NETMASK
238d-i netcfg/get_gateway string $GATEWAY
239d-i netcfg/confirm_static boolean true
240EOF
241fi
242
243# Perferred hostname of mirror site
244cat >> preseed <<EOF
245d-i apt-setup/hostname string $mirrorsite
246d-i mirror/http/hostname string $mirrorsite
247EOF
248
249# This is used by the final installer step.
250# A hardcoded number is used as DNS may still be iffy.
251echo "Fetching Debathena postinstaller."
252# 18.92.2.195 = OLD athena10.mit.edu
253# 18.9.60.73 = NEW athena10.mit.edu
254wget http://18.9.60.73/install-debathena.sh
255
256# Let the postinstall know what we are up to.
257echo "$pxetype" > $mp/pxe-install-flag
258
259echo "Initial Debathena installer complete; exiting preconfig to start main install."
260if ! [ "$clusteraddr" -a "$clusterforce" = yes ] ; then
261  echo "Hit return to continue."
262  read r
263fi
264exit 0
Note: See TracBrowser for help on using the repository browser.