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

Revision 24271, 8.5 KB checked in by geofft, 14 years ago (diff)
installer: Add an option to PRESERVE PRESERVE PRESERVE your disk
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 ;;
126    2)
127      echo "Normal Debathena install it is."; pxetype=choose ;;
128    3)
129      echo "Vanilla Ubuntu it is."; pxetype=vanilla;;
130    4)
131      echo "Here's a shell.  You'll return to this prompt when done."
132      /bin/sh;;
133    *)
134      echo "Choose one of the above, please.";;
135  esac
136done
137
138##############################################################################
139
140if [ vanilla = $pxetype ] ; then
141  echo "WARNING: if you let the system default to using a DHCP address, this"
142  echo "may not work for you, as you won't be able to reach the off-campus"
143  echo "Ubuntu repositories.  If you cancelled that and configured manually,"
144  echo "or otherwise believe you have a functional address, you can continue."
145  echo "Would you like to configure a static address before switching back to"
146  echo -n "a vanilla Ubuntu install?  [y/N]: "
147  while : ; do
148    read r
149    case "$r" in
150      N*|n*|"") break;;
151      y*|Y*) netconfig; break;;
152    esac
153    echo -n "Choose: [y/N]: "
154  done
155
156  echo "Starting normal Ubuntu install in five seconds."
157  sleep 5
158  exit 0
159fi
160
161if [ cluster = "$pxetype" ]; then
162  if [ notreally != "$destroys" ]; then
163    cat << EOF
164
165************************************************************
166               ${ddb}DESTROYS${nnn}
167${rrr}THIS PROCEDURE ${ddd}DESTROYS${nnn}${rrr} THE CONTENTS OF THE HARD DISK.${nnn}
168               ${ddb}DESTROYS${nnn}
169
170IF YOU DO NOT WISH TO CONTINUE, REBOOT NOW.
171
172************************************************************
173
174EOF
175    echo "Installing autoinstall preseed file."
176    egrep -v '(^$|^#)' < preseed.autoinstall >> preseed
177  else
178    echo "Installing autoinstall preseed file without automated partitioning."
179    egrep -v '(^$|^#|partman)' < preseed.autoinstall >> preseed
180  fi
181fi
182
183if [ -z "$mirrorsite" ] ; then mirrorsite=ubuntu.media.mit.edu ; fi
184
185# Set up a usable static network config, since the DHCP address is not very useful.
186if [ choose = $pxetype ]; then
187  if ping $mirrorsite ; then
188    if ip address | grep '    inet 18\.' >/dev/null ; then
189      echo "Your computer seems to be registered on MITnet."
190    else
191      echo "Your computer seems not to be registered on MITnet, but the mirror"
192      echo "site $mirrorsite is accessible."
193    fi
194    echo
195    echo "${ccc}You can continue the install using your existing dynamic address.${nnn}"
196    echo -n "Configure a static address anyway?  [y/N]: "
197    while : ; do
198      read r
199      case "$r" in
200        N*|n*|"") break;;
201        y*|Y*) netconfig; break;;
202      esac
203      echo -n "Choose: [y/N]: "
204    done
205  else
206    echo "The mirror site $mirrorsite is NOT accessible in your current"
207    echo "dynamic configuration."
208    echo
209    echo "${rrr}You must specify a static address for the installation.${nnn}"
210    netconfig
211  fi
212else
213  netconfig
214fi
215
216# Shovel in the generically useful preseed stuff regardless.
217egrep -v '(^$|^#)' < preseed.common >> preseed
218
219if [ "$IPADDR" ] ; then
220  # ...and the specified network config.
221  cat >> preseed <<EOF
222d-i netcfg/get_nameservers string 18.72.0.3
223d-i netcfg/get_ipaddress string $IPADDR
224d-i netcfg/get_netmask string $NETMASK
225d-i netcfg/get_gateway string $GATEWAY
226d-i netcfg/confirm_static boolean true
227EOF
228fi
229
230# Perferred hostname of mirror site
231cat >> preseed <<EOF
232d-i apt-setup/hostname string $mirrorsite
233d-i mirror/http/hostname string $mirrorsite
234EOF
235
236# This is used by the final installer step.
237# A hardcoded number is used as DNS may still be iffy.
238echo "Fetching Debathena postinstaller."
239# 18.92.2.195 = OLD athena10.mit.edu
240# 18.9.60.73 = NEW athena10.mit.edu
241wget http://18.9.60.73/install-debathena.sh
242
243# Let the postinstall know what we are up to.
244echo "$pxetype" > $mp/pxe-install-flag
245
246echo "Initial Debathena installer complete; exiting preconfig to start main install."
247if ! [ "$clusteraddr" -a "$clusterforce" = yes ] ; then
248  echo "Hit return to continue."
249  read r
250fi
251exit 0
Note: See TracBrowser for help on using the repository browser.