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

Revision 25251, 12.8 KB checked in by jdreed, 13 years ago (diff)
No longer save half the disk for LVM snapshots This means Jaunty cluster is no longer installable; we don't care
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  if [ -x /usr/bin/sudo ]; then
40    error "Try running 'sudo $0'."
41  fi
42  exit 1
43fi
44
45echo "Welcome to the Debathena installer."
46echo ""
47echo "Please choose the category which best suits your needs.  Each category"
48echo "in this list includes the functionality of the previous ones.  See the"
49echo "documentation at http://debathena.mit.edu for more information."
50echo ""
51echo "  standard:        Athena client software and customizations"
52echo "                   Recommended for laptops and single-user computers."
53echo "  login:           Allow Athena accounts to log into your machine"
54echo "                   Recommended for private remote-access servers."
55echo "  login-graphical: Athena graphical login customizations"
56echo "                   Recommended for private multi-user desktops."
57echo "  workstation:     Graphical workstation with automatic updates"
58echo "                   Recommended for auto-managed cluster-like systems."
59echo ""
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
77csoft=no
78tsoft=no
79resolvconfhack=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 ""
84echo "Note: This package may include software with additional license terms."
85echo "      By installing it, you are agreeing to the terms of these licenses."
86echo "      For more information, please see http://debathena.mit.edu/licensing"
87echo ""
88if [ cluster = $category -o workstation = $category ] ; then
89  # See Trac #648 and LP:471975
90  resolvconfhack=yes
91  echo "The extra-software package is required for '$category' and will be installed."
92  csoft=yes
93  # Not setting tsoft=yes here; -cluster will pull it in anyway.
94else
95  ask "Do you want the extra-software package [y/N]? " n
96  if [ y = "$answer" ]; then
97    csoft=yes
98  fi
99fi
100if [ yes = "$csoft" ]; then
101    # Preseed an answer to the java license query, which license was already accepted
102    # at install time:
103    echo "sun-java6-bin shared/accepted-sun-dlj-v1-1 boolean true" |debconf-set-selections
104fi
105
106echo "A summary of your choices:"
107echo "  Category: $category"
108echo "  Extra-software package: $csoft"
109echo "  Third-party software package: $tsoft"
110echo ""
111if [ "$pxetype" = "cluster" ] ; then
112  if wget -q http://athena10.mit.edu/installer/installing.txt; then
113     cat installing.txt > /dev/tty6
114     date > /dev/tty6
115     chvt 6
116  fi
117  # Divert the default background and install our own so that failed machines
118  # are more conspicuous
119  echo "Diverting default background..."
120  bgimage=/usr/share/backgrounds/warty-final-ubuntu.png
121  divertedbg=no
122  if dpkg-divert --divert ${bgimage}.debathena --rename $bgimage; then
123      divertedbg=yes
124      if ! wget -N -O $bgimage http://debathena.mit.edu/error-background.png; then
125          echo "Hrm, that didn't work.  Oh well..."
126          dpkg-divert --rename --remove $bgimage
127          divertedbg=no
128      fi
129  fi
130
131  # Setup for package installs in a chrooted immediately-postinstall environment.
132  echo "Setting locale."
133  export LANG
134  . /etc/default/locale
135  echo "LANG set to $LANG."
136  echo "Mounting /proc."
137  mount /proc 2> /dev/null || :
138  # Clear toxic environment settings inherited from the installer.
139  unset DEBCONF_REDIR
140  unset DEBIAN_HAS_FRONTEND
141  if [ cluster = "$pxetype" ] ; then
142    # Network, LVM, and display config that's specific to PXE cluster installs.
143    # If someone is installing -cluster on an already-installed machine, it's
144    # assumed that this config has already happened and shouldn't be stomped on.
145
146    # Configure network based on the preseed file settings, if present.
147    if test -f /root/debathena.preseed ; then
148      # Switch to canonical hostname.
149      ohostname=`cat /etc/hostname`
150      # Hack to avoid installing debconf-get for just this.
151      ipaddr=`grep netcfg/get_ipaddress /root/debathena.preseed|sed -e 's/.* //'`
152      netmask=`grep netcfg/get_netmask /root/debathena.preseed|sed -e 's/.* //'`
153      gateway=`grep netcfg/get_gateway /root/debathena.preseed|sed -e 's/.* //'`
154
155      hostname=`host $ipaddr | \
156          sed 's#^.*domain name pointer \(.*\)$#\1#' | sed 's;\.*$;;' | \
157          tr '[A-Z]' '[a-z]'`
158      if echo $hostname|grep -q "not found" ; then
159        hostname=""
160        printf "\a"; sleep 1 ; printf "\a"; sleep 1 ;printf "\a"
161        echo "The IP address you selected, $ipaddr, does not have an associated"
162        echo "hostname.  Please confirm that you're using the correct address."
163        while [ -z "$hostname" ] ; do
164          echo -n "Enter fully qualified hostname [no default]: "
165          read hostname
166        done
167      fi
168      echo ${hostname%%.*} > /etc/hostname
169      sed -e 's/\(127\.0\.1\.1[         ]*\).*/\1'"$hostname ${hostname%%.*}/" < /etc/hosts > /etc/hosts.new
170      mv -f /etc/hosts.new /etc/hosts
171      if grep -q dhcp /etc/network/interfaces ; then
172        sed -e s/dhcp/static/ < /etc/network/interfaces > /etc/network/interfaces.new
173        echo "  address $ipaddr" >> /etc/network/interfaces.new
174        echo "  netmask $netmask" >> /etc/network/interfaces.new
175        echo "  gateway $gateway" >> /etc/network/interfaces.new
176        echo "  dns-nameservers 18.72.0.3 18.70.0.160 18.71.0.151" >> /etc/network/interfaces.new
177        mv -f /etc/network/interfaces.new /etc/network/interfaces
178      fi
179      hostname ${hostname%%.*}
180    fi
181
182  fi
183else
184  output "Press return to begin or control-C to abort"
185  read dummy
186fi
187
188apt-get update
189
190output "Verifying machine is up to date..."
191pattern='^0 upgraded, 0 newly installed, 0 to remove'
192if ! apt-get --simulate --assume-yes dist-upgrade | grep -q "$pattern"; then
193    if [ -n "$pxetype" ] ; then
194        output "Forcing an upgrade"
195        apt-get --assume-yes dist-upgrade
196    else
197        error "Your system is not up to date.  Proceeding with an install at"
198        error "this time could render your system unusable."
199        error "Please run 'apt-get dist-upgrade' as root or use the GUI update"
200        error "manager to ensure your system is up to date before continuing."
201        error "NOTE: You do NOT need to upgrade to a newer release of Ubuntu",
202        error "you merely need to ensure you have the latest software updates"
203        error "for the current version."
204        exit 1
205    fi
206fi
207
208if ! hash aptitude >/dev/null 2>&1; then
209  output "Installing Debathena installer dependency: aptitude"
210  apt-get -y install aptitude
211fi
212
213output "Installing Debathena installer dependencies: lsb-release, wget, and dnsutils"
214aptitude -y install lsb-release wget dnsutils
215if [ yes = "$resolvconfhack" ]; then
216  output "Installing resolvconf ahead of time"
217  aptitude -y install resolvconf
218fi
219distro=`lsb_release -cs`
220case $distro in
221lenny|squeeze)
222  ;;
223hardy|intrepid|jaunty|karmic|lucid|maverick|natty)
224  ubuntu=yes
225  ;;
226*)
227  error "Your machine seems to not be running a supported Debian/Ubuntu release."
228  error "(New releases may not be supported immediately after their release)."
229  error "If you believe you are running a supported release, contact debathena@mit.edu"
230  exit 1
231  ;;
232esac
233
234if aptitude show openafs-modules-dkms > /dev/null; then
235  openafs_component=" openafs"
236  modules="openafs-modules-dkms"
237fi
238
239output "Adding the Debathena repository to the apt sources"
240output "(This may cause the update manager to claim new upgrades are available."
241output "Ignore them until this script is complete.)"
242sourceslist=/etc/apt/sources.list.d/debathena.list
243clustersourceslist=/etc/apt/sources.list.d/debathena.clusterinfo.list
244if [ -z "$hostname" ] ; then hostname=`hostname` ; fi
245
246if [ ! -e "$sourceslist" ] || ! grep -q debathena "$sourceslist"; then
247  if [ -e "$sourceslist" ]; then
248    echo "" >> $sourceslist
249  fi
250  echo "deb http://debathena.mit.edu/apt $distro debathena debathena-config debathena-system$openafs_component" >> $sourceslist
251  echo "deb-src http://debathena.mit.edu/apt $distro debathena debathena-config debathena-system$openafs_component" >> $sourceslist
252fi
253
254# Note that hesiod may contain multiple apt_release tokens.  We want to
255# include known repositories but make no assumptions about wanting
256# others.  (For instances, "development" does @i{not} automatically
257# infer "proposed".)
258hescluster=$(dig +short +bufsize=2048 ${hostname}.cluster.ns.athena.mit.edu TXT) || hescluster=""
259
260aptexplained=false
261for hc in proposed development bleeding; do
262  if echo "$hescluster" | grep -Fxq "\"apt_release $hc\""; then
263    echo "Adding $distro-$hc apt repository."
264    if [ "${aptexplained}" = false ] ; then
265      echo "" >> $clustersourceslist
266      echo "# This file is automatically updated by debathena-auto-update" >> $clustersourceslist
267      echo "# based on your Hesiod cluster information. If you want to" >> $clustersourceslist
268      echo "# make changes, do so in another file." >> $clustersourceslist
269      aptexplained=true
270    fi
271    echo "" >> $clustersourceslist
272    echo "deb http://debathena.mit.edu/apt $distro-${hc} debathena debathena-config debathena-system$openafs_component" >> $clustersourceslist
273    echo "deb-src http://debathena.mit.edu/apt $distro-${hc} debathena debathena-config debathena-system$openafs_component" >> $clustersourceslist
274  fi
275done
276
277if [ "$ubuntu" = "yes" ]; then
278  output "Making sure the universe repository is enabled"
279  sed -i 's,^# \(deb\(\-src\)* http://archive.ubuntu.com/ubuntu [[:alnum:]]* universe\)$,\1,' /etc/apt/sources.list
280fi
281
282output "Downloading the Debathena archive signing key"
283if ! wget -N http://debathena.mit.edu/apt/debathena-archive-keyring.asc ; then
284  error "Download failed; terminating."
285  exit 1
286fi
287echo "fa787714d1ea439c28458aab64962f755e2bdee7a3520919a72b641458757fa3586fd269cc1dae8d99047e00b3df88db0826f0c99a1f5a8771618b3c0be8e3bd  ./debathena-archive-keyring.asc" | \
288  sha512sum -c
289apt-key add debathena-archive-keyring.asc
290rm ./debathena-archive-keyring.asc
291
292apt-get update
293
294if [ -z "$modules" ]; then
295  modules_want=$(dpkg-query -W -f '${Source}\t${Package}\n' 'linux-image-*' | \
296   sed -nre 's/^linux-(meta|latest[^\t]*)\tlinux-image-(.*)$/openafs-modules-\2/p')
297  modules=
298  for m in $modules_want; do
299    aptitude show $m > /dev/null && modules="$modules $m"
300  done
301fi
302
303if [ -z "$modules" ]; then
304  error "An OpenAFS modules metapackage for your kernel is not available."
305  error "Please use the manual installation instructions at"
306  error "http://debathena.mit.edu/install"
307  error "You will need to compile your own AFS modules as described at:"
308  error "http://debathena.mit.edu/troubleshooting#openafs-custom"
309  exit 1
310fi
311
312output "Installing OpenAFS kernel metapackage"
313apt-get -y install $modules
314
315# Use the noninteractive frontend to install the main package.  This
316# is so that AFS and Zephyr don't ask questions of the user which
317# debathena packages will later stomp on anyway.
318output "Installing main Debathena metapackage $mainpackage"
319
320DEBIAN_FRONTEND=noninteractive aptitude -y install "$mainpackage"
321
322# Use the default front end and allow questions to be asked; otherwise
323# Java will fail to install since it has to present its license.
324if [ yes = "$csoft" ]; then
325  output "Installing debathena-extra-software"
326  DEBIAN_PRIORITY=critical aptitude -y install debathena-extra-software
327fi
328if [ yes = "$tsoft" ]; then
329  output "Installing debathena-thirdparty"
330  DEBIAN_PRIORITY=critical aptitude -y install debathena-thirdparty
331fi
332
333# Post-install cleanup for cluster systems.
334if [ "$divertedbg" = "yes" ]; then
335    rm -f $bgimage
336    if ! dpkg-divert --rename --remove $bgimage; then
337        echo "Failed to remove diversion of background.  You probably don't care."
338    fi
339fi
340
341if [ cluster = "$category" ] ; then
342  # Force an /etc/adjtime entry so there's no confusion about whether the
343  # hardware clock is UTC or local.
344  echo "Setting hardware clock to UTC."
345  hwclock --systohc --utc
346fi
Note: See TracBrowser for help on using the repository browser.