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

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