source: branches/fc13-dev/server/doc/install-howto.sh @ 1636

Last change on this file since 1636 was 1620, checked in by ezyang, 14 years ago
Undo scripts.mit.edu SVN change, add more docs about it.
File size: 18.3 KB
Line 
1# This document is a how-to for installing a Fedora scripts.mit.edu server.
2
3set -e -x
4
5[ -e /scripts-boot-count ] || echo 0 > /scripts-boot-count
6
7# This is actually just "pick an active scripts server"
8source_server="cats-whiskers.mit.edu"
9
10boot=${1:$(cat /scripts-boot-count)}
11
12# XXX: let 'branch' be the current svn branch you are on.  You want to
13# use trunk if your just installing a new server, and branches/fcXX-dev
14# if your preparing a server on a new Fedora release.
15
16doreboot() {
17    echo $(( $boot + 1 )) > /scripts-boot-count;
18    shutdown -r now "Rebooting for step $(cat /scripts-boot-count)"
19}
20
21YUM() {
22    NSS_NONLOCAL_IGNORE=1 yum "$@"
23}
24
25# Helper files for the install are located in server/fedora/config.
26
27# Start with a normal install of Fedora.
28
29if [ $boot = 0 ]; then
30# When the initial configuration screen comes up, under "Firewall
31# configuration", disable the firewall, and under "System services", leave
32# enabled (as of Fedora 9) acpid, anacron, atd, cpuspeed, crond,
33# firstboot, fuse, haldaemon, ip6tables, iptables, irqbalance,
34# kerneloops, mdmonitor, messagebus, microcode_ctl, netfs, network, nscd, ntpd,
35# sshd, udev-post, and nothing else.
36
37# If you did a minimal install, these won't be installed, so you'll
38# need to do this step later in the process.
39    echo "--disabled" > /etc/sysconfig/system-config-firewall
40    for i in NetworkManager avahi-daemon bluetooth cups isdn nfslock nfs pcscd restorecond rpcbind rpcgssd rpcidmapd sendmail; do
41        chkconfig "$i" off
42    done
43
44# Turn on network, so we can connect at boot
45chkconfig network on
46
47# Edit /etc/selinux/config so it has SELINUX=disabled and reboot.
48    sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config
49    doreboot
50fi
51
52if [ $boot = 1 ]; then
53# Create a scripts-build user account, and set up rpm to build in
54# $HOME by doing a
55# cp config/home/scripts-build/.rpmmacros /home/scripts-build/
56# (If you just use the default setup, it will generate packages
57# in /usr/src/redhat.)
58    adduser scripts-build
59
60# Check out the scripts.mit.edu svn repository. Configure svn not to cache
61# credentials.
62
63    YUM install -y subversion
64
65    cd /srv
66    # We must use an explicit source_server while setting up the Scripts
67    # server, because once we load the Scripts /etc configuration,
68    # scripts.mit.edu will start resolving to localhost and
69    # updates/commits will stop working.  This will be switched to
70    # scripts.mit.edu at the end of the install process.
71    svn co svn://$source_server/$branch repository
72
73    sed -i 's/^(# *)*store-passwords.*/store-passwords = no/' /root/.subversion/config
74    sed -i 's/^(# *)*store-auth-creds.*/store-auth-creds = no/' /root/.subversion/config
75# The same tweaks should be made on /home/scripts-build/.subversion/config
76# once it exists (do something with svn as scripts-build)
77
78    chown -R scripts-build /srv/repository
79
80# cd to server/fedora in the svn repository.
81    cd /srv/repository/server/fedora
82
83# Run "make install-deps" to install various prereqs.  Nonstandard
84# deps are in /mit/scripts/rpm.
85    YUM install -y make
86    make install-deps
87    # You should pay close attention to the output of this command, and
88    # note if packages you think should exist don't exist anymore.  In
89    # particular, if Fedora changes an architecture designation those
90    # won't work.
91
92# Add scripts-build to the group 'mock'
93    usermod -a -G mock scripts-build
94
95# Install bind
96    YUM install -y bind
97
98# Check out the scripts /etc configuration
99    cd /root
100    svn co svn://scripts.mit.edu/$branch/server/fedora/config/etc etc
101    # backslash to make us not use the alias
102    \cp -a etc /
103
104# NOTE: You will have just lost DNS resolution and the ability
105# to do password SSH in.  If you managed to botch this step without
106# having named setup, you can do a quick fix by frobbing /etc/resolv.conf
107# with a non 127.0.0.1 address for the DNS server.  Be sure to revert it once
108# you have named.
109
110# You can get password SSH back by editing /etc/ssh/sshd_config (allow
111# password auth) and /etc/pam.d/sshd (comment out the first three auth
112# lines)
113
114    service named start
115    chkconfig named on
116
117# This is the point at which you should start updating scriptsified
118# packages for a new Fedora release.  Consult 'upgrade-tips' for more
119# information.
120
121# In the case of the Kerberos libraries, you'll be told that
122# there are conflicting files with the 64-bit versions of the packages,
123# which we scriptsify.  You'll have to use --force to install those
124# rpms despite the conflicts.  After doing that, you may want to
125# install the corresponding 64-bit scriptsified versions again, just
126# to be safe in case the 32-bit versions overwrite files that differ.
127# When you try this, it will complain that you already have the same
128# version installed; again, you'll need to use --force to do it anyway.
129
130# We need yumdownloader to force some RPMs
131    # XXX: This might be wrong. Sanity check what packages ou
132    # have when done
133    YUM install -y yum-utils
134    yumdownloader krb5-libs
135    # XXX: These version numbers are hardcoded, need some cli-fu to generalize
136    # FC13: Check if they are necessary
137    rpm -i krb5-libs-*.i586.rpm
138    rpm -U --force krb5-libs-*.scripts.1138.x86_64.rpm
139
140# env NSS_NONLOCAL_IGNORE=1 yum install scripts-base
141    YUM install -y scripts-base
142
143# Remember to set NSS_NONLOCAL_IGNORE=1 anytime you're setting up
144# anything, e.g. using yum. Otherwise useradd will query LDAP in a stupid way
145# that makes it hang forever. (This is why we're using YUM, not yum)
146
147# Reload the iptables config to take down the restrictive firewall
148    service iptables restart
149
150# Copy over root's dotfiles from one of the other machines.
151# Perhaps a useful change is to remove the default aliases
152    # On 2009-07-01, the dotfiles to transfer where:
153    #   .bashrc .ldapvirc (<- HAS PRIVILEDGED DATA)
154    #   .screenrc .ssh (<- directory) .vimrc
155    # Trying to scp from server to server won't work, as scp
156    # will attempt to negotiate a server-to-server connection.
157    # Instead, scp to your trusted machine as a temporary file,
158    # and then push to the other server
159    # You'll need some way to authenticate to the server, and since
160    # password logins are disabled, you'll need some way of
161    # temporarily giving yourself credentials.  On a test server,
162    # reenabling password authentication is ok: frob /etc/pam.d/sshd
163    # and reverse apply r1068.
164
165# Replace rsyslog with syslog-ng by doing:
166    rpm -e --nodeps rsyslog
167    YUM install -y syslog-ng
168    chkconfig syslog-ng on
169
170# Install various dependencies of the scripts system, including
171# glibc-devel.i586 (ezyang: already installed for me),
172# python-twisted-core (ditto), mod_fcgid, nrpe, nagios-plugins-all.
173    YUM install -y mod_fcgid
174    YUM install -y nrpe
175    YUM install -y nagios-plugins-all
176
177# Disable NetworkManager with chkconfig NetworkManager off. Configure
178# networking on the front end and back end, and the routing table to send
179# traffic over the back end. Make sure that chkconfig reports "network" on, so
180# that the network will still be configured at next boot.
181# ezyang: For me, NetworkManager was not installed at this point, and
182# we had already done the basic config for networking front end and
183# back end (because I wanted ssh access, and not just conserver access)
184
185# Fix the openafs /usr/vice/etc <-> /etc/openafs mapping by changing
186#  /usr/vice/etc/cacheinfo to contain:
187#       /afs:/usr/vice/cache:10000000
188# Also fix ThisCell to contain athena.mit.edu in both directories
189# WARNING: if you're installing a test server, this needs to be much
190# smaller; the max filesize on XVM is 10GB.  Pick something like
191# 500000
192    echo "/afs:/usr/vice/cache:10000000" > /usr/vice/etc/cacheinfo
193    # ezyang: ThisCell on b-k and c-w don't have anything special
194    # written here
195# If you're making a test server, some of the AFS parameters are
196# kind of retarded (and if you're low on disk space, will actually
197# exhaust our inodes).
198# Edit the parameters in /etc/sysconfig/openafs
199
200# Figure out why Zephyr isn't working. Most recently, it was because there
201# was a 64-bit RPM installed; remove it and install Joe's 32-bit one
202    YUM erase -y mit-zephyr
203    # mit-zephyr has a spurious dependency on mit-krb-config
204    yumdownloader mit-zephyr.i386
205    # if deps change, this breaks
206    YUM install -y libXaw.i586 libXext.i586 libXmu.i586 ncurses-libs.i586 readline.i586
207    rpm -i --nodeps mit-zephyr-2.1-6-linux.i386.rpm
208    # test if it worked by sending an un-authed message
209    zwrite -d -c scripts -i test
210
211# Install the athena-base, athena-lprng, and athena-lprng-misc RPMs
212# from the Athena 9 build (these are present in our yum repo).  Note
213# that you will have to use --nodeps for at least one of the lprng
214# ones because it thinks it needs the Athena hesiod RPM.  It doesn't
215# really.  Before doing this, run it without --nodeps and arrange to
216# install the rest of the things it really does depend on.  This will
217# include a bunch of 32-bit rpms; go ahead and install the .i586 versions
218# of them.
219    YUM install -y athena-base
220    YUM install -y athena-lprng
221    yumdownloader athena-lprng-misc
222    # ezyang: I couldn't find any deps for this that existed in the repos
223    # You might get a "find: `/usr/athena/info': No such file or directory"
224    # error; this is fine
225    rpm -i --nodeps athena-lprng-misc-9.4-0.i386.rpm
226
227# Install the full list of RPMs that users expect to be on the
228# scripts.mit.edu servers.
229
230# on another server, run:
231rpm -qa --queryformat "%{Name}.%{Arch}\n" | sort > packages.txt
232# arrange for packages.txt to be passed to the server, then run:
233    # notice that yum is not capitalized
234    # Also notice skip-broken
235    cat packages.txt | NSS_NONLOCAL_IGNORE=1 xargs yum install -y --skip-broken
236
237# Check which packages are installed on your new server that are not
238# in the snapshot, and remove ones that aren't needed for some reason
239# on the new machine.  Otherwise, aside from bloat, you may end up
240# with undesirable things for security, like sendmail.
241    rpm -qa --queryformat "%{Name}.%{Arch}\n" | sort > newpackages.txt
242    diff -u packages.txt newpackages.txt  | less
243    # if all went well, you'll probably see multiple kernel versions
244    # as the only diff
245    # ezyang: I got exim installed as another package
246    # here's a cute script that removes all extra packages
247    diff -u packages.txt newpackages.txt  | grep '+' | cut -c2- | grep -v "@" | grep -v "++" | xargs yum erase -y
248
249# Check out the scripts /usr/vice/etc configuration
250    cd /root
251    mkdir vice
252    cd vice
253    svn co svn://scripts.mit.edu/trunk/server/fedora/config/usr/vice/etc etc
254    \cp -a etc /usr/vice
255
256# Install the full list of perl modules that users expect to be on the
257# scripts.mit.edu servers.
258# - export PERL_MM_USE_DEFAULT=1
259# - Run 'cpan', accept the default configuration, and do 'o conf
260#   prerequisites_policy follow'.
261# - Parse the output of perldoc -u perllocal | grep head2 on an existing
262#   server, and "notest install" them from the cpan prompt.
263# TO DO THIS:
264# On another server, run:
265# perldoc -u perllocal | grep head2 | cut -f 3 -d '<' | cut -f 1 -d '|' | sort -u | perl -ne 'chomp; print "notest install $_\n" if system("rpm -q --whatprovides \"perl($_)\" >/dev/null 2>/dev/null")' > /mit/scripts/config/perl-packages.txt
266# Then on the server you're installing,
267#    cat perl-packages.txt | perl -MCPAN -e shell
268    export PERL_MM_USE_DEFAULT=1
269    # XXX: Some interactive gobbeldygook
270    cpan
271        o conf prerequisites_policy follow
272        o conf commit
273# on a reference server
274perldoc -u perllocal | grep head2 | cut -f 3 -d '<' | cut -f 1 -d '|' | sort -u | perl -ne 'chomp; print "notest install $_\n" if system("rpm -q --whatprovides \"perl($_)\" >/dev/null 2>/dev/null")' > perl-packages.txt
275# arrange for perl-packages.txt to be transferred to server
276    cat perl-packages.txt | perl -MCPAN -e shell
277
278# Install the Python eggs and Ruby gems and PEAR/PECL doohickeys that are on
279# the other scripts.mit.edu servers and do not have RPMs.
280# The general mode of operation will be to run the "list" command
281# on both servers, see what the differences are, check if those diffs
282# are packaged up as rpms, and install them (rpm if possible, native otherwise)
283# - Look at /usr/lib/python2.6/site-packages and
284#           /usr/lib64/python2.6/site-packages for Python eggs and modules.
285#   There will be a lot of gunk that was installed from packages;
286#   easy-install.pth will tell you what was easy_installed.
287#   First use 'yum search' to see if the relevant package is now available
288#   as an RPM, and install that if it is.  If not, then use easy_install.
289#   Pass -Z to easy_install to install them unzipped, as some zipped eggs
290#   want to be able to write to ~/.python-eggs.  (Also makes sourcediving
291#   easier.)
292# - Look at `gem list` for Ruby gems.
293#   Again, use 'yum search' and prefer RPMs, but failing that, 'gem install'.
294#       ezyang: rspec-rails depends on rspec, and will override the Yum
295#       package, so... don't use that RPM yet
296# - Look at `pear list` for Pear fruits (or whatever they're called).
297#   Yet again, 'yum search' for RPMs before resorting to 'pear install'.  Note
298#   that for things in the beta repo, you'll need 'pear install package-beta'.
299#   (you might get complaints about the php_scripts module; ignore them)
300# - Look at `pecl list` for PECL things.  'yum search', and if you must,
301#   'pecl install' needed items. If it doesn't work, try 'pear install
302#   pecl/foo' or 'pecl install foo-beta' or those two combined.
303    # Automating this... will require a lot of batonning between
304    # the servers. Probably best way to do it is to write an actual
305    # script.
306
307# Setup some Python config
308    echo 'import site, os.path; site.addsitedir(os.path.expanduser("~/lib/python2.6/site-packages"))' > /usr/lib/python2.6/site-packages/00scripts-home.pth
309
310# Install the credentials.  There are a lot of things to remember here:
311#   o This will be different if you're setting up our build/update server.
312#   o You probably installed the machine keytab long ago
313    ls -l /etc/krb5.keytab
314#   o Use ktutil to combine the host/scripts.mit.edu and
315#     host/scripts-vhosts.mit.edu keys with host/this-server.mit.edu in
316#     the keytab.  Do not use 'k5srvutil change' on the combined keytab
317#     or you'll break the other servers. (real servers only)
318#   o The daemon.scripts keytab
319    ls -l /etc/daemon.keytab
320#   o The SSL cert private key (real servers only)
321#   o The LDAP password for the signup process (real servers only)
322#   o The SQL password for the signup process (real servers only)
323#   o The whoisd password (real servers only)
324#   o The LDAP keytab for this server, which will be used later (real servers only)
325#   o Replace the ssh host keys with the ones common to all scripts servers (real servers only)
326#   o You'll install an LDAP certificate signed by the scripts CA later (real servers only)
327#   o Make sure root's .k5login is correct
328    cat /root/.k5login
329#   o Make sure logview's .k5login is correct (real servers only)
330
331# If you are setting up a test server, pay attention to
332# /etc/sysconfig/network-scripts and do not bind scripts' IP address.
333# You will also need to modify:
334#   o /etc/ldap.conf
335#       add: host scripts.mit.edu
336#   o /etc/nss-ldapd.conf
337#       replace: uri *****
338#       with: uri ldap://scripts.mit.edu/
339#   o /etc/openldap/ldap.conf
340#       add: URI ldap://scripts.mit.edu/
341#            BASE dc=scripts,dc=mit,dc=edu
342#   o /etc/httpd/conf.d/vhost_ldap.conf
343#       replace: VhostLDAPUrl ****
344#       with: VhostLDAPUrl "ldap://scripts.mit.edu/ou=VirtualHosts,dc=scripts,dc=mit,dc=edu"
345#   o /etc/postfix/virtual-alias-{domains,maps}-ldap.cf
346#       replace: server_host *****
347#       with: server_host = ldap://scripts.mit.edu
348# to use scripts.mit.edu instead of localhost.
349# XXX: someone should write sed scripts to do this
350
351# If you are setting up a test server, afsagent's cronjob will attempt
352# to be renewing with the wrong credentials (daemon.scripts). Change this:
353    vim /home/afsagent/renew # replace all mentions of daemon.scripts.mit.edu
354
355# Install 389-ds-base and set up replication (see ./HOWTO-SETUP-LDAP
356#   and ./389-ds-enable-ssl-and-kerberos.diff).
357
358# Make the services dirsrv, nslcd, nscd, postfix, and httpd start at
359# boot. Run chkconfig to make sure the set of services to be run is
360# correct.
361    chkconfig dirsrv on
362    chkconfig nslcd on
363    chkconfig nscd on
364    chkconfig postfix on
365    chkconfig httpd on
366
367# Postfix doesn't actually deliver mail; fix this
368    cd /etc/postfix
369    postmap virtual
370
371# Munin might not be monitoring packages that were installed after it
372    munin-node-configure --suggest --shell | sh
373
374# Run fmtutil-sys --all, which does something that makes TeX work.
375    fmtutil-sys --all
376    # ezyang: I got errors on xetex
377
378# Ensure that PHP isn't broken:
379    mkdir /tmp/sessions
380    chmod 01777 /tmp/sessions
381
382# Ensure fcgid isn't broken
383    chmod 755 /var/run/mod_fcgid # ezyang: I suspect this is no longer necessary
384
385# Fix etc by making sure none of our config files got overwritten
386    cd /etc
387    svn status | grep M
388    # ezyang: I had to revert krb5.conf (not with latest), nsswitch.conf and sysconfig/openafs
389
390# ThisCell got clobbered, replace it with athena.mit.edu
391    echo "athena.mit.edu" > /usr/vice/etc/ThisCell
392
393# Reboot the machine to restore a consistent state, in case you
394# changed anything.
395    # ezyang: When I rebooted, the following things happened:
396    #   o Starting kdump failed (this is ok)
397    #   o postfix mailbombed us
398    #   o firstboot configuration screen popped up (ignored; manually will do
399    #     chkconfig after the fact)
400
401# (Optional) Beat your head against a wall.
402
403# Possibly perform other steps that I've neglected to put in this
404# document.
405#   o For some reason, syslog-ng wasn't turning on automatically, so we weren't
406#     getting spew
407
408# Some info about changing hostnames: it appears to be in:
409#   o /etc/sysconfig/network
410#   o your lvm thingies; probably don't need to edit
411
412# More stuff for test servers
413#   - You need a self-signed SSL cert.  Generate with:
414    openssl req -new -x509 -keyout /etc/pki/tls/private/scripts.key -out /etc/pki/tls/certs/scripts.cert -nodes
415#     Also make /etc/pki/tls/certs/ca.pem match up
416#   - Make (/etc/aliases) root mail go to /dev/null, so we don't spam people
417#   - Edit /etc/httpd/conf.d/scripts-vhost-names.conf to have scripts-fX-test.xvm.mit.edu
418#     be an accepted vhost name
419#   - Look at the old test server and see what config changes are floating around
420
421# XXX: our SVN checkout should be updated to use scripts.mit.edu
422# (repository and etc)
Note: See TracBrowser for help on using the repository browser.