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

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