source: branches/fc13-dev/server/doc/ @ 1660

Last change on this file since 1660 was 1645, checked in by ezyang, 14 years ago
Dramatically expand LDAP and installation documentation.
File size: 17.6 KB
1# This document is a how-to for installing a Fedora server.
3set -e -x
5[ -e /scripts-boot-count ] || echo 0 > /scripts-boot-count
7# This is actually just "pick an active scripts server"
10boot=${1:$(cat /scripts-boot-count)}
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.
16doreboot() {
17    echo $(( $boot + 1 )) > /scripts-boot-count;
18    shutdown -r now "Rebooting for step $(cat /scripts-boot-count)"
21YUM() {
22    NSS_NONLOCAL_IGNORE=1 yum "$@"
25# Helper files for the install are located in server/fedora/config.
27# Start with a normal install of Fedora.
29# Take updates
30    YUM update
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.
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
47# Turn on network, so we can connect at boot
48chkconfig network on
50# Edit /etc/selinux/config so it has SELINUX=disabled and reboot.
51    sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config
52    doreboot
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
63# Check out the svn repository. Configure svn not to cache
64# credentials.
66    YUM install -y subversion
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    # will start resolving to localhost and
72    # updates/commits will stop working.  This will be switched to
73    # at the end of the install process.
74    svn co svn://$source_server/$branch repository
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)
82    chown -R scripts-build /srv/repository
84# cd to server/fedora in the svn repository.
85    cd /srv/repository/server/fedora
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.
96# Get some packages necessary for OpenAFS
97    YUM install -y redhat-lsb
98    YUM install -y autofs
100# Add scripts-build to the group 'mock'
101    usermod -a -G mock scripts-build
103# Install bind
104    YUM install -y bind
106# Check out the scripts /etc configuration
107    cd /root
108    svn co svn://$branch/server/fedora/config/etc etc
109    # backslash to make us not use the alias
110    \cp -a etc /
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 address for the DNS server.  Be sure to revert it once
116# you have named.
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.
123    service named start
124    chkconfig named on
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.
130# env NSS_NONLOCAL_IGNORE=1 yum install scripts-base
131    YUM install -y scripts-base
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)
137# Reload the iptables config to take down the restrictive firewall
138    service iptables restart
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.
155# Replace rsyslog with syslog-ng by doing:
156    rpm -e --nodeps rsyslog
157    YUM install -y syslog-ng
158    chkconfig syslog-ng on
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
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)
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 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
191# Test that zephyr is working
192    chkconfig zhm on
193    service zhm start
194    echo 'Test!' | zwrite -d -c scripts -i test
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
212# Install the full list of RPMs that users expect to be on the
213# servers.
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
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
234# Check out the scripts /usr/vice/etc configuration
235    cd /root
236    mkdir vice
237    cd vice
238    svn co svn://$branch/server/fedora/config/usr/vice/etc etc
239    \cp -a etc /usr/vice
241# Install the full list of perl modules that users expect to be on the
242# 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
263# Install the Python eggs and Ruby gems and PEAR/PECL doohickeys that are on
264# the other 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.
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
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/ and
302#     host/ keys with host/ 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
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
333#   o /etc/nss-ldapd.conf
334#       replace: uri *****
335#       with: uri ldap://
336#   o /etc/openldap/ldap.conf
337#       add: URI ldap://
338#            BASE dc=scripts,dc=mit,dc=edu
339#   o /etc/httpd/conf.d/vhost_ldap.conf
340#       replace: VhostLDAPUrl ****
341#       with: VhostLDAPUrl "ldap://,dc=scripts,dc=mit,dc=edu"
342#   o /etc/postfix/virtual-alias-{domains,maps}
343#       replace: server_host *****
344#       with: server_host = ldap://
345# to use instead of localhost.
346# XXX: someone should write sed scripts to do this
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
352# Install 389-ds-base and set up replication (see ./HOWTO-SETUP-LDAP).
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
363# Postfix doesn't actually deliver mail; fix this
364    cd /etc/postfix
365    postmap virtual
367# Munin might not be monitoring packages that were installed after it
368    munin-node-configure --suggest --shell | sh
370# Run fmtutil-sys --all, which does something that makes TeX work.
371    fmtutil-sys --all
372    # ezyang: I got errors on xetex
374# Ensure that PHP isn't broken:
375    mkdir /tmp/sessions
376    chmod 01777 /tmp/sessions
378# Ensure fcgid isn't broken
379    chmod 755 /var/run/mod_fcgid # ezyang: I suspect this is no longer necessary
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
386# ThisCell got clobbered, replace it with
387    echo "" > /usr/vice/etc/ThisCell
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)
397# (Optional) Beat your head against a wall.
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
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
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
414#     be an accepted vhost name
415#   - Look at the old test server and see what config changes are floating around
417# XXX: our SVN checkout should be updated to use
418# (repository and etc) once serving actually works.
Note: See TracBrowser for help on using the repository browser.