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.
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
[23946]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
[23093]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
[23492]38  error "You must run the Debathena installer as root."
39  exit 1
[23093]40fi
41
[23492]42echo "Welcome to the Debathena installer."
[23093]43echo ""
[23604]44echo "Please choose the category which best suits your needs.  Each category"
[23093]45echo "in this list includes the functionality of the previous ones.  See the"
[23492]46echo "documentation at http://debathena.mit.edu/beta for more information."
[23093]47echo ""
[23678]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"
[23797]51echo "  workstation:     Managed graphical workstation with minimal need for"
52echo "                   manual maintenance"
[23093]53echo ""
54
[23476]55# Hack to deal with the older PXE installer (which used a simple flag file to
56# indicate a PXE cluster install).
[23460]57if test -f /root/unattended-cluster-install ; then
[23476]58  echo cluster > /root/pxe-install-flag
[23460]59fi
[23476]60
61category=""
62if test -f /root/pxe-install-flag ; then
63  pxetype=`head -1 /root/pxe-install-flag`
64  if [ cluster = "$pxetype" ] ; then
[23492]65    category=cluster ;
[23476]66    echo "PXE cluster install detected, so installing \"cluster\"."
67  fi
68fi
[23135]69while [ standard != "$category" -a login != "$category" -a \
[23797]70        login-graphical != "$category" -a workstation != "$category" -a \
71        cluster != "$category" ]; do
[23093]72  output -n "Please choose a category or press control-C to abort: "
73  read category
74done
75mainpackage=debathena-$category
76
[23187]77dev=no
[23093]78echo
[23476]79if [ cluster != $category ] ; then
[23460]80  ask "Will this machine be used to build Debathena packages [y/N]? " n
81  if [ y = "$answer" ]; then
82    dev=yes
83  fi
[23093]84fi
85
[23187]86csoft=no
[23460]87tsoft=no
[23247]88echo "The extra-software package installs a standard set of software"
[23093]89echo "determined to be of interest to MIT users, such as LaTeX.  It is pretty"
[23247]90echo "big (several gigabytes, possibly more)."
[23093]91echo ""
[23872]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 ""
[23478]96if [ cluster = $category ] ; then
[23476]97  echo "Cluster install detected, so installing extras."
[23187]98  csoft=yes
[23469]99  # Not setting tsoft=yes here; -cluster will pull it in anyway.
[23460]100else
101  ask "Do you want the extra-software package [y/N]? " n
102  if [ y = "$answer" ]; then
103    csoft=yes
[23492]104  fi
[23093]105fi
[23876]106if [ yes = "$csoft" ]; then
[23872]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
[23093]111
112echo "A summary of your choices:"
[23187]113echo "  Category: $category"
114echo "  Debian development package: $dev"
[23247]115echo "  Extra-software package: $csoft"
[23460]116echo "  Third-party software package: $tsoft"
[23093]117echo ""
[23476]118if [ "$pxetype" ] ; then
[23460]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
[23476]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.
[23093]133
[23479]134    # Configure network based on the preseed file settings, if present.
[23867]135    if test -f /root/debathena.preseed ; then
[23479]136      # Switch to canonical hostname.
137      ohostname=`cat /etc/hostname`
138      # Hack to avoid installing debconf-get for just this.
[23875]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/.* //'`
[23479]142
143      hostname=`host $ipaddr | \
[23476]144          sed 's#^.*domain name pointer \(.*\)$#\1#' | sed 's;\.*$;;' | \
145          tr '[A-Z]' '[a-z]'`
[23479]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
[23923]164        echo "  dns-nameservers 18.72.0.3 18.70.0.160 18.71.0.151" >> /etc/network/interfaces.new
[23479]165        mv -f /etc/network/interfaces.new /etc/network/interfaces
166      fi
167      hostname ${hostname%%.*}
[23476]168    fi
[23479]169
[23476]170    # Free up designated LVM overhead.
[23867]171    lvremove -f /dev/athena/keep_2 || :
[23476]172
[23874]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
[23460]179Section "Device"
180        Identifier "Configured Video Device"
181        Driver "radeonhd"
182EndSection
183EOF
[23874]184      fi
[23476]185    fi
[23460]186  fi
187else
188  output "Press return to begin or control-C to abort"
189  read dummy
190fi
191
[23093]192output "Installing lsb-release to determine system type"
193aptitude -y install lsb-release
194distro=`lsb_release -cs`
195case $distro in
[23591]196etch|lenny|squeeze)
[23093]197  ;;
[23753]198hardy|intrepid|jaunty)
[23093]199  ubuntu=yes
200  ;;
201*)
202  error "Your machine seems to not be running a current Debian/Ubuntu release."
[23492]203  error "If you believe you are running a current release, contact debathena@mit.edu"
204  exit 1
[23093]205  ;;
206esac
207
[23492]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.)"
[23093]211if [ -d /etc/apt/sources.list.d ]; then
212  sourceslist=/etc/apt/sources.list.d/debathena.list
213else
[23492]214  # dapper is the only "current" platform that doesn't support sources.list.d
[23093]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
[23517]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
[23093]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
[23492]231output "Downloading the Debathena archive signing key"
[23831]232if ! wget -N http://debathena.mit.edu/apt/debathena-archive-keyring.asc ; then
[23492]233  error "Download failed; terminating."
[23093]234  exit 1
235fi
[23817]236echo "6334cf7272423247f3693a3fef771c8274860b26  ./debathena-archive-keyring.asc" | \
[23093]237  sha1sum -c
[23500]238apt-key add debathena-archive-keyring.asc
239rm ./debathena-archive-keyring.asc
[23093]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."
[23492]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
[23093]257fi
258
259output "Installing OpenAFS kernel metapackage"
260apt-get -y install $modules
261
[23187]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.
[23492]265output "Installing main Debathena metapackage $mainpackage"
[23460]266
[23187]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
[23247]279  output "Installing debathena-extra-software"
280  DEBIAN_PRIORITY=critical aptitude -y install debathena-extra-software
[23187]281fi
[23460]282if [ yes = "$tsoft" ]; then
283  output "Installing debathena-thirdparty"
284  DEBIAN_PRIORITY=critical aptitude -y install debathena-thirdparty
285fi
[23910]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.