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