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

Last change on this file since 1620 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
RevLine 
[1058]1# This document is a how-to for installing a Fedora scripts.mit.edu server.
[181]2
[1063]3set -e -x
4
5[ -e /scripts-boot-count ] || echo 0 > /scripts-boot-count
6
[1620]7# This is actually just "pick an active scripts server"
8source_server="cats-whiskers.mit.edu"
[1063]9
10boot=${1:$(cat /scripts-boot-count)}
11
[1619]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.
[1259]15
[1063]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
[1058]25# Helper files for the install are located in server/fedora/config.
[861]26
[1058]27# Start with a normal install of Fedora.
[861]28
[1063]29if [ $boot = 0 ]; then
[1058]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.
[1619]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.
[1063]39    echo "--disabled" > /etc/sysconfig/system-config-firewall
[1382]40    for i in NetworkManager avahi-daemon bluetooth cups isdn nfslock nfs pcscd restorecond rpcbind rpcgssd rpcidmapd sendmail; do
[1063]41        chkconfig "$i" off
42    done
[1056]43
[1381]44# Turn on network, so we can connect at boot
45chkconfig network on
46
[1058]47# Edit /etc/selinux/config so it has SELINUX=disabled and reboot.
[1063]48    sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config
49    doreboot
50fi
[861]51
[1063]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
[1058]60# Check out the scripts.mit.edu svn repository. Configure svn not to cache
61# credentials.
[387]62
[1063]63    YUM install -y subversion
64
65    cd /srv
[1620]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
[1063]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
[1237]75# The same tweaks should be made on /home/scripts-build/.subversion/config
76# once it exists (do something with svn as scripts-build)
[1063]77
78    chown -R scripts-build /srv/repository
79
[1058]80# cd to server/fedora in the svn repository.
[1063]81    cd /srv/repository/server/fedora
[387]82
[1058]83# Run "make install-deps" to install various prereqs.  Nonstandard
84# deps are in /mit/scripts/rpm.
[1259]85    YUM install -y make
[1063]86    make install-deps
[1619]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.
[387]91
[1619]92# Add scripts-build to the group 'mock'
93    usermod -a -G mock scripts-build
94
[1063]95# Install bind
96    YUM install -y bind
[934]97
[1063]98# Check out the scripts /etc configuration
99    cd /root
[1259]100    svn co svn://scripts.mit.edu/$branch/server/fedora/config/etc etc
101    # backslash to make us not use the alias
[1063]102    \cp -a etc /
[785]103
[1381]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.
[1259]109
[1619]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
[1259]114    service named start
115    chkconfig named on
116
[1619]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
[1259]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
[1619]136    # FC13: Check if they are necessary
[1259]137    rpm -i krb5-libs-*.i586.rpm
138    rpm -U --force krb5-libs-*.scripts.1138.x86_64.rpm
139
[1058]140# env NSS_NONLOCAL_IGNORE=1 yum install scripts-base
[1063]141    YUM install -y scripts-base
[387]142
[1058]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
[1259]145# that makes it hang forever. (This is why we're using YUM, not yum)
[881]146
[1058]147# Reload the iptables config to take down the restrictive firewall
[1259]148    service iptables restart
[862]149
[1058]150# Copy over root's dotfiles from one of the other machines.
[1259]151# Perhaps a useful change is to remove the default aliases
152    # On 2009-07-01, the dotfiles to transfer where:
[1381]153    #   .bashrc .ldapvirc (<- HAS PRIVILEDGED DATA)
154    #   .screenrc .ssh (<- directory) .vimrc
[1259]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
[1381]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.
[803]164
[1058]165# Replace rsyslog with syslog-ng by doing:
[1259]166    rpm -e --nodeps rsyslog
167    YUM install -y syslog-ng
168    chkconfig syslog-ng on
[861]169
[1259]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
[788]176
[1058]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.
[1259]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)
[788]184
[1058]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
[1178]188# Also fix ThisCell to contain athena.mit.edu in both directories
[1382]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
[1259]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
[1382]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
[788]199
[1058]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
[1259]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
[1381]206    YUM install -y libXaw.i586 libXext.i586 libXmu.i586 ncurses-libs.i586 readline.i586
[1259]207    rpm -i --nodeps mit-zephyr-2.1-6-linux.i386.rpm
[1381]208    # test if it worked by sending an un-authed message
209    zwrite -d -c scripts -i test
[861]210
[1178]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
[1259]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
[1178]226
[1058]227# Install the full list of RPMs that users expect to be on the
[1259]228# scripts.mit.edu servers.
[387]229
[1259]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
[1190]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.
[1259]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
[1382]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
[1190]248
[1237]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
[1058]256# Install the full list of perl modules that users expect to be on the
[1108]257# scripts.mit.edu servers.
[1058]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.
[1109]263# TO DO THIS:
264# On another server, run:
[1178]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
[1109]266# Then on the server you're installing,
[1190]267#    cat perl-packages.txt | perl -MCPAN -e shell
[1259]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
[812]277
[1058]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.
[1259]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)
[1178]283# - Look at /usr/lib/python2.6/site-packages and
284#           /usr/lib64/python2.6/site-packages for Python eggs and modules.
[1259]285#   There will be a lot of gunk that was installed from packages;
286#   easy-install.pth will tell you what was easy_installed.
[1178]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.
[1432]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.)
[1058]292# - Look at `gem list` for Ruby gems.
[1178]293#   Again, use 'yum search' and prefer RPMs, but failing that, 'gem install'.
[1259]294#       ezyang: rspec-rails depends on rspec, and will override the Yum
295#       package, so... don't use that RPM yet
[1058]296# - Look at `pear list` for Pear fruits (or whatever they're called).
[1178]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'.
[1259]299#   (you might get complaints about the php_scripts module; ignore them)
[1190]300# - Look at `pecl list` for PECL things.  'yum search', and if you must,
[1462]301#   'pecl install' needed items. If it doesn't work, try 'pear install
[1544]302#   pecl/foo' or 'pecl install foo-beta' or those two combined.
[1259]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.
[785]306
[1259]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
[812]309
[1178]310# Install the credentials.  There are a lot of things to remember here:
[1259]311#   o This will be different if you're setting up our build/update server.
[1178]312#   o You probably installed the machine keytab long ago
[1259]313    ls -l /etc/krb5.keytab
[1178]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
[1259]317#     or you'll break the other servers. (real servers only)
[1178]318#   o The daemon.scripts keytab
[1259]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)
[1320]323#   o The whoisd password (real servers only)
[1259]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)
[1178]327#   o Make sure root's .k5login is correct
[1259]328    cat /root/.k5login
329#   o Make sure logview's .k5login is correct (real servers only)
[387]330
[1058]331# If you are setting up a test server, pay attention to
332# /etc/sysconfig/network-scripts and do not bind scripts' IP address.
[1259]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"
[1450]345#   o /etc/postfix/virtual-alias-{domains,maps}-ldap.cf
346#       replace: server_host *****
347#       with: server_host = ldap://scripts.mit.edu
[1259]348# to use scripts.mit.edu instead of localhost.
349# XXX: someone should write sed scripts to do this
[562]350
[1259]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
[1296]355# Install 389-ds-base and set up replication (see ./HOWTO-SETUP-LDAP
356#   and ./389-ds-enable-ssl-and-kerberos.diff).
[785]357
[1058]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.
[1259]361    chkconfig dirsrv on
362    chkconfig nslcd on
363    chkconfig nscd on
364    chkconfig postfix on
365    chkconfig httpd on
[818]366
[1259]367# Postfix doesn't actually deliver mail; fix this
368    cd /etc/postfix
369    postmap virtual
[1178]370
[1451]371# Munin might not be monitoring packages that were installed after it
372    munin-node-configure --suggest --shell | sh
373
[1058]374# Run fmtutil-sys --all, which does something that makes TeX work.
[1259]375    fmtutil-sys --all
376    # ezyang: I got errors on xetex
[803]377
[1058]378# Ensure that PHP isn't broken:
[1259]379    mkdir /tmp/sessions
380    chmod 01777 /tmp/sessions
[954]381
[1481]382# Ensure fcgid isn't broken
[1482]383    chmod 755 /var/run/mod_fcgid # ezyang: I suspect this is no longer necessary
[1259]384
385# Fix etc by making sure none of our config files got overwritten
386    cd /etc
387    svn status | grep M
[1382]388    # ezyang: I had to revert krb5.conf (not with latest), nsswitch.conf and sysconfig/openafs
[1259]389
[1382]390# ThisCell got clobbered, replace it with athena.mit.edu
391    echo "athena.mit.edu" > /usr/vice/etc/ThisCell
392
[1058]393# Reboot the machine to restore a consistent state, in case you
394# changed anything.
[1259]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)
[875]400
[1058]401# (Optional) Beat your head against a wall.
[562]402
[1058]403# Possibly perform other steps that I've neglected to put in this
404# document.
[1259]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
[1382]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
[1620]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.