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

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