1 | #!/bin/sh |
---|
2 | |
---|
3 | cd /athena10-intrepid |
---|
4 | |
---|
5 | touch preseed |
---|
6 | |
---|
7 | pxetype="" |
---|
8 | |
---|
9 | netconfig () { |
---|
10 | echo "Configuring network..." |
---|
11 | mp=/athena10-intrepid |
---|
12 | export IPADDR NETMASK GATEWAY SYSTEM CONTROL |
---|
13 | while [ -z "$IPADDR" ] ; do |
---|
14 | echo -n "Enter IP address: " |
---|
15 | read IPADDR |
---|
16 | done |
---|
17 | NETMASK=`$mp/athena/netparams -f $mp/athena/masks $IPADDR|cut -d\ -f 1` |
---|
18 | net=`$mp/athena/netparams -f $mp/athena/masks $IPADDR|cut -d\ -f 2` |
---|
19 | bc=`$mp/athena/netparams -f $mp/athena/masks $IPADDR|cut -d\ -f 3` |
---|
20 | GATEWAY=`$mp/athena/netparams -f $mp/athena/masks $IPADDR|cut -d\ -f 4` |
---|
21 | maskbits=`$mp/athena/netparams -f $mp/athena/masks $IPADDR|cut -d\ -f 5` |
---|
22 | |
---|
23 | echo "Autoconfigured settings:" |
---|
24 | echo " Netmask bits: $maskbits" |
---|
25 | echo " Broadcast: $bc" |
---|
26 | echo " Gateway: $GATEWAY" |
---|
27 | echo -n "Are these OK? [Y/n]: "; read response |
---|
28 | case $response in |
---|
29 | y|Y|"") ;; |
---|
30 | *) |
---|
31 | echo -n "Netmask bits [$maskbits]: "; read r; if [ "$r" ] ; then maskbits=$r ; fi |
---|
32 | echo -n "Broadcast [$bc]: "; read r; if [ "$r" ] ; then bc=$r ; fi |
---|
33 | echo -n "Gateway [$GATEWAY]: "; read r; if [ "$r" ] ; then GATEWAY=$r ; fi |
---|
34 | esac |
---|
35 | |
---|
36 | # We can not set the hostname here; running "debconf-set netcfg/get_hostname" |
---|
37 | # causes fatal reentry problems. Setting values directly with preseeding |
---|
38 | # also fails, as the DHCP values override it. |
---|
39 | echo "Killing dhcp client." |
---|
40 | killall dhclient |
---|
41 | echo "Running: ip addr flush dev eth0" |
---|
42 | ip addr flush dev eth0 |
---|
43 | echo "Running: ip addr add $IPADDR/$maskbits broadcast $bc dev eth0" |
---|
44 | ip addr add $IPADDR/$maskbits broadcast $bc dev eth0 |
---|
45 | echo "Flushing old default route." |
---|
46 | route delete default 2> /dev/null |
---|
47 | echo "Running: route add default gw $GATEWAY" |
---|
48 | route add default gw $GATEWAY |
---|
49 | echo "Replacing installer DHCP nameserver with MIT nameservers." |
---|
50 | sed -e '/nameserver/s/ .*/ 18.72.0.3/' < /etc/resolv.conf > /etc/resolv.conf.new |
---|
51 | echo "nameserver 18.70.0.160" >> /etc/resolv.conf.new |
---|
52 | echo "nameserver 18.71.0.151" >> /etc/resolv.conf.new |
---|
53 | mv -f /etc/resolv.conf.new /etc/resolv.conf |
---|
54 | } |
---|
55 | |
---|
56 | |
---|
57 | echo "Welcome to Athena 10." |
---|
58 | echo |
---|
59 | |
---|
60 | while [ -z "$pxetype" ] ; do |
---|
61 | echo "Choose one:" |
---|
62 | echo |
---|
63 | echo " 1: Perform an unattended Athena 10 install, WIPING OUT your ENTIRE DISK." |
---|
64 | echo " This will give you a CLUSTER-style \"public workstation\" setup," |
---|
65 | echo " and you hereby agree with the license terms at:" |
---|
66 | echo " <http://dlc.sun.com/dlj/DLJ-v1.1.txt>," |
---|
67 | echo " Sun's Operating System Distributor License for Java version 1.1." |
---|
68 | echo " 2: Do a normal Athena 10 install. You'll need to answer normal Ubuntu" |
---|
69 | echo " install prompts, and then the Athena-10-specific prompts, including" |
---|
70 | echo " choosing which flavor of Athena 10 you'd like." |
---|
71 | echo " 8: Punt to a completely vanilla install of Ubuntu 8.10 (Intrepid Ibex)" |
---|
72 | echo " (Note: locale and keyboard have already been set.)" |
---|
73 | echo |
---|
74 | echo " 9: /bin/sh (for rescue purposes)" |
---|
75 | echo |
---|
76 | echo -n "Choose: " |
---|
77 | read r |
---|
78 | case "$r" in |
---|
79 | 1) |
---|
80 | echo "Athena 10 CLUSTER it is."; pxetype=cluster ;; |
---|
81 | 2) |
---|
82 | echo "Normal Athena 10 install it is."; pxetype=choose ;; |
---|
83 | 8) |
---|
84 | echo "Vanilla Ubuntu it is."; pxetype=vanilla;; |
---|
85 | 9) |
---|
86 | echo "Here's a shell. You'll return to this prompt when done." |
---|
87 | /bin/sh;; |
---|
88 | *) |
---|
89 | echo "Choose one of the above, please.";; |
---|
90 | esac |
---|
91 | done |
---|
92 | |
---|
93 | ############################################################################## |
---|
94 | |
---|
95 | if [ vanilla = $pxetype ] ; then |
---|
96 | echo "WARNING: if you let the system default to using a DHCP address, this" |
---|
97 | echo "may not work for you, as you won't be able to reach the off-campus" |
---|
98 | echo "Ubuntu repositories. If you cancelled that and configured manually," |
---|
99 | echo "or otherwise believe you have a functional address, you can continue." |
---|
100 | echo "Would you like to configure a static address before switching back to" |
---|
101 | echo -n "a vanilla Ubuntu install? [y/N]: " |
---|
102 | while : ; do |
---|
103 | read r |
---|
104 | case "$r" in |
---|
105 | N*|n*|"") break;; |
---|
106 | y*|Y*) netconfig; break;; |
---|
107 | esac |
---|
108 | echo -n "Choose: [y/N]: " |
---|
109 | done |
---|
110 | |
---|
111 | echo "Starting normal Ubuntu install in five seconds." |
---|
112 | sleep 5 |
---|
113 | exit 0 |
---|
114 | fi |
---|
115 | |
---|
116 | if [ cluster = $pxetype ] ; then |
---|
117 | cat << EOF |
---|
118 | |
---|
119 | ************************************************************ |
---|
120 | DESTROYS |
---|
121 | THIS PROCEDURE DESTROYS THE CONTENTS OF THE HARD DISK. |
---|
122 | DESTROYS |
---|
123 | |
---|
124 | IF YOU DO NOT WISH TO CONTINUE, REBOOT NOW. |
---|
125 | |
---|
126 | ************************************************************ |
---|
127 | |
---|
128 | EOF |
---|
129 | echo "Installing autoinstall preseed file." |
---|
130 | egrep -v '(^$|^#)' < preseed.autoinstall >> preseed |
---|
131 | fi |
---|
132 | |
---|
133 | # Set up a usable static network config, since the DHCP address is not very useful. |
---|
134 | netconfig |
---|
135 | |
---|
136 | # Shovel in the generically useful preseed stuff regardless. |
---|
137 | egrep -v '(^$|^#)' < preseed.common >> preseed |
---|
138 | # ...and the specified network config. |
---|
139 | cat >> preseed <<EOF |
---|
140 | d-i netcfg/get_nameservers string 18.72.0.3 |
---|
141 | d-i netcfg/get_ipaddress string $IPADDR |
---|
142 | d-i netcfg/get_netmask string $NETMASK |
---|
143 | d-i netcfg/get_gateway string $GATEWAY |
---|
144 | d-i netcfg/confirm_static boolean true |
---|
145 | EOF |
---|
146 | |
---|
147 | # This is used by the final installer step. |
---|
148 | # A hardcoded number is used as DNS may still be iffy. |
---|
149 | echo "Fetching Athena 10 postinstaller." |
---|
150 | # 18.92.2.195 = OLD athena10.mit.edu |
---|
151 | # 18.9.60.73 = NEW athena10.mit.edu |
---|
152 | wget http://18.9.60.73/install-debathena.sh |
---|
153 | |
---|
154 | # Let the postinstall know what we are up to. |
---|
155 | echo "$pxetype" > $mp/pxe-install-flag |
---|
156 | |
---|
157 | echo "Initial Athena 10 installer complete; exiting preconfig to start main install." |
---|
158 | echo "Hit return to continue." |
---|
159 | read r |
---|
160 | exit 0 |
---|