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

Revision 23912, 6.8 KB checked in by amb, 15 years ago (diff)
...set the preferred mirror in the other place, too. (Though arguably we shouldn't force this for non-cluster installs as we do now.)
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    2)
112      echo "Normal Debathena install it is."; pxetype=choose ;;
113    3)
114      echo "Vanilla Ubuntu it is."; pxetype=vanilla;;
115    4)
116      echo "Here's a shell.  You'll return to this prompt when done."
117      /bin/sh;;
118    *)
119      echo "Choose one of the above, please.";;
120  esac
121done
122
123##############################################################################
124
125if [ vanilla = $pxetype ] ; then
126  echo "WARNING: if you let the system default to using a DHCP address, this"
127  echo "may not work for you, as you won't be able to reach the off-campus"
128  echo "Ubuntu repositories.  If you cancelled that and configured manually,"
129  echo "or otherwise believe you have a functional address, you can continue."
130  echo "Would you like to configure a static address before switching back to"
131  echo -n "a vanilla Ubuntu install?  [y/N]: "
132  while : ; do
133    read r
134    case "$r" in
135      N*|n*|"") break;;
136      y*|Y*) netconfig; break;;
137    esac
138    echo -n "Choose: [y/N]: "
139  done
140
141  echo "Starting normal Ubuntu install in five seconds."
142  sleep 5
143  exit 0
144fi
145
146if [ cluster = $pxetype ] ; then
147  cat << EOF
148
149************************************************************
150               ${ddb}DESTROYS${nnn}
151${rrr}THIS PROCEDURE ${ddd}DESTROYS${nnn}${rrr} THE CONTENTS OF THE HARD DISK.${nnn}
152               ${ddb}DESTROYS${nnn}
153
154IF YOU DO NOT WISH TO CONTINUE, REBOOT NOW.
155
156************************************************************
157
158EOF
159  echo "Installing autoinstall preseed file."
160  egrep -v '(^$|^#)' < preseed.autoinstall >> preseed
161fi
162
163# Set up a usable static network config, since the DHCP address is not very useful.
164netconfig
165
166# Shovel in the generically useful preseed stuff regardless.
167egrep -v '(^$|^#)' < preseed.common >> preseed
168# ...and the specified network config.
169cat >> preseed <<EOF
170d-i netcfg/get_nameservers string 18.72.0.3
171d-i netcfg/get_ipaddress string $IPADDR
172d-i netcfg/get_netmask string $NETMASK
173d-i netcfg/get_gateway string $GATEWAY
174d-i netcfg/confirm_static boolean true
175EOF
176
177if [ -z "$mirrorsite" ] ; then mirrorsite=ubuntu.media.mit.edu ; fi
178
179# Perferred hostname of mirror site
180cat >> preseed <<EOF
181d-i apt-setup/hostname string $mirrorsite
182d-i mirror/http/hostname string $mirrorsite
183EOF
184
185# This is used by the final installer step.
186# A hardcoded number is used as DNS may still be iffy.
187echo "Fetching Debathena postinstaller."
188# 18.92.2.195 = OLD athena10.mit.edu
189# 18.9.60.73 = NEW athena10.mit.edu
190wget http://18.9.60.73/install-debathena.sh
191
192# Let the postinstall know what we are up to.
193echo "$pxetype" > $mp/pxe-install-flag
194
195echo "Initial Debathena installer complete; exiting preconfig to start main install."
196if ! [ "$clusteraddr" -a "$clusterforce" = yes ] ; then
197  echo "Hit return to continue."
198  read r
199fi
200exit 0
Note: See TracBrowser for help on using the repository browser.