[25147] | 1 | #!/bin/sh |
---|
| 2 | |
---|
[25452] | 3 | # Sigh. check-missing-firmware is too stupid to reconfigure the NIC after |
---|
| 4 | # removing and reloading the module. So we lose network in the middle |
---|
| 5 | # of the install. The card works just fine without firmware, so we |
---|
| 6 | # just convince hwdetect and friends that there is no missing firmware. |
---|
| 7 | # NOTE: Although the nic-firmware udeb does not include the Realtek |
---|
| 8 | # firmware, shipping the firmware ourselves does not fix the problem, |
---|
| 9 | # because check-missing-firmware still insists on reloading the module |
---|
| 10 | # and we lose the network configuration. |
---|
| 11 | if grep -q "^Vostro 320" /sys/class/dmi/id/product_name || lsmod | grep -q r8169; then |
---|
[25454] | 12 | # This will break if the firmware eventually wants to live somewhere else |
---|
| 13 | # This is possibly a bad idea if there are r8169-based cards that do need |
---|
| 14 | # firmware, but if they do, it's not likely they made it this far in the |
---|
| 15 | # installation process. |
---|
| 16 | rm -f /dev/.udev/firmware-missing/rtl_nic* |
---|
[25352] | 17 | fi |
---|
| 18 | |
---|
[25147] | 19 | cd /debathena |
---|
| 20 | |
---|
| 21 | touch preseed |
---|
| 22 | |
---|
| 23 | pxetype="" |
---|
| 24 | |
---|
| 25 | # Using debconf here will hang, so parse the command line manually. |
---|
| 26 | # old options: |
---|
| 27 | # debathena/clusterforce: implies pxetype=cluster, don't recheck net |
---|
| 28 | # debathena/clusteraddr: address to use with above |
---|
| 29 | # new options: |
---|
| 30 | # debathena/pxetype: could be cluster, but could be other things |
---|
| 31 | |
---|
[25405] | 32 | # support for clusteraddr should be removed sometime in Spring 2012 |
---|
| 33 | # Be sure to remove the conditional around line 115 too. |
---|
[25147] | 34 | clusteraddr=`sed -e 's/ /\n/g' < /proc/cmdline | grep debathena/clusteraddr | sed -e 's/.*=//'` |
---|
[25405] | 35 | pxetype=`sed -e 's/ /\n/g' < /proc/cmdline | grep da/pxe= | sed -e 's/.*=//'` |
---|
| 36 | if [ -z "$pxetype" ]; then |
---|
| 37 | # Fallback to old-style option for very old machines that haven't |
---|
| 38 | # updated. This conditional should be removed sometime in Spring 2012 |
---|
| 39 | pxetype=`sed -e 's/ /\n/g' < /proc/cmdline | grep debathena/pxetype | sed -e 's/.*=//'` |
---|
| 40 | fi |
---|
| 41 | installertype=`sed -e 's/ /\n/g' < /proc/cmdline | grep da/i= | sed -e 's/.*=//'` |
---|
| 42 | mirrorsite=`sed -e 's/ /\n/g' < /proc/cmdline | grep da/m= | sed -e 's/.*=//'` |
---|
| 43 | partitioning=`sed -e 's/ /\n/g' < /proc/cmdline | grep da/part= | sed -e 's/.*=//'` |
---|
[25232] | 44 | nodhcp=`sed -e 's/ /\n/g' < /proc/cmdline | grep netcfg/disable_dhcp= | sed -e 's/.*=//'` |
---|
[25147] | 45 | |
---|
[25232] | 46 | |
---|
[25155] | 47 | echo "Picked up values from command line: |
---|
| 48 | clusteraddr=$clusteraddr |
---|
| 49 | pxetype=$pxetype |
---|
| 50 | installertype=$installertype |
---|
| 51 | mirrorsite=$mirrorsite" |
---|
| 52 | |
---|
[25229] | 53 | # Apply some sane defaults |
---|
| 54 | if [ -z "$installertype" ]; then installertype=production ; fi |
---|
| 55 | if [ -z "$mirrorsite" ]; then mirrorsite="mirrors.mit.edu" ; fi |
---|
| 56 | |
---|
| 57 | # Sanity check |
---|
| 58 | if [ -z "$pxetype" ]; then |
---|
[25405] | 59 | echo "ERROR: No pxetype on the command line." |
---|
[25229] | 60 | echo "Cannot proceed. Reboot now, please." |
---|
| 61 | read dummy |
---|
| 62 | fi |
---|
| 63 | |
---|
| 64 | |
---|
[25147] | 65 | netconfig () { |
---|
| 66 | echo "Configuring network..." |
---|
| 67 | mp=/debathena |
---|
| 68 | export IPADDR NETMASK GATEWAY SYSTEM CONTROL |
---|
| 69 | while [ -z "$IPADDR" ] ; do |
---|
| 70 | echo -n "Enter IP address: " |
---|
| 71 | read IPADDR |
---|
| 72 | done |
---|
| 73 | NETMASK=`$mp/athena/netparams -f $mp/athena/masks $IPADDR|cut -d\ -f 1` |
---|
| 74 | net=`$mp/athena/netparams -f $mp/athena/masks $IPADDR|cut -d\ -f 2` |
---|
| 75 | bc=`$mp/athena/netparams -f $mp/athena/masks $IPADDR|cut -d\ -f 3` |
---|
| 76 | GATEWAY=`$mp/athena/netparams -f $mp/athena/masks $IPADDR|cut -d\ -f 4` |
---|
| 77 | maskbits=`$mp/athena/netparams -f $mp/athena/masks $IPADDR|cut -d\ -f 5` |
---|
| 78 | |
---|
| 79 | echo "Address: $IPADDR" |
---|
| 80 | echo |
---|
| 81 | echo "Autoconfigured settings:" |
---|
| 82 | echo " Netmask bits: $maskbits" |
---|
| 83 | echo " Broadcast: $bc" |
---|
| 84 | echo " Gateway: $GATEWAY" |
---|
| 85 | |
---|
| 86 | echo "Killing dhcp client." |
---|
| 87 | killall dhclient |
---|
| 88 | echo "Running: ip addr flush dev eth0" |
---|
| 89 | ip addr flush dev eth0 |
---|
| 90 | echo "Running: ip addr add $IPADDR/$maskbits broadcast $bc dev eth0" |
---|
| 91 | ip addr add $IPADDR/$maskbits broadcast $bc dev eth0 |
---|
| 92 | echo "Flushing old default route." |
---|
| 93 | route delete default 2> /dev/null |
---|
| 94 | echo "Running: route add default gw $GATEWAY" |
---|
| 95 | route add default gw $GATEWAY |
---|
| 96 | echo "Replacing installer DHCP nameserver with MIT nameservers." |
---|
| 97 | sed -e '/nameserver/s/ .*/ 18.72.0.3/' < /etc/resolv.conf > /etc/resolv.conf.new |
---|
| 98 | echo "nameserver 18.70.0.160" >> /etc/resolv.conf.new |
---|
| 99 | echo "nameserver 18.71.0.151" >> /etc/resolv.conf.new |
---|
| 100 | mv -f /etc/resolv.conf.new /etc/resolv.conf |
---|
[25248] | 101 | echo "Saving preseed netcfg values" |
---|
| 102 | cat >> preseed <<EOF |
---|
| 103 | d-i netcfg/get_nameservers string 18.72.0.3 |
---|
| 104 | d-i netcfg/get_ipaddress string $IPADDR |
---|
| 105 | d-i netcfg/get_netmask string $NETMASK |
---|
| 106 | d-i netcfg/get_gateway string $GATEWAY |
---|
| 107 | d-i netcfg/confirm_static boolean true |
---|
| 108 | EOF |
---|
[25147] | 109 | } |
---|
| 110 | |
---|
| 111 | # Color strings. I'd like to use tput, but the installer doesn't have it. |
---|
| 112 | esc="" |
---|
| 113 | nnn="${esc}[m" # Normal |
---|
| 114 | ccc="${esc}[36m" # Cyan |
---|
| 115 | rrr="${esc}[1;31m" # Bold and red |
---|
| 116 | ddd="${esc}[1;31;47m" # Plus gray background |
---|
| 117 | ddb="${esc}[1;31;47;5m" # Plus blinking |
---|
| 118 | |
---|
[25232] | 119 | # OK, we can arrive at this point in the installer through two |
---|
| 120 | # ways: from the stage1 installer or from athena-auto-upgrade |
---|
| 121 | # Anything else is an error and will not be supported. |
---|
| 122 | # The stage1 installer takes care of sanity-checking networking |
---|
| 123 | # so if we have a DHCP address here, it's either valid, or we got here |
---|
| 124 | # from an old athena-auto-upgrade that doesn't do full networking. |
---|
[25147] | 125 | |
---|
[25232] | 126 | if [ -n "$clusteraddr" ] && [ "$nodhcp" != "true" ]; then |
---|
| 127 | IPADDR=$clusteraddr |
---|
| 128 | netconfig |
---|
[25248] | 129 | else |
---|
| 130 | # We're not running netconfig here, but install-debathena.sh still |
---|
| 131 | # uses the information from the preseed. So convert information from |
---|
| 132 | # the kernel command line to the preseed file format. |
---|
| 133 | sed "s/ /\n/g" < /proc/cmdline | grep "^netcfg" | sed -e "s/^/d-i /" -e "s/=/ string /" >> preseed |
---|
[25247] | 134 | fi |
---|
[25232] | 135 | |
---|
| 136 | # We're at a point in the install process where we can be fairly sure |
---|
| 137 | # that nothing else is happening, so "killall wget" should be safe. |
---|
| 138 | (sleep 5; killall wget >/dev/null 2>&1) & |
---|
| 139 | if wget -s http://$mirrorsite/ubuntu ; then |
---|
| 140 | if ip address show to 18.0.0.0/8 | grep -q . && ! ip address show to 18.2.0.0/16 | grep -q . ; then |
---|
| 141 | echo "Network config checks out. Proceeding..." |
---|
[25147] | 142 | else |
---|
[25232] | 143 | echo "Your computer seems not to be registered on MITnet, but the mirror" |
---|
| 144 | echo "site $mirrorsite is accessible. Continuing anyway." |
---|
[25147] | 145 | fi |
---|
| 146 | else |
---|
[25232] | 147 | echo "${rrr}The mirror site $mirrorsite is NOT accessible in your current" |
---|
| 148 | echo "network configuration. Cannot continue." |
---|
| 149 | echo "Reboot now." |
---|
| 150 | read dummy |
---|
[25147] | 151 | fi |
---|
| 152 | |
---|
[25232] | 153 | # Perferred hostname of mirror site |
---|
| 154 | # We want this here even for vanilla installs |
---|
| 155 | cat >> preseed <<EOF |
---|
| 156 | d-i apt-setup/hostname string $mirrorsite |
---|
| 157 | d-i mirror/http/hostname string $mirrorsite |
---|
[25342] | 158 | d-i mirror/country string manual |
---|
| 159 | d-i mirror/http/directory string /ubuntu |
---|
| 160 | d-i mirror/http/proxy string |
---|
[25232] | 161 | EOF |
---|
| 162 | |
---|
[25229] | 163 | if [ vanilla = "$pxetype" ] ; then |
---|
[25147] | 164 | echo "Starting normal Ubuntu install in five seconds." |
---|
| 165 | sleep 5 |
---|
| 166 | exit 0 |
---|
| 167 | fi |
---|
| 168 | |
---|
| 169 | if [ cluster = "$pxetype" ]; then |
---|
[25405] | 170 | if [ "$partitioning" != "manual" ]; then |
---|
[25147] | 171 | cat << EOF |
---|
| 172 | ************************************************************ |
---|
| 173 | ${ddb}DESTROYS${nnn} |
---|
| 174 | ${rrr}THIS PROCEDURE ${ddd}DESTROYS${nnn}${rrr} THE CONTENTS OF THE HARD DISK.${nnn} |
---|
| 175 | ${ddb}DESTROYS${nnn} |
---|
| 176 | |
---|
| 177 | IF YOU DO NOT WISH TO CONTINUE, REBOOT NOW. |
---|
| 178 | |
---|
| 179 | ************************************************************ |
---|
| 180 | |
---|
| 181 | EOF |
---|
| 182 | echo "Installing autoinstall preseed file." |
---|
| 183 | egrep -v '(^$|^#)' < preseed.autoinstall >> preseed |
---|
| 184 | else |
---|
| 185 | echo "Installing autoinstall preseed file without automated partitioning." |
---|
| 186 | egrep -v '(^$|^#|partman)' < preseed.autoinstall >> preseed |
---|
| 187 | fi |
---|
| 188 | fi |
---|
| 189 | |
---|
| 190 | # Shovel in the generically useful preseed stuff regardless. |
---|
| 191 | egrep -v '(^$|^#)' < preseed.common >> preseed |
---|
| 192 | |
---|
| 193 | |
---|
| 194 | # This is used by the final installer step. |
---|
| 195 | # A hardcoded number is used as DNS may still be iffy. |
---|
| 196 | echo "Fetching Debathena postinstaller." |
---|
| 197 | # 18.92.2.195 = OLD athena10.mit.edu |
---|
| 198 | # 18.9.60.73 = NEW athena10.mit.edu |
---|
| 199 | if [ "$installertype" = "beta" ]; then |
---|
| 200 | wget http://18.9.60.73/install-debathena.beta.sh |
---|
| 201 | mv install-debathena.beta.sh install-debathena.sh |
---|
| 202 | else |
---|
| 203 | wget http://18.9.60.73/install-debathena.sh |
---|
| 204 | fi |
---|
| 205 | |
---|
| 206 | # Let the postinstall know what we are up to. |
---|
[25242] | 207 | echo "$pxetype" > pxe-install-flag |
---|
[25147] | 208 | |
---|
| 209 | echo "Initial Debathena installer complete; exiting preconfig to start main install." |
---|
[25250] | 210 | if [ "$pxetype" != "cluster" ] || [ "$installertype" = "beta" ]; then |
---|
[25147] | 211 | echo "Hit return to continue." |
---|
| 212 | read r |
---|
[25250] | 213 | fi |
---|
[25147] | 214 | exit 0 |
---|