source: trunk/debathena/scripts/installer/pxe/karmic/debathena-karmic/installer.sh @ 24304

Revision 24304, 8.3 KB checked in by amb, 15 years ago (diff)
Switch default upstream repo to mirrors.mit.edu.
Line 
1#!/bin/sh
2
3cd /debathena-karmic
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-karmic
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.10${nnn} (Karmic Koala)."
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      echo "Choose one of the above, please.";;
140  esac
141done
142
143##############################################################################
144
145if [ -z "$mirrorsite" ] ; then mirrorsite=mirrors.mit.edu ; fi
146
147# Consider setting a static IP address, especially if we can't reach the mirror.
148if [ cluster != $pxetype ]; then
149  # We're at a point in the install process where we can be fairly sure
150  # that nothing else is happening, so "killall wget" should be safe.
151  (sleep 5; killall wget >/dev/null 2>&1) &
152  if wget -s http://$mirrorsite/ubuntu ; then
153    if ip address show to 18/8 | grep -q . && ! ip address show to 18.2/16 | grep -q . ; then
154      echo "Your computer seems to be registered on MITnet."
155    else
156      echo "Your computer seems not to be registered on MITnet, but the mirror"
157      echo "site $mirrorsite is accessible."
158    fi
159    echo
160    echo "${ccc}You can continue the install using your existing dynamic address.${nnn}"
161    echo -n "Configure a static address anyway?  [y/N]: "
162    while : ; do
163      read r
164      case "$r" in
165        N*|n*|"") break;;
166        y*|Y*) netconfig; break;;
167      esac
168      echo -n "Choose: [y/N]: "
169    done
170  else
171    echo "The mirror site $mirrorsite is NOT accessible in your current"
172    echo "dynamic configuration."
173    echo
174    echo "${rrr}You must specify a static address for the installation.${nnn}"
175    netconfig
176  fi
177else
178  netconfig
179fi
180
181if [ vanilla = $pxetype ] ; then
182  echo "Starting normal Ubuntu install in five seconds."
183  sleep 5
184  exit 0
185fi
186
187if [ cluster = "$pxetype" ]; then
188  if [ notreally != "$destroys" ]; then
189    cat << EOF
190************************************************************
191               ${ddb}DESTROYS${nnn}
192${rrr}THIS PROCEDURE ${ddd}DESTROYS${nnn}${rrr} THE CONTENTS OF THE HARD DISK.${nnn}
193               ${ddb}DESTROYS${nnn}
194
195IF YOU DO NOT WISH TO CONTINUE, REBOOT NOW.
196
197************************************************************
198
199EOF
200    echo "Installing autoinstall preseed file."
201    egrep -v '(^$|^#)' < preseed.autoinstall >> preseed
202  else
203    echo "Installing autoinstall preseed file without automated partitioning."
204    egrep -v '(^$|^#|partman)' < preseed.autoinstall >> preseed
205  fi
206fi
207
208# Shovel in the generically useful preseed stuff regardless.
209egrep -v '(^$|^#)' < preseed.common >> preseed
210
211if [ "$IPADDR" ] ; then
212  # ...and the specified network config.
213  cat >> preseed <<EOF
214d-i netcfg/get_nameservers string 18.72.0.3
215d-i netcfg/get_ipaddress string $IPADDR
216d-i netcfg/get_netmask string $NETMASK
217d-i netcfg/get_gateway string $GATEWAY
218d-i netcfg/confirm_static boolean true
219EOF
220fi
221
222# Perferred hostname of mirror site
223cat >> preseed <<EOF
224d-i apt-setup/hostname string $mirrorsite
225d-i mirror/http/hostname string $mirrorsite
226EOF
227
228# This is used by the final installer step.
229# A hardcoded number is used as DNS may still be iffy.
230echo "Fetching Debathena postinstaller."
231# 18.92.2.195 = OLD athena10.mit.edu
232# 18.9.60.73 = NEW athena10.mit.edu
233wget http://18.9.60.73/install-debathena.sh
234
235# Let the postinstall know what we are up to.
236echo "$pxetype" > $mp/pxe-install-flag
237
238echo "Initial Debathena installer complete; exiting preconfig to start main install."
239if ! [ "$clusteraddr" -a "$clusterforce" = yes ] ; then
240  echo "Hit return to continue."
241  read r
242fi
243exit 0
Note: See TracBrowser for help on using the repository browser.