[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 | |
---|
| 10 | set -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. |
---|
| 15 | export DEBCONF_NONINTERACTIVE_SEEN=true |
---|
| 16 | |
---|
[23093] | 17 | output() { |
---|
| 18 | printf '\033[38m'; echo "$@"; printf '\033[0m' |
---|
| 19 | } |
---|
| 20 | |
---|
| 21 | error() { |
---|
| 22 | printf '\033[31m'; echo "$@"; printf '\033[0m' |
---|
| 23 | } |
---|
| 24 | |
---|
| 25 | ask() { |
---|
| 26 | answer='' |
---|
| 27 | while [ y != "$answer" -a n != "$answer" ]; do |
---|
| 28 | printf '\033[38m'; echo -n "$1"; printf '\033[0m' |
---|
| 29 | read answer |
---|
[24912] | 30 | [ Y = "$answer" ] && answer=y |
---|
| 31 | [ N = "$answer" ] && answer=n |
---|
[23093] | 32 | [ -z "$answer" ] && answer=$2 |
---|
| 33 | done |
---|
| 34 | output "" |
---|
| 35 | } |
---|
| 36 | |
---|
| 37 | if [ `id -u` != "0" ]; then |
---|
[23492] | 38 | error "You must run the Debathena installer as root." |
---|
[24010] | 39 | if [ -x /usr/bin/sudo ]; then |
---|
[24009] | 40 | error "Try running 'sudo $0'." |
---|
| 41 | fi |
---|
[23492] | 42 | exit 1 |
---|
[23093] | 43 | fi |
---|
| 44 | |
---|
[23492] | 45 | echo "Welcome to the Debathena installer." |
---|
[23093] | 46 | echo "" |
---|
[23604] | 47 | echo "Please choose the category which best suits your needs. Each category" |
---|
[23093] | 48 | echo "in this list includes the functionality of the previous ones. See the" |
---|
[23957] | 49 | echo "documentation at http://debathena.mit.edu for more information." |
---|
[23093] | 50 | echo "" |
---|
[23967] | 51 | echo " standard: Athena client software and customizations" |
---|
| 52 | echo " Recommended for laptops and single-user computers." |
---|
| 53 | echo " login: Allow Athena accounts to log into your machine" |
---|
| 54 | echo " Recommended for private remote-access servers." |
---|
[23678] | 55 | echo " login-graphical: Athena graphical login customizations" |
---|
[23967] | 56 | echo " Recommended for private multi-user desktops." |
---|
| 57 | echo " workstation: Graphical workstation with automatic updates" |
---|
[23969] | 58 | echo " Recommended for auto-managed cluster-like systems." |
---|
[23093] | 59 | echo "" |
---|
| 60 | |
---|
[23476] | 61 | category="" |
---|
| 62 | if 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 |
---|
| 68 | fi |
---|
[23135] | 69 | while [ 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 |
---|
| 74 | done |
---|
| 75 | mainpackage=debathena-$category |
---|
| 76 | |
---|
[23187] | 77 | csoft=no |
---|
[23460] | 78 | tsoft=no |
---|
[24786] | 79 | resolvconfhack=no |
---|
[23247] | 80 | echo "The extra-software package installs a standard set of software" |
---|
[23093] | 81 | echo "determined to be of interest to MIT users, such as LaTeX. It is pretty" |
---|
[23247] | 82 | echo "big (several gigabytes, possibly more)." |
---|
[23093] | 83 | echo "" |
---|
[24358] | 84 | echo "Note: by installing this package, you hereby agree with the license terms at:" |
---|
[23872] | 85 | echo " <http://dlc.sun.com/dlj/DLJ-v1.1.txt> Sun's Operating System Distributor" |
---|
| 86 | echo " License for Java version 1.1." |
---|
| 87 | echo "" |
---|
[24358] | 88 | if [ cluster = $category -o workstation = $category ] ; then |
---|
[24786] | 89 | # See Trac #648 and LP:471975 |
---|
| 90 | resolvconfhack=yes |
---|
[24358] | 91 | echo "The extra-software package is required for '$category' and will be installed." |
---|
[23187] | 92 | csoft=yes |
---|
[23469] | 93 | # Not setting tsoft=yes here; -cluster will pull it in anyway. |
---|
[23460] | 94 | else |
---|
| 95 | ask "Do you want the extra-software package [y/N]? " n |
---|
| 96 | if [ y = "$answer" ]; then |
---|
| 97 | csoft=yes |
---|
[23492] | 98 | fi |
---|
[23093] | 99 | fi |
---|
[23876] | 100 | if [ yes = "$csoft" ]; then |
---|
[23872] | 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 |
---|
| 104 | fi |
---|
[23093] | 105 | |
---|
| 106 | echo "A summary of your choices:" |
---|
[23187] | 107 | echo " Category: $category" |
---|
[23247] | 108 | echo " Extra-software package: $csoft" |
---|
[23460] | 109 | echo " Third-party software package: $tsoft" |
---|
[23093] | 110 | echo "" |
---|
[23476] | 111 | if [ "$pxetype" ] ; then |
---|
[24903] | 112 | # Divert the default background and install our own so that failed machines |
---|
| 113 | # are more conspicuous |
---|
| 114 | echo "Diverting default background..." |
---|
| 115 | bgimage=/usr/share/backgrounds/warty-final-ubuntu.png |
---|
| 116 | divertedbg=no |
---|
| 117 | if dpkg-divert --divert ${bgimage}.debathena --rename $bgimage; then |
---|
| 118 | divertedbg=yes |
---|
| 119 | if ! wget -N -O $bgimage http://debathena.mit.edu/error-background.png; then |
---|
| 120 | echo "Hrm, that didn't work. Oh well..." |
---|
| 121 | dpkg-divert --rename --remove $bgimage |
---|
| 122 | divertedbg=no |
---|
| 123 | fi |
---|
| 124 | fi |
---|
| 125 | |
---|
[23460] | 126 | # Setup for package installs in a chrooted immediately-postinstall environment. |
---|
| 127 | echo "Setting locale." |
---|
| 128 | export LANG |
---|
| 129 | . /etc/default/locale |
---|
| 130 | echo "LANG set to $LANG." |
---|
| 131 | echo "Mounting /proc." |
---|
| 132 | mount /proc 2> /dev/null || : |
---|
| 133 | # Clear toxic environment settings inherited from the installer. |
---|
| 134 | unset DEBCONF_REDIR |
---|
| 135 | unset DEBIAN_HAS_FRONTEND |
---|
[23476] | 136 | if [ cluster = "$pxetype" ] ; then |
---|
| 137 | # Network, LVM, and display config that's specific to PXE cluster installs. |
---|
| 138 | # If someone is installing -cluster on an already-installed machine, it's |
---|
| 139 | # assumed that this config has already happened and shouldn't be stomped on. |
---|
[23093] | 140 | |
---|
[23479] | 141 | # Configure network based on the preseed file settings, if present. |
---|
[23867] | 142 | if test -f /root/debathena.preseed ; then |
---|
[23479] | 143 | # Switch to canonical hostname. |
---|
| 144 | ohostname=`cat /etc/hostname` |
---|
| 145 | # Hack to avoid installing debconf-get for just this. |
---|
[23875] | 146 | ipaddr=`grep netcfg/get_ipaddress /root/debathena.preseed|sed -e 's/.* //'` |
---|
| 147 | netmask=`grep netcfg/get_netmask /root/debathena.preseed|sed -e 's/.* //'` |
---|
| 148 | gateway=`grep netcfg/get_gateway /root/debathena.preseed|sed -e 's/.* //'` |
---|
[23479] | 149 | |
---|
| 150 | hostname=`host $ipaddr | \ |
---|
[23476] | 151 | sed 's#^.*domain name pointer \(.*\)$#\1#' | sed 's;\.*$;;' | \ |
---|
| 152 | tr '[A-Z]' '[a-z]'` |
---|
[23479] | 153 | if echo $hostname|grep -q "not found" ; then |
---|
| 154 | hostname="" |
---|
| 155 | printf "\a"; sleep 1 ; printf "\a"; sleep 1 ;printf "\a" |
---|
| 156 | echo "The IP address you selected, $ipaddr, does not have an associated" |
---|
| 157 | echo "hostname. Please confirm that you're using the correct address." |
---|
| 158 | while [ -z "$hostname" ] ; do |
---|
| 159 | echo -n "Enter fully qualified hostname [no default]: " |
---|
| 160 | read hostname |
---|
| 161 | done |
---|
| 162 | fi |
---|
| 163 | echo ${hostname%%.*} > /etc/hostname |
---|
| 164 | sed -e 's/\(127\.0\.1\.1[ ]*\).*/\1'"$hostname ${hostname%%.*}/" < /etc/hosts > /etc/hosts.new |
---|
| 165 | mv -f /etc/hosts.new /etc/hosts |
---|
| 166 | if grep -q dhcp /etc/network/interfaces ; then |
---|
| 167 | sed -e s/dhcp/static/ < /etc/network/interfaces > /etc/network/interfaces.new |
---|
| 168 | echo " address $ipaddr" >> /etc/network/interfaces.new |
---|
| 169 | echo " netmask $netmask" >> /etc/network/interfaces.new |
---|
| 170 | echo " gateway $gateway" >> /etc/network/interfaces.new |
---|
[23923] | 171 | echo " dns-nameservers 18.72.0.3 18.70.0.160 18.71.0.151" >> /etc/network/interfaces.new |
---|
[23479] | 172 | mv -f /etc/network/interfaces.new /etc/network/interfaces |
---|
| 173 | fi |
---|
| 174 | hostname ${hostname%%.*} |
---|
[23476] | 175 | fi |
---|
[23479] | 176 | |
---|
[23476] | 177 | # Free up designated LVM overhead. |
---|
[23867] | 178 | lvremove -f /dev/athena/keep_2 || : |
---|
[23476] | 179 | |
---|
[23460] | 180 | fi |
---|
| 181 | else |
---|
| 182 | output "Press return to begin or control-C to abort" |
---|
| 183 | read dummy |
---|
| 184 | fi |
---|
| 185 | |
---|
[24891] | 186 | if ! hash aptitude >/dev/null 2>&1; then |
---|
| 187 | output "Installing Debathena installer dependency: aptitude" |
---|
| 188 | apt-get -y install aptitude |
---|
| 189 | fi |
---|
| 190 | |
---|
[24791] | 191 | output "Installing Debathena installer dependencies: lsb-release, wget, and dnsutils" |
---|
| 192 | aptitude -y install lsb-release wget dnsutils |
---|
[24786] | 193 | if [ yes = "$resolvconfhack" ]; then |
---|
| 194 | output "Installing resolvconf ahead of time" |
---|
| 195 | aptitude -y install resolvconf |
---|
| 196 | fi |
---|
[23093] | 197 | distro=`lsb_release -cs` |
---|
| 198 | case $distro in |
---|
[24326] | 199 | lenny|squeeze) |
---|
[23093] | 200 | ;; |
---|
[24898] | 201 | hardy|intrepid|jaunty|karmic|lucid|maverick) |
---|
[23093] | 202 | ubuntu=yes |
---|
| 203 | ;; |
---|
| 204 | *) |
---|
[24897] | 205 | error "Your machine seems to not be running a supported Debian/Ubuntu release." |
---|
| 206 | error "(New releases may not be supported immediately after their release)." |
---|
| 207 | error "If you believe you are running a supported release, contact debathena@mit.edu" |
---|
[23492] | 208 | exit 1 |
---|
[23093] | 209 | ;; |
---|
| 210 | esac |
---|
| 211 | |
---|
[23492] | 212 | output "Adding the Debathena repository to the apt sources" |
---|
| 213 | output "(This may cause the update manager to claim new upgrades are available." |
---|
| 214 | output "Ignore them until this script is complete.)" |
---|
[24472] | 215 | sourceslist=/etc/apt/sources.list.d/debathena.list |
---|
[24791] | 216 | clustersourceslist=/etc/apt/sources.list.d/debathena.clusterinfo.list |
---|
| 217 | if [ -z "$hostname" ] ; then hostname=`hostname` ; fi |
---|
| 218 | hescluster=$(dig +short +bufsize=2048 ${hostname}.cluster.ns.athena.mit.edu TXT \ |
---|
| 219 | |sed -e 's/"$//' -ne 's/^"apt_release //p') || hescluster="" |
---|
[23093] | 220 | |
---|
| 221 | if [ ! -e "$sourceslist" ] || ! grep -q debathena "$sourceslist"; then |
---|
| 222 | if [ -e "$sourceslist" ]; then |
---|
| 223 | echo "" >> $sourceslist |
---|
| 224 | fi |
---|
[23517] | 225 | echo "deb http://debathena.mit.edu/apt $distro debathena debathena-config debathena-system openafs" >> $sourceslist |
---|
| 226 | echo "deb-src http://debathena.mit.edu/apt $distro debathena debathena-config debathena-system openafs" >> $sourceslist |
---|
[23093] | 227 | fi |
---|
| 228 | |
---|
[24765] | 229 | if [ development = "$hescluster" -o proposed = "$hescluster" ] ; then |
---|
| 230 | echo "Adding $distro-proposed apt repository." |
---|
[24791] | 231 | echo "# This file is automatically updated by debathena-auto-update" >> $clustersourceslist |
---|
| 232 | echo "# based on your Hesiod cluster information. If you want to" >> $clustersourceslist |
---|
| 233 | echo "# make changes, do so in another file." >> $clustersourceslist |
---|
| 234 | echo "" >> $clustersourceslist |
---|
| 235 | |
---|
| 236 | echo "deb http://debathena.mit.edu/apt $distro-proposed debathena debathena-config debathena-system openafs" >> $clustersourceslist |
---|
| 237 | echo "deb-src http://debathena.mit.edu/apt $distro-proposed debathena debathena-config debathena-system openafs" >> $clustersourceslist |
---|
[24765] | 238 | fi |
---|
| 239 | |
---|
| 240 | if [ development = "$hescluster" ] ; then |
---|
| 241 | echo "Adding $distro-development apt repository." |
---|
[24791] | 242 | echo "deb http://debathena.mit.edu/apt $distro-development debathena debathena-config debathena-system openafs" >> $clustersourceslist |
---|
| 243 | echo "deb-src http://debathena.mit.edu/apt $distro-development debathena debathena-config debathena-system openafs" >> $clustersourceslist |
---|
[24765] | 244 | fi |
---|
| 245 | |
---|
[23093] | 246 | if [ "$ubuntu" = "yes" ]; then |
---|
| 247 | output "Making sure the universe repository is enabled" |
---|
| 248 | sed -i 's,^# \(deb\(\-src\)* http://archive.ubuntu.com/ubuntu [[:alnum:]]* universe\)$,\1,' /etc/apt/sources.list |
---|
| 249 | fi |
---|
| 250 | |
---|
[23492] | 251 | output "Downloading the Debathena archive signing key" |
---|
[23831] | 252 | if ! wget -N http://debathena.mit.edu/apt/debathena-archive-keyring.asc ; then |
---|
[23492] | 253 | error "Download failed; terminating." |
---|
[23093] | 254 | exit 1 |
---|
| 255 | fi |
---|
[24334] | 256 | echo "fa787714d1ea439c28458aab64962f755e2bdee7a3520919a72b641458757fa3586fd269cc1dae8d99047e00b3df88db0826f0c99a1f5a8771618b3c0be8e3bd ./debathena-archive-keyring.asc" | \ |
---|
| 257 | sha512sum -c |
---|
[23500] | 258 | apt-key add debathena-archive-keyring.asc |
---|
| 259 | rm ./debathena-archive-keyring.asc |
---|
[23093] | 260 | |
---|
| 261 | apt-get update |
---|
| 262 | |
---|
| 263 | modules_want=$(dpkg-query -W -f '${Source}\t${Package}\n' 'linux-image-*' | \ |
---|
| 264 | sed -nre 's/^linux-(meta|latest[^\t]*)\tlinux-image-(.*)$/openafs-modules-\2/p') |
---|
| 265 | modules= |
---|
| 266 | for m in $modules_want; do |
---|
| 267 | aptitude show $m > /dev/null && modules="$modules $m" |
---|
| 268 | done |
---|
| 269 | |
---|
| 270 | if [ -z "$modules" ]; then |
---|
| 271 | error "An OpenAFS modules metapackage for your kernel is not available." |
---|
[23492] | 272 | error "Please use the manual installation instructions at" |
---|
[23957] | 273 | error "http://debathena.mit.edu/install" |
---|
[23492] | 274 | error "You will need to compile your own AFS modules as described at:" |
---|
[23957] | 275 | error "http://debathena.mit.edu/troubleshooting#openafs-custom" |
---|
[23492] | 276 | exit 1 |
---|
[23093] | 277 | fi |
---|
| 278 | |
---|
| 279 | output "Installing OpenAFS kernel metapackage" |
---|
| 280 | apt-get -y install $modules |
---|
| 281 | |
---|
[23187] | 282 | # Use the noninteractive frontend to install the main package. This |
---|
| 283 | # is so that AFS and Zephyr don't ask questions of the user which |
---|
| 284 | # debathena packages will later stomp on anyway. |
---|
[23492] | 285 | output "Installing main Debathena metapackage $mainpackage" |
---|
[23460] | 286 | |
---|
[23187] | 287 | DEBIAN_FRONTEND=noninteractive aptitude -y install "$mainpackage" |
---|
| 288 | |
---|
| 289 | # Use the default front end and allow questions to be asked; otherwise |
---|
| 290 | # Java will fail to install since it has to present its license. |
---|
| 291 | if [ yes = "$csoft" ]; then |
---|
[23247] | 292 | output "Installing debathena-extra-software" |
---|
| 293 | DEBIAN_PRIORITY=critical aptitude -y install debathena-extra-software |
---|
[23187] | 294 | fi |
---|
[23460] | 295 | if [ yes = "$tsoft" ]; then |
---|
| 296 | output "Installing debathena-thirdparty" |
---|
| 297 | DEBIAN_PRIORITY=critical aptitude -y install debathena-thirdparty |
---|
| 298 | fi |
---|
[23910] | 299 | |
---|
| 300 | # Post-install cleanup for cluster systems. |
---|
[24903] | 301 | if [ "$divertedbg" = "yes" ]; then |
---|
| 302 | rm -f $bgimage |
---|
| 303 | if ! dpkg-divert --rename --remove $bgimage; then |
---|
| 304 | echo "Failed to remove diversion of background. You probably don't care." |
---|
| 305 | fi |
---|
| 306 | fi |
---|
| 307 | |
---|
[23910] | 308 | if [ cluster = "$category" ] ; then |
---|
| 309 | # Force an /etc/adjtime entry so there's no confusion about whether the |
---|
| 310 | # hardware clock is UTC or local. |
---|
| 311 | echo "Setting hardware clock to UTC." |
---|
| 312 | hwclock --systohc --utc |
---|
| 313 | fi |
---|