source: trunk/debathena/scripts/installer/install-debathena.beta.sh @ 25492

Revision 25492, 15.5 KB checked in by jdreed, 12 years ago (diff)
- Wording tweak in beta warning message - Move PXE test earlier in script - Don't interact with the user if you're installing cluster
Line 
1#!/bin/sh
2# Athena installer script.
3# Maintainer: debathena@mit.edu
4# Based on original Debathena installer script by: Tim Abbott <tabbott@mit.edu>
5
6# Download this to a Debian or Ubuntu machine and run it as root.  It can
7# be downloaded with:
8#   wget -N http://debathena.mit.edu/install-debathena.sh
9
10set -e
11
12# If we run with the noninteractive frontend, mark Debconf questions as
13# seen, so you don't see all the suppressed questions next time you
14# upgrade that package, or worse, upgrade releases.
15export DEBCONF_NONINTERACTIVE_SEEN=true
16export DEBIAN_FRONTEND=noninteractive
17
18output() {
19  printf '\033[38m'; echo "$@"; printf '\033[0m'
20}
21
22error() {
23  printf '\033[31m'; echo "$@"; printf '\033[0m'
24}
25
26ask() {
27  answer=''
28  while [ y != "$answer" -a n != "$answer" ]; do
29    printf '\033[38m'; echo -n "$1"; printf '\033[0m'
30    read answer
31    [ Y = "$answer" ] && answer=y
32    [ N = "$answer" ] && answer=n
33    [ -z "$answer" ] && answer=$2
34  done
35  output ""
36}
37
38if [ `id -u` != "0" ]; then
39  error "You must run the Debathena installer as root."
40  if [ -x /usr/bin/sudo ]; then
41    error "Try running 'sudo $0'."
42  fi
43  exit 1
44fi
45
46pxetype=
47if test -f /root/pxe-install-flag ; then
48  pxetype=`head -1 /root/pxe-install-flag`
49fi
50
51have_lsbrelease="$(dpkg-query -W -f '${Status}' lsb-release 2>/dev/null)"
52if [ "$have_lsbrelease" != "install ok installed" ]; then
53  echo "The installer requires the 'lsb-release' package to determine"
54  echo "whether or not installation can proceed."
55  ask "Is it ok to install this package now? [Y/n] " y
56  if [ y = "$answer" ]; then
57    if ! apt-get -qq update && apt-get -qqy install lsb-release; then
58        error "Could not install lsb-release.  Try installing it manually."
59        exit 1
60    fi
61  else
62    error "Sorry, lsb-release is required.  Cannot continue."
63    exit 1
64  fi
65fi
66distro=`lsb_release -cs`
67case $distro in
68  squeeze)
69    ;;
70  hardy|lucid|natty|oneiric)
71    ubuntu=yes
72    ;;
73  precise)
74    ubuntu=yes
75    output "The release you are running ($distro) is not fully supported"
76    output "and installing Debathena on it is probably a bad idea."
77    if ! test -f /root/pxe-install-flag; then
78        ask "Are you sure you want to proceed? [y/N] " n
79        [ y != "$answer" ] && exit 1
80    fi
81    ;;
82  lenny|intrepid|jaunty|karmic|maverick)
83    error "The release you are running is no longer supported."
84    error "Generally, Debathena de-supports releases when they are no longer"
85    error "supported by upstream.  If you believe you received this message"
86    error "in error, please contact debathena@mit.edu."
87    exit 1
88    ;;
89  *)
90    error "Unsupported release codename: $distro"
91    error "Sorry, Debathena does not support installation on this release at this time."
92    error "(New releases may not be supported immediately after their release)."
93    error "If you believe you are running a supported release or have questions,"
94    error "please contact debathena@mit.edu"
95    exit 1
96    ;;
97esac
98
99laptop=no
100wifi=no
101if [ -x /usr/sbin/laptop-detect ] && /usr/sbin/laptop-detect 2>/dev/null; then
102    laptop=yes
103fi
104
105if [ -x /usr/bin/nmcli ] && /usr/bin/nmcli dev status 2>/dev/null | awk '{print $2}' | grep -q 802-11-wireless; then
106    wifi=yes
107fi
108
109echo "Welcome to the Debathena installer."
110echo ""
111echo "Please choose the category which best suits your needs.  Each category"
112echo "in this list includes the functionality of the previous ones.  See the"
113echo "documentation at http://debathena.mit.edu for more information."
114echo ""
115echo "  standard:        Athena client software and customizations"
116echo "                   Recommended for laptops and single-user computers."
117echo "  login:           Allow Athena accounts to log into your machine"
118echo "                   Recommended for private remote-access servers."
119echo "  login-graphical: Athena graphical login customizations"
120echo "                   Recommended for private multi-user desktops."
121echo "  workstation:     Graphical workstation with automatic updates"
122echo "                   Recommended for auto-managed cluster-like systems."
123echo ""
124
125if [ "$laptop" = "yes" ] || [ "$wifi" = "yes" ]; then
126    cat <<EOF
127This machine appears to be a laptop or has at least one wireless
128network device.  You probably want to choose "standard" unless this
129device will have an uninterrupted network connection.
130EOF
131fi
132
133category=""
134if [ cluster = "$pxetype" ] ; then
135  category=cluster ;
136  echo "PXE cluster install detected, so installing \"cluster\"."
137fi
138while [ standard != "$category" -a login != "$category" -a \
139        login-graphical != "$category" -a workstation != "$category" -a \
140        cluster != "$category" ]; do
141  output -n "Please choose a category or press control-C to abort: "
142  read category
143done
144mainpackage=debathena-$category
145
146csoft=no
147tsoft=no
148resolvconfhack=no
149echo "The extra-software package installs a standard set of software"
150echo "determined to be of interest to MIT users, such as LaTeX.  It is pretty"
151echo "big (several gigabytes, possibly more)."
152echo ""
153echo "Note: This package may include software with additional license terms."
154echo "      By installing it, you are agreeing to the terms of these licenses."
155echo "      For more information, please see http://debathena.mit.edu/licensing"
156echo ""
157if [ cluster = $category -o workstation = $category ] ; then
158  # See Trac #648 and LP:471975
159  resolvconfhack=yes
160  echo "The extra-software package is required for '$category' and will be installed."
161  csoft=yes
162  # Not setting tsoft=yes here; -cluster will pull it in anyway.
163else
164  ask "Do you want the extra-software package [y/N]? " n
165  if [ y = "$answer" ]; then
166    csoft=yes
167  fi
168fi
169if [ yes = "$csoft" ]; then
170    # Preseed an answer to the java license query, which license was already accepted
171    # at install time:
172    echo "sun-java6-bin shared/accepted-sun-dlj-v1-1 boolean true" |debconf-set-selections
173fi
174
175if [ "$(cat /sys/class/dmi/id/product_name)" = "OptiPlex 790" ]; then
176    noacpi=y
177    if [ "$category" != "cluster" ]; then
178        echo
179        echo "The Dell 790 sometimes has problems rebooting.  The best way to"
180        echo "work around this is to pass 'reboot=pci' at boot time."
181        echo "This change will be made in your GRUB (bootloader) configuration."
182        ask "Is it ok to do this now? [Y/n] " y
183        if [ y != "$answer" ]; then
184            noacpi=n
185        fi
186    fi
187    if [ "$noacpi" = "y" ] && ! grep -q "Added by install-debathena.sh to address reboot issues on the Dell 790" /etc/default/grub; then
188        cat >> /etc/default/grub << 'EOF'
189
190# Added by install-debathena.sh to address reboot issues on the Dell 790
191GRUB_CMDLINE_LINUX="reboot=pci $GRUB_CMDLINE_LINUX"
192EOF
193        update-grub
194    fi
195fi
196
197echo "A summary of your choices:"
198echo "  Category: $category"
199echo "  Extra-software package: $csoft"
200echo "  Third-party software package: $tsoft"
201echo ""
202if [ "$pxetype" = "cluster" ] ; then
203  if wget -q http://athena10.mit.edu/installer/installing.txt; then
204     cat installing.txt > /dev/tty6
205     date > /dev/tty6
206     chvt 6
207  fi
208  # Divert the default background and install our own so that failed machines
209  # are more conspicuous
210  echo "Diverting default background..."
211  bgimage=/usr/share/backgrounds/warty-final-ubuntu.png
212  divertedbg=no
213  if dpkg-divert --divert ${bgimage}.debathena --rename $bgimage; then
214      divertedbg=yes
215      if ! wget -N -O $bgimage http://debathena.mit.edu/error-background.png; then
216          echo "Hrm, that didn't work.  Oh well..."
217          dpkg-divert --rename --remove $bgimage
218          divertedbg=no
219      fi
220  fi
221
222  # Setup for package installs in a chrooted immediately-postinstall environment.
223  echo "Setting locale."
224  export LANG
225  . /etc/default/locale
226  echo "LANG set to $LANG."
227  echo "Mounting /proc."
228  mount /proc 2> /dev/null || :
229  # Clear toxic environment settings inherited from the installer.
230  unset DEBCONF_REDIR
231  unset DEBIAN_HAS_FRONTEND
232  if [ cluster = "$pxetype" ] ; then
233    # Network, LVM, and display config that's specific to PXE cluster installs.
234    # If someone is installing -cluster on an already-installed machine, it's
235    # assumed that this config has already happened and shouldn't be stomped on.
236
237    # Configure network based on the preseed file settings, if present.
238    if test -f /root/debathena.preseed ; then
239      # Switch to canonical hostname.
240      ohostname=`cat /etc/hostname`
241      # Hack to avoid installing debconf-get for just this.
242      ipaddr=`grep netcfg/get_ipaddress /root/debathena.preseed|sed -e 's/.* //'`
243      netmask=`grep netcfg/get_netmask /root/debathena.preseed|sed -e 's/.* //'`
244      gateway=`grep netcfg/get_gateway /root/debathena.preseed|sed -e 's/.* //'`
245
246      hostname=`host $ipaddr | \
247          sed 's#^.*domain name pointer \(.*\)$#\1#' | sed 's;\.*$;;' | \
248          tr '[A-Z]' '[a-z]'`
249      if echo $hostname|grep -q "not found" ; then
250        hostname=""
251        printf "\a"; sleep 1 ; printf "\a"; sleep 1 ;printf "\a"
252        echo "The IP address you selected, $ipaddr, does not have an associated"
253        echo "hostname.  Please confirm that you're using the correct address."
254        while [ -z "$hostname" ] ; do
255          echo -n "Enter fully qualified hostname [no default]: "
256          read hostname
257        done
258      fi
259      echo ${hostname%%.*} > /etc/hostname
260      sed -e 's/\(127\.0\.1\.1[         ]*\).*/\1'"$hostname ${hostname%%.*}/" < /etc/hosts > /etc/hosts.new
261      mv -f /etc/hosts.new /etc/hosts
262      if grep -q dhcp /etc/network/interfaces ; then
263        sed -e s/dhcp/static/ < /etc/network/interfaces > /etc/network/interfaces.new
264        echo "  address $ipaddr" >> /etc/network/interfaces.new
265        echo "  netmask $netmask" >> /etc/network/interfaces.new
266        echo "  gateway $gateway" >> /etc/network/interfaces.new
267        echo "  dns-nameservers 18.72.0.3 18.70.0.160 18.71.0.151" >> /etc/network/interfaces.new
268        mv -f /etc/network/interfaces.new /etc/network/interfaces
269      fi
270      hostname ${hostname%%.*}
271    fi
272
273  fi
274else
275  output "Press return to begin or control-C to abort"
276  read dummy
277fi
278
279apt-get update
280
281output "Verifying machine is up to date..."
282pattern='^0 upgraded, 0 newly installed, 0 to remove'
283if ! apt-get --simulate --assume-yes dist-upgrade | grep -q "$pattern"; then
284    if [ -n "$pxetype" ] ; then
285        output "Forcing an upgrade"
286        apt-get --assume-yes dist-upgrade
287    else
288        error "Your system is not up to date.  Proceeding with an install at"
289        error "this time could render your system unusable."
290        error "Please run 'apt-get dist-upgrade' as root or use the GUI update"
291        error "manager to ensure your system is up to date before continuing."
292        error "NOTE: You do NOT need to upgrade to a newer release of Ubuntu",
293        error "you merely need to ensure you have the latest software updates"
294        error "for the current version."
295        exit 1
296    fi
297fi
298
299if ! hash aptitude >/dev/null 2>&1; then
300  output "Installing Debathena installer dependency: aptitude"
301  apt-get -y install aptitude
302fi
303
304output "Installing Debathena installer dependencies: wget and dnsutils"
305aptitude -y install wget dnsutils
306if [ yes = "$resolvconfhack" ]; then
307  output "Installing resolvconf ahead of time"
308  aptitude -y install resolvconf
309fi
310
311if aptitude show openafs-modules-dkms > /dev/null; then
312  openafs_component=" openafs"
313  modules="openafs-modules-dkms"
314fi
315
316output "Adding the Debathena repository to the apt sources"
317output "(This may cause the update manager to claim new upgrades are available."
318output "Ignore them until this script is complete.)"
319sourceslist=/etc/apt/sources.list.d/debathena.list
320clustersourceslist=/etc/apt/sources.list.d/debathena.clusterinfo.list
321if [ -z "$hostname" ] ; then hostname=`hostname` ; fi
322
323if [ ! -e "$sourceslist" ] || ! grep -v ^# "$sourceslist" | grep -q debathena; then
324  if [ -e "$sourceslist" ]; then
325    echo "" >> $sourceslist
326  fi
327  echo "deb http://debathena.mit.edu/apt $distro debathena debathena-config debathena-system$openafs_component" >> $sourceslist
328  echo "deb-src http://debathena.mit.edu/apt $distro debathena debathena-config debathena-system$openafs_component" >> $sourceslist
329fi
330
331# Note that hesiod may contain multiple apt_release tokens.  We want to
332# include known repositories but make no assumptions about wanting
333# others.  (For instances, "development" does @i{not} automatically
334# infer "proposed".)
335hescluster=$(dig +short +bufsize=2048 ${hostname}.cluster.ns.athena.mit.edu TXT) || hescluster=""
336
337aptexplained=false
338for hc in proposed development bleeding; do
339  if echo "$hescluster" | grep -Fxq "\"apt_release $hc\""; then
340    echo "Adding $distro-$hc apt repository."
341    if [ "${aptexplained}" = false ] ; then
342      echo "" >> $clustersourceslist
343      echo "# This file is automatically updated by debathena-auto-update" >> $clustersourceslist
344      echo "# based on your Hesiod cluster information. If you want to" >> $clustersourceslist
345      echo "# make changes, do so in another file." >> $clustersourceslist
346      aptexplained=true
347    fi
348    echo "" >> $clustersourceslist
349    echo "deb http://debathena.mit.edu/apt $distro-${hc} debathena debathena-config debathena-system$openafs_component" >> $clustersourceslist
350    echo "deb-src http://debathena.mit.edu/apt $distro-${hc} debathena debathena-config debathena-system$openafs_component" >> $clustersourceslist
351  fi
352done
353
354if [ "$ubuntu" = "yes" ]; then
355  output "Making sure the universe repository is enabled"
356  sed -i 's,^# \(deb\(\-src\)* http://archive.ubuntu.com/ubuntu [[:alnum:]]* universe\)$,\1,' /etc/apt/sources.list
357fi
358
359output "Downloading the Debathena archive signing key"
360if ! wget -N http://debathena.mit.edu/apt/debathena-archive-keyring.asc ; then
361  error "Download failed; terminating."
362  exit 1
363fi
364echo "fa787714d1ea439c28458aab64962f755e2bdee7a3520919a72b641458757fa3586fd269cc1dae8d99047e00b3df88db0826f0c99a1f5a8771618b3c0be8e3bd  ./debathena-archive-keyring.asc" | \
365  sha512sum -c
366apt-key add debathena-archive-keyring.asc
367rm ./debathena-archive-keyring.asc
368
369apt-get update
370
371if [ -z "$modules" ]; then
372  modules_want=$(dpkg-query -W -f '${Source}\t${Package}\n' 'linux-image-*' | \
373   sed -nre 's/^linux-(meta|latest[^\t]*)\tlinux-image-(.*)$/openafs-modules-\2/p')
374  modules=
375  for m in $modules_want; do
376    aptitude show $m > /dev/null && modules="$modules $m"
377  done
378fi
379
380if [ -z "$modules" ]; then
381  error "An OpenAFS modules metapackage for your kernel is not available."
382  error "Please use the manual installation instructions at"
383  error "http://debathena.mit.edu/install"
384  error "You will need to compile your own AFS modules as described at:"
385  error "http://debathena.mit.edu/troubleshooting#openafs-custom"
386  exit 1
387fi
388
389output "Installing OpenAFS kernel metapackage"
390apt-get -y install $modules
391
392if [ "cluster" = "$category" ] || [ "workstation" = "$category" ] ; then
393    output "Installing debathena-license-config"
394    apt-get -y install debathena-license-config
395fi
396
397# Use the noninteractive frontend to install the main package.  This
398# is so that AFS and Zephyr don't ask questions of the user which
399# debathena packages will later stomp on anyway.
400output "Installing main Debathena metapackage $mainpackage"
401
402aptitude -y install "$mainpackage"
403
404# Use the default front end and allow questions to be asked; otherwise
405# Java will fail to install since it has to present its license.
406if [ yes = "$csoft" ]; then
407  output "Installing debathena-extra-software"
408  DEBIAN_PRIORITY=critical aptitude -y install debathena-extra-software
409fi
410if [ yes = "$tsoft" ]; then
411  output "Installing debathena-thirdparty"
412  DEBIAN_PRIORITY=critical aptitude -y install debathena-thirdparty
413fi
414
415# Post-install cleanup for cluster systems.
416if [ "$divertedbg" = "yes" ]; then
417    rm -f $bgimage
418    if ! dpkg-divert --rename --remove $bgimage; then
419        echo "Failed to remove diversion of background.  You probably don't care."
420    fi
421fi
422
423if [ cluster = "$category" ] ; then
424  # Force an /etc/adjtime entry so there's no confusion about whether the
425  # hardware clock is UTC or local.
426  echo "Setting hardware clock to UTC."
427  hwclock --systohc --utc
428fi
Note: See TracBrowser for help on using the repository browser.