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

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