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

Revision 23831, 9.2 KB checked in by andersk, 15 years ago (diff)
install-debathena.sh: Use wget -N to avoid downloading file.1, file.2, etc.
RevLine 
[23093]1#!/bin/sh
[23492]2# Athena 10 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
12output() {
13  printf '\033[38m'; echo "$@"; printf '\033[0m'
14}
15
16error() {
17  printf '\033[31m'; echo "$@"; printf '\033[0m'
18}
19
20ask() {
21  answer=''
22  while [ y != "$answer" -a n != "$answer" ]; do
23    printf '\033[38m'; echo -n "$1"; printf '\033[0m'
24    read answer
25    [ Y = answer ] && answer=y
26    [ N = answer ] && answer=n
27    [ -z "$answer" ] && answer=$2
28  done
29  output ""
30}
31
32if [ `id -u` != "0" ]; then
[23492]33  error "You must run the Debathena installer as root."
34  exit 1
[23093]35fi
36
[23492]37echo "Welcome to the Debathena installer."
[23093]38echo ""
[23604]39echo "Please choose the category which best suits your needs.  Each category"
[23093]40echo "in this list includes the functionality of the previous ones.  See the"
[23492]41echo "documentation at http://debathena.mit.edu/beta for more information."
[23093]42echo ""
[23678]43echo "  standard:        Athena client software (e.g. discuss) and customizations"
44echo "  login:           Allow Athena users to log into your machine"
45echo "  login-graphical: Athena graphical login customizations"
[23797]46echo "  workstation:     Managed graphical workstation with minimal need for"
47echo "                   manual maintenance"
[23093]48echo ""
49
[23476]50# Hack to deal with the older PXE installer (which used a simple flag file to
51# indicate a PXE cluster install).
[23460]52if test -f /root/unattended-cluster-install ; then
[23476]53  echo cluster > /root/pxe-install-flag
[23460]54fi
[23476]55
56category=""
57if test -f /root/pxe-install-flag ; then
58  pxetype=`head -1 /root/pxe-install-flag`
59  if [ cluster = "$pxetype" ] ; then
[23492]60    category=cluster ;
[23476]61    echo "PXE cluster install detected, so installing \"cluster\"."
62  fi
63fi
[23135]64while [ standard != "$category" -a login != "$category" -a \
[23797]65        login-graphical != "$category" -a workstation != "$category" -a \
66        cluster != "$category" ]; do
[23093]67  output -n "Please choose a category or press control-C to abort: "
68  read category
69done
70mainpackage=debathena-$category
71
[23187]72dev=no
[23093]73echo
[23476]74if [ cluster != $category ] ; then
[23460]75  ask "Will this machine be used to build Debathena packages [y/N]? " n
76  if [ y = "$answer" ]; then
77    dev=yes
78  fi
[23093]79fi
80
[23187]81csoft=no
[23460]82tsoft=no
[23247]83echo "The extra-software package installs a standard set of software"
[23093]84echo "determined to be of interest to MIT users, such as LaTeX.  It is pretty"
[23247]85echo "big (several gigabytes, possibly more)."
[23093]86echo ""
[23478]87if [ cluster = $category ] ; then
[23476]88  echo "Cluster install detected, so installing extras."
[23187]89  csoft=yes
[23469]90  # Not setting tsoft=yes here; -cluster will pull it in anyway.
[23460]91else
92  ask "Do you want the extra-software package [y/N]? " n
93  if [ y = "$answer" ]; then
94    csoft=yes
[23492]95  fi
[23093]96fi
97
98echo "A summary of your choices:"
[23187]99echo "  Category: $category"
100echo "  Debian development package: $dev"
[23247]101echo "  Extra-software package: $csoft"
[23460]102echo "  Third-party software package: $tsoft"
[23093]103echo ""
[23476]104if [ "$pxetype" ] ; then
[23460]105  # Setup for package installs in a chrooted immediately-postinstall environment.
106  echo "Setting locale."
107  export LANG
108  . /etc/default/locale
109  echo "LANG set to $LANG."
110  echo "Mounting /proc."
111  mount /proc 2> /dev/null || :
112  # Clear toxic environment settings inherited from the installer.
113  unset DEBCONF_REDIR
114  unset DEBIAN_HAS_FRONTEND
[23476]115  if [ cluster = "$pxetype" ] ; then
116    # Network, LVM, and display config that's specific to PXE cluster installs.
117    # If someone is installing -cluster on an already-installed machine, it's
118    # assumed that this config has already happened and shouldn't be stomped on.
[23093]119
[23476]120    # Preseed an answer to the java license query, which license was already accepted
121    # at install time:
122    echo "sun-java6-bin shared/accepted-sun-dlj-v1-1 boolean true" |debconf-set-selections
[23460]123
[23479]124    # Configure network based on the preseed file settings, if present.
125    if test -f /root/athena10.preseed ; then
126      # Switch to canonical hostname.
127      ohostname=`cat /etc/hostname`
128      # Hack to avoid installing debconf-get for just this.
129      ipaddr=`grep netcfg/get_ipaddress /root/athena10.preseed|sed -e 's/.* //'`
130      netmask=`grep netcfg/get_netmask /root/athena10.preseed|sed -e 's/.* //'`
131      gateway=`grep netcfg/get_gateway /root/athena10.preseed|sed -e 's/.* //'`
132
133      hostname=`host $ipaddr | \
[23476]134          sed 's#^.*domain name pointer \(.*\)$#\1#' | sed 's;\.*$;;' | \
135          tr '[A-Z]' '[a-z]'`
[23479]136      if echo $hostname|grep -q "not found" ; then
137        hostname=""
138        printf "\a"; sleep 1 ; printf "\a"; sleep 1 ;printf "\a"
139        echo "The IP address you selected, $ipaddr, does not have an associated"
140        echo "hostname.  Please confirm that you're using the correct address."
141        while [ -z "$hostname" ] ; do
142          echo -n "Enter fully qualified hostname [no default]: "
143          read hostname
144        done
145      fi
146      echo ${hostname%%.*} > /etc/hostname
147      sed -e 's/\(127\.0\.1\.1[         ]*\).*/\1'"$hostname ${hostname%%.*}/" < /etc/hosts > /etc/hosts.new
148      mv -f /etc/hosts.new /etc/hosts
149      if grep -q dhcp /etc/network/interfaces ; then
150        sed -e s/dhcp/static/ < /etc/network/interfaces > /etc/network/interfaces.new
151        echo "  address $ipaddr" >> /etc/network/interfaces.new
152        echo "  netmask $netmask" >> /etc/network/interfaces.new
153        echo "  gateway $gateway" >> /etc/network/interfaces.new
154        mv -f /etc/network/interfaces.new /etc/network/interfaces
155      fi
156      hostname ${hostname%%.*}
[23476]157    fi
[23479]158
[23476]159    # Free up designated LVM overhead.
160    lvremove -f /dev/athena10/keep_2 || :
161
162    # This makes gx755s suck less.
163    if lspci -n|grep -q 1002:94c1 && ! grep -q radeonhd /etc/X11/xorg.conf ; then
[23479]164      DEBIAN_FRONTEND=noninteractive aptitude -y install xserver-xorg-video-radeonhd
[23476]165      cat >> /etc/X11/xorg.conf <<EOF
[23460]166Section "Device"
167        Identifier "Configured Video Device"
168        Driver "radeonhd"
169EndSection
170EOF
[23476]171    fi
[23460]172  fi
173else
174  output "Press return to begin or control-C to abort"
175  read dummy
176fi
177
[23093]178output "Installing lsb-release to determine system type"
179aptitude -y install lsb-release
180distro=`lsb_release -cs`
181case $distro in
[23591]182etch|lenny|squeeze)
[23093]183  ;;
[23753]184hardy|intrepid|jaunty)
[23093]185  ubuntu=yes
186  ;;
187*)
188  error "Your machine seems to not be running a current Debian/Ubuntu release."
[23492]189  error "If you believe you are running a current release, contact debathena@mit.edu"
190  exit 1
[23093]191  ;;
192esac
193
[23492]194output "Adding the Debathena repository to the apt sources"
195output "(This may cause the update manager to claim new upgrades are available."
196output "Ignore them until this script is complete.)"
[23093]197if [ -d /etc/apt/sources.list.d ]; then
198  sourceslist=/etc/apt/sources.list.d/debathena.list
199else
[23492]200  # dapper is the only "current" platform that doesn't support sources.list.d
[23093]201  sourceslist=/etc/apt/sources.list
202fi
203
204if [ ! -e "$sourceslist" ] || ! grep -q debathena "$sourceslist"; then
205  if [ -e "$sourceslist" ]; then
206    echo "" >> $sourceslist
207  fi
[23517]208  echo "deb http://debathena.mit.edu/apt $distro debathena debathena-config debathena-system openafs" >> $sourceslist
209  echo "deb-src http://debathena.mit.edu/apt $distro debathena debathena-config debathena-system openafs" >> $sourceslist
[23093]210fi
211
212if [ "$ubuntu" = "yes" ]; then
213  output "Making sure the universe repository is enabled"
214  sed -i 's,^# \(deb\(\-src\)* http://archive.ubuntu.com/ubuntu [[:alnum:]]* universe\)$,\1,' /etc/apt/sources.list
215fi
216
[23492]217output "Downloading the Debathena archive signing key"
[23831]218if ! wget -N http://debathena.mit.edu/apt/debathena-archive-keyring.asc ; then
[23492]219  error "Download failed; terminating."
[23093]220  exit 1
221fi
[23817]222echo "6334cf7272423247f3693a3fef771c8274860b26  ./debathena-archive-keyring.asc" | \
[23093]223  sha1sum -c
[23500]224apt-key add debathena-archive-keyring.asc
225rm ./debathena-archive-keyring.asc
[23093]226
227apt-get update
228
229modules_want=$(dpkg-query -W -f '${Source}\t${Package}\n' 'linux-image-*' | \
230 sed -nre 's/^linux-(meta|latest[^\t]*)\tlinux-image-(.*)$/openafs-modules-\2/p')
231modules=
232for m in $modules_want; do
233  aptitude show $m > /dev/null && modules="$modules $m"
234done
235
236if [ -z "$modules" ]; then
237  error "An OpenAFS modules metapackage for your kernel is not available."
[23492]238  error "Please use the manual installation instructions at"
239  error "http://debathena.mit.edu/beta/install"
240  error "You will need to compile your own AFS modules as described at:"
241  error "http://debathena.mit.edu/beta/troubleshooting#openafs-custom"
242  exit 1
[23093]243fi
244
245output "Installing OpenAFS kernel metapackage"
246apt-get -y install $modules
247
[23187]248# Use the noninteractive frontend to install the main package.  This
249# is so that AFS and Zephyr don't ask questions of the user which
250# debathena packages will later stomp on anyway.
[23492]251output "Installing main Debathena metapackage $mainpackage"
[23460]252
[23187]253DEBIAN_FRONTEND=noninteractive aptitude -y install "$mainpackage"
254
255# This package is relatively small so it's not as important, but allow
256# critical questions to be asked.
257if [ yes = "$dev" ]; then
258  output "Installing debathena-build-depends"
259  DEBIAN_PRIORITY=critical aptitude -y install debathena-build-depends
260fi
261
262# Use the default front end and allow questions to be asked; otherwise
263# Java will fail to install since it has to present its license.
264if [ yes = "$csoft" ]; then
[23247]265  output "Installing debathena-extra-software"
266  DEBIAN_PRIORITY=critical aptitude -y install debathena-extra-software
[23187]267fi
[23460]268if [ yes = "$tsoft" ]; then
269  output "Installing debathena-thirdparty"
270  DEBIAN_PRIORITY=critical aptitude -y install debathena-thirdparty
271fi
Note: See TracBrowser for help on using the repository browser.