1 | #!/bin/sh |
---|
2 | # Athena 10 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 http://debathena.mit.edu/install-debathena.sh |
---|
9 | |
---|
10 | set -e |
---|
11 | |
---|
12 | output() { |
---|
13 | printf '\033[38m'; echo "$@"; printf '\033[0m' |
---|
14 | } |
---|
15 | |
---|
16 | error() { |
---|
17 | printf '\033[31m'; echo "$@"; printf '\033[0m' |
---|
18 | } |
---|
19 | |
---|
20 | ask() { |
---|
21 | answer='' |
---|
22 | while [ y != "$answer" -a n != "$answer" ]; do |
---|
23 | printf '\033[38m'; echo -n "$1"; printf '\033[0m' |
---|
24 | read answer |
---|
25 | [ Y = answer ] && answer=y |
---|
26 | [ N = answer ] && answer=n |
---|
27 | [ -z "$answer" ] && answer=$2 |
---|
28 | done |
---|
29 | output "" |
---|
30 | } |
---|
31 | |
---|
32 | if [ `id -u` != "0" ]; then |
---|
33 | error "You must run the Debathena installer as root." |
---|
34 | exit 1 |
---|
35 | fi |
---|
36 | |
---|
37 | echo "Welcome to the Debathena installer." |
---|
38 | echo "" |
---|
39 | echo "Please choose the category which best suits your needs. Each category" |
---|
40 | echo "in this list includes the functionality of the previous ones. See the" |
---|
41 | echo "documentation at http://debathena.mit.edu/beta for more information." |
---|
42 | echo "" |
---|
43 | echo " standard: Athena client software (e.g. discuss) and customizations" |
---|
44 | echo " login: Allow Athena users to log into your machine" |
---|
45 | echo " login-graphical: Athena graphical login customizations" |
---|
46 | echo " workstation: Managed graphical workstation with minimal need for" |
---|
47 | echo " manual maintenance" |
---|
48 | echo "" |
---|
49 | |
---|
50 | # Hack to deal with the older PXE installer (which used a simple flag file to |
---|
51 | # indicate a PXE cluster install). |
---|
52 | if test -f /root/unattended-cluster-install ; then |
---|
53 | echo cluster > /root/pxe-install-flag |
---|
54 | fi |
---|
55 | |
---|
56 | category="" |
---|
57 | if test -f /root/pxe-install-flag ; then |
---|
58 | pxetype=`head -1 /root/pxe-install-flag` |
---|
59 | if [ cluster = "$pxetype" ] ; then |
---|
60 | category=cluster ; |
---|
61 | echo "PXE cluster install detected, so installing \"cluster\"." |
---|
62 | fi |
---|
63 | fi |
---|
64 | while [ standard != "$category" -a login != "$category" -a \ |
---|
65 | login-graphical != "$category" -a workstation != "$category" -a \ |
---|
66 | cluster != "$category" ]; do |
---|
67 | output -n "Please choose a category or press control-C to abort: " |
---|
68 | read category |
---|
69 | done |
---|
70 | mainpackage=debathena-$category |
---|
71 | |
---|
72 | dev=no |
---|
73 | echo |
---|
74 | if [ cluster != $category ] ; then |
---|
75 | ask "Will this machine be used to build Debathena packages [y/N]? " n |
---|
76 | if [ y = "$answer" ]; then |
---|
77 | dev=yes |
---|
78 | fi |
---|
79 | fi |
---|
80 | |
---|
81 | csoft=no |
---|
82 | tsoft=no |
---|
83 | echo "The extra-software package installs a standard set of software" |
---|
84 | echo "determined to be of interest to MIT users, such as LaTeX. It is pretty" |
---|
85 | echo "big (several gigabytes, possibly more)." |
---|
86 | echo "" |
---|
87 | if [ cluster = $category ] ; then |
---|
88 | echo "Cluster install detected, so installing extras." |
---|
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 | |
---|
98 | echo "A summary of your choices:" |
---|
99 | echo " Category: $category" |
---|
100 | echo " Debian development package: $dev" |
---|
101 | echo " Extra-software package: $csoft" |
---|
102 | echo " Third-party software package: $tsoft" |
---|
103 | echo "" |
---|
104 | if [ "$pxetype" ] ; then |
---|
105 | # Setup for package installs in a chrooted immediately-postinstall environment. |
---|
106 | echo "Setting locale." |
---|
107 | export LANG |
---|
108 | . /etc/default/locale |
---|
109 | echo "LANG set to $LANG." |
---|
110 | echo "Mounting /proc." |
---|
111 | mount /proc 2> /dev/null || : |
---|
112 | # Clear toxic environment settings inherited from the installer. |
---|
113 | unset DEBCONF_REDIR |
---|
114 | unset DEBIAN_HAS_FRONTEND |
---|
115 | if [ cluster = "$pxetype" ] ; then |
---|
116 | # Network, LVM, and display config that's specific to PXE cluster installs. |
---|
117 | # If someone is installing -cluster on an already-installed machine, it's |
---|
118 | # assumed that this config has already happened and shouldn't be stomped on. |
---|
119 | |
---|
120 | # Preseed an answer to the java license query, which license was already accepted |
---|
121 | # at install time: |
---|
122 | echo "sun-java6-bin shared/accepted-sun-dlj-v1-1 boolean true" |debconf-set-selections |
---|
123 | |
---|
124 | # Configure network based on the preseed file settings, if present. |
---|
125 | if test -f /root/athena10.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/athena10.preseed|sed -e 's/.* //'` |
---|
130 | netmask=`grep netcfg/get_netmask /root/athena10.preseed|sed -e 's/.* //'` |
---|
131 | gateway=`grep netcfg/get_gateway /root/athena10.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 | mv -f /etc/network/interfaces.new /etc/network/interfaces |
---|
155 | fi |
---|
156 | hostname ${hostname%%.*} |
---|
157 | fi |
---|
158 | |
---|
159 | # Free up designated LVM overhead. |
---|
160 | lvremove -f /dev/athena10/keep_2 || : |
---|
161 | |
---|
162 | # This makes gx755s suck less. |
---|
163 | if lspci -n|grep -q 1002:94c1 && ! grep -q radeonhd /etc/X11/xorg.conf ; then |
---|
164 | DEBIAN_FRONTEND=noninteractive aptitude -y install xserver-xorg-video-radeonhd |
---|
165 | cat >> /etc/X11/xorg.conf <<EOF |
---|
166 | Section "Device" |
---|
167 | Identifier "Configured Video Device" |
---|
168 | Driver "radeonhd" |
---|
169 | EndSection |
---|
170 | EOF |
---|
171 | fi |
---|
172 | fi |
---|
173 | else |
---|
174 | output "Press return to begin or control-C to abort" |
---|
175 | read dummy |
---|
176 | fi |
---|
177 | |
---|
178 | output "Installing lsb-release to determine system type" |
---|
179 | aptitude -y install lsb-release |
---|
180 | distro=`lsb_release -cs` |
---|
181 | case $distro in |
---|
182 | etch|lenny|squeeze) |
---|
183 | ;; |
---|
184 | hardy|intrepid|jaunty) |
---|
185 | ubuntu=yes |
---|
186 | ;; |
---|
187 | *) |
---|
188 | error "Your machine seems to not be running a current Debian/Ubuntu release." |
---|
189 | error "If you believe you are running a current release, contact debathena@mit.edu" |
---|
190 | exit 1 |
---|
191 | ;; |
---|
192 | esac |
---|
193 | |
---|
194 | output "Adding the Debathena repository to the apt sources" |
---|
195 | output "(This may cause the update manager to claim new upgrades are available." |
---|
196 | output "Ignore them until this script is complete.)" |
---|
197 | if [ -d /etc/apt/sources.list.d ]; then |
---|
198 | sourceslist=/etc/apt/sources.list.d/debathena.list |
---|
199 | else |
---|
200 | # dapper is the only "current" platform that doesn't support sources.list.d |
---|
201 | sourceslist=/etc/apt/sources.list |
---|
202 | fi |
---|
203 | |
---|
204 | if [ ! -e "$sourceslist" ] || ! grep -q debathena "$sourceslist"; then |
---|
205 | if [ -e "$sourceslist" ]; then |
---|
206 | echo "" >> $sourceslist |
---|
207 | fi |
---|
208 | echo "deb http://debathena.mit.edu/apt $distro debathena debathena-config debathena-system openafs" >> $sourceslist |
---|
209 | echo "deb-src http://debathena.mit.edu/apt $distro debathena debathena-config debathena-system openafs" >> $sourceslist |
---|
210 | fi |
---|
211 | |
---|
212 | if [ "$ubuntu" = "yes" ]; then |
---|
213 | output "Making sure the universe repository is enabled" |
---|
214 | sed -i 's,^# \(deb\(\-src\)* http://archive.ubuntu.com/ubuntu [[:alnum:]]* universe\)$,\1,' /etc/apt/sources.list |
---|
215 | fi |
---|
216 | |
---|
217 | output "Downloading the Debathena archive signing key" |
---|
218 | if ! wget http://debathena.mit.edu/apt/debathena-archive-keyring.asc ; then |
---|
219 | error "Download failed; terminating." |
---|
220 | exit 1 |
---|
221 | fi |
---|
222 | echo "05c41a58b820b9aef198d8dad5a613c40cbd8b52 ./debathena-archive-keyring.asc" | \ |
---|
223 | sha1sum -c |
---|
224 | apt-key add debathena-archive-keyring.asc |
---|
225 | rm ./debathena-archive-keyring.asc |
---|
226 | |
---|
227 | apt-get update |
---|
228 | |
---|
229 | modules_want=$(dpkg-query -W -f '${Source}\t${Package}\n' 'linux-image-*' | \ |
---|
230 | sed -nre 's/^linux-(meta|latest[^\t]*)\tlinux-image-(.*)$/openafs-modules-\2/p') |
---|
231 | modules= |
---|
232 | for m in $modules_want; do |
---|
233 | aptitude show $m > /dev/null && modules="$modules $m" |
---|
234 | done |
---|
235 | |
---|
236 | if [ -z "$modules" ]; then |
---|
237 | error "An OpenAFS modules metapackage for your kernel is not available." |
---|
238 | error "Please use the manual installation instructions at" |
---|
239 | error "http://debathena.mit.edu/beta/install" |
---|
240 | error "You will need to compile your own AFS modules as described at:" |
---|
241 | error "http://debathena.mit.edu/beta/troubleshooting#openafs-custom" |
---|
242 | exit 1 |
---|
243 | fi |
---|
244 | |
---|
245 | output "Installing OpenAFS kernel metapackage" |
---|
246 | apt-get -y install $modules |
---|
247 | |
---|
248 | # Use the noninteractive frontend to install the main package. This |
---|
249 | # is so that AFS and Zephyr don't ask questions of the user which |
---|
250 | # debathena packages will later stomp on anyway. |
---|
251 | output "Installing main Debathena metapackage $mainpackage" |
---|
252 | |
---|
253 | DEBIAN_FRONTEND=noninteractive aptitude -y install "$mainpackage" |
---|
254 | |
---|
255 | # This package is relatively small so it's not as important, but allow |
---|
256 | # critical questions to be asked. |
---|
257 | if [ yes = "$dev" ]; then |
---|
258 | output "Installing debathena-build-depends" |
---|
259 | DEBIAN_PRIORITY=critical aptitude -y install debathena-build-depends |
---|
260 | fi |
---|
261 | |
---|
262 | # Use the default front end and allow questions to be asked; otherwise |
---|
263 | # Java will fail to install since it has to present its license. |
---|
264 | if [ yes = "$csoft" ]; then |
---|
265 | output "Installing debathena-extra-software" |
---|
266 | DEBIAN_PRIORITY=critical aptitude -y install debathena-extra-software |
---|
267 | fi |
---|
268 | if [ yes = "$tsoft" ]; then |
---|
269 | output "Installing debathena-thirdparty" |
---|
270 | DEBIAN_PRIORITY=critical aptitude -y install debathena-thirdparty |
---|
271 | fi |
---|