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

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