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

Last change on this file since 1664 was 1661, checked in by ezyang, 12 years ago
Mass documentation update.
File size: 15.9 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
[1661]5# Some commands should be run as the scripts-build user, not root.
6
7alias asbuild="sudo -u scripts-build"
8
9# Old versions of this install document advised setting
10# NSS_NONLOCAL_IGNORE=1 anytime you're setting up anything, e.g. using
11# yum, warning that useradd will query LDAP in a stupid way that makes
12# it hang forever.  As of Fedora 13, this does not seem to be a problem,
13# so it's been removed from the instructions.  If an install is hanging,
14# though, try adding NSS_NONLOCAL_IGNORE.
15
[1063]16[ -e /scripts-boot-count ] || echo 0 > /scripts-boot-count
17
[1661]18# This is actually just "pick an active scripts server".  It can't be
19# scripts.mit.edu because our networking config points that domain
20# at localhost, and if our server is not setup at that point things
21# will break.
[1620]22source_server="cats-whiskers.mit.edu"
[1063]23
24boot=${1:$(cat /scripts-boot-count)}
25
[1619]26# XXX: let 'branch' be the current svn branch you are on.  You want to
27# use trunk if your just installing a new server, and branches/fcXX-dev
28# if your preparing a server on a new Fedora release.
[1259]29
[1063]30doreboot() {
31    echo $(( $boot + 1 )) > /scripts-boot-count;
32    shutdown -r now "Rebooting for step $(cat /scripts-boot-count)"
33}
34
[1058]35# Helper files for the install are located in server/fedora/config.
[861]36
[1661]37# Start with a minimal install of Fedora.
[861]38
[1645]39# Take updates
[1661]40    yum update
[1645]41
[1063]42if [ $boot = 0 ]; then
[1619]43
[1661]44echo "--disabled" > /etc/sysconfig/system-config-firewall
[1056]45
[1381]46# Turn on network, so we can connect at boot
47chkconfig network on
48
[1058]49# Edit /etc/selinux/config so it has SELINUX=disabled and reboot.
[1063]50    sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config
51    doreboot
52fi
[861]53
[1063]54if [ $boot = 1 ]; then
55# Create a scripts-build user account, and set up rpm to build in
56# $HOME by doing a
57# cp config/home/scripts-build/.rpmmacros /home/scripts-build/
58# (If you just use the default setup, it will generate packages
59# in /usr/src/redhat.)
60    adduser scripts-build
61
[1058]62# Check out the scripts.mit.edu svn repository. Configure svn not to cache
63# credentials.
[387]64
[1661]65    yum install -y subversion
[1063]66
67    cd /srv
[1620]68    # We must use an explicit source_server while setting up the Scripts
69    # server, because once we load the Scripts /etc configuration,
70    # scripts.mit.edu will start resolving to localhost and
71    # updates/commits will stop working.  This will be switched to
72    # scripts.mit.edu at the end of the install process.
73    svn co svn://$source_server/$branch repository
[1063]74
[1661]75    sed -i 's/^\(# *\)?store-passwords.*/store-passwords = no/' /root/.subversion/config
76    sed -i 's/^\(# *\)?store-auth-creds.*/store-auth-creds = no/' /root/.subversion/config
[1063]77
78    chown -R scripts-build /srv/repository
79
[1661]80    asbuild svn up # generate the config file
81    asbuild sed -i 's/^\(# *\)?store-passwords.*/store-passwords = no/' /home/scripts-build/.subversion/config
82    asbuild sed -i 's/^\(# *\)?store-auth-creds.*/store-auth-creds = no/' /home/scripts-build/.subversion/config
83
[1058]84# cd to server/fedora in the svn repository.
[1063]85    cd /srv/repository/server/fedora
[387]86
[1058]87# Run "make install-deps" to install various prereqs.  Nonstandard
88# deps are in /mit/scripts/rpm.
[1661]89    yum install -y make
[1063]90    make install-deps
[1619]91    # You should pay close attention to the output of this command, and
[1661]92    # note if packages you think should exist don't exist anymore.
[387]93
[1645]94# Get some packages necessary for OpenAFS
[1661]95    yum install -y redhat-lsb
96    yum install -y autofs
[1645]97
[1661]98# Copy over root's dotfiles from one of the other machines.
99# Perhaps a useful change is to remove the default aliases
100    cd /root
101    ls -l .bashrc
102    ls -l .ldapvirc
103    ls -l .screenrc
104    ls -l .ssh
105    ls -l .vimrc
106    # Trying to scp from server to server won't work, as scp
107    # will attempt to negotiate a server-to-server connection.
108    # Instead, scp to your trusted machine as a temporary file,
109    # and then push to the other server
110
[1619]111# Add scripts-build to the group 'mock'
112    usermod -a -G mock scripts-build
113
[1063]114# Install bind
[1661]115    yum install -y bind
[934]116
[1063]117# Check out the scripts /etc configuration
118    cd /root
[1661]119    svn co svn://$source_server/$branch/server/fedora/config/etc etc
[1259]120    # backslash to make us not use the alias
[1063]121    \cp -a etc /
[785]122
[1381]123# NOTE: You will have just lost DNS resolution and the ability
124# to do password SSH in.  If you managed to botch this step without
125# having named setup, you can do a quick fix by frobbing /etc/resolv.conf
126# with a non 127.0.0.1 address for the DNS server.  Be sure to revert it once
127# you have named.
[1259]128
[1619]129# You can get password SSH back by editing /etc/ssh/sshd_config (allow
130# password auth) and /etc/pam.d/sshd (comment out the first three auth
[1645]131# lines).  However, you can also temporarily install krb5 and setup the
132# keytabs and k5login to get Kerberized authentication.
[1619]133
[1259]134    service named start
135    chkconfig named on
136
[1619]137# This is the point at which you should start updating scriptsified
138# packages for a new Fedora release.  Consult 'upgrade-tips' for more
139# information.
140
[1661]141    yum install -y scripts-base
[387]142
[1058]143# Reload the iptables config to take down the restrictive firewall
[1259]144    service iptables restart
[862]145
[1661]146# Check that fs sysname is correct.  You should see, among others,
147# 'amd64_fedoraX_scripts' (vary X) and 'scripts'. If it's not, you
148# probably did a distro upgrade and should update /etc/sysconfig/openafs.
149    fs sysname
[803]150
[1058]151# Replace rsyslog with syslog-ng by doing:
[1259]152    rpm -e --nodeps rsyslog
[1661]153    yum install -y syslog-ng
[1259]154    chkconfig syslog-ng on
[861]155
[1259]156# Install various dependencies of the scripts system, including
157# glibc-devel.i586 (ezyang: already installed for me),
158# python-twisted-core (ditto), mod_fcgid, nrpe, nagios-plugins-all.
[1661]159    yum install -y mod_fcgid
160    yum install -y nrpe
161    yum install -y nagios-plugins-all
162    yum install -y fprintd-pam
[788]163
[1661]164# Fix the openafs /usr/vice/etc <-> /etc/openafs mapping.
[1259]165    echo "/afs:/usr/vice/cache:10000000" > /usr/vice/etc/cacheinfo
[1661]166    echo "athena.mit.edu" > /usr/vice/etc/ThisCell
[788]167
[1661]168# [TEST SERVER] If you're installing a test server, this needs to be
169# much smaller; the max filesize on XVM is 10GB.  Pick something like
170# 500000. Also, some of the AFS parameters are kind of retarded (and if
171# you're low on disk space, will actually exhaust our inodes).  Edit
172# these parameters in /etc/sysconfig/openafs
173
[1645]174# Test that zephyr is working
175    chkconfig zhm on
176    service zhm start
177    echo 'Test!' | zwrite -d -c scripts -i test
[861]178
[1058]179# Install the full list of RPMs that users expect to be on the
[1259]180# scripts.mit.edu servers.
181rpm -qa --queryformat "%{Name}.%{Arch}\n" | sort > packages.txt
182# arrange for packages.txt to be passed to the server, then run:
[1661]183# --skip-broken will (usually) prevent you from having to sit through
184# several minutes of dependency resolution until it decides that
185# it can't install /one/ package.
186    cat packages.txt | xargs yum install -y --skip-broken
[1259]187
[1190]188# Check which packages are installed on your new server that are not
189# in the snapshot, and remove ones that aren't needed for some reason
190# on the new machine.  Otherwise, aside from bloat, you may end up
191# with undesirable things for security, like sendmail.
[1661]192    rpm -qa --queryformat "%{Name}.%{Arch}\n" | grep -v kernel | sort > newpackages.txt
193    diff -u packages.txt newpackages.txt | grep -v kernel | less
[1382]194    # here's a cute script that removes all extra packages
[1661]195    diff -u packages.txt newpackages.txt | grep -v kernel | grep '+' | cut -c2- | grep -v "@" | grep -v "++" | xargs yum erase -y
[1190]196
[1661]197# We need an upstream version of cgi which we've packaged ourselves, but
198# it doesn't work with the haskell-platform package which expects
199# explicit versions.  So temporarily rpm -e the package, and then
200# install it again after you install haskell-platform.  [Note: You
201# probably won't need this in Fedora 15 or something, when the Haskell
202# Platform gets updated.]
203    rpm -e ghc-cgi-devel ghc-cgi
204    yum install haskell-platform
205    yumdownloader ghc-cgi
206    yumdownloader ghc-cgi-devel
207    rpm -i ghc-cgi*.rpm
208    rpm -i ghc-cgi-devel*.rpm
209
[1237]210# Check out the scripts /usr/vice/etc configuration
211    cd /root
212    mkdir vice
213    cd vice
[1645]214    svn co svn://scripts.mit.edu/$branch/server/fedora/config/usr/vice/etc etc
[1237]215    \cp -a etc /usr/vice
216
[1058]217# Install the full list of perl modules that users expect to be on the
[1108]218# scripts.mit.edu servers.
[1259]219    export PERL_MM_USE_DEFAULT=1
[1661]220    cpan # this is interactive, enter the next two lines
[1259]221        o conf prerequisites_policy follow
222        o conf commit
223# on a reference server
224perldoc -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
225# arrange for perl-packages.txt to be transferred to server
226    cat perl-packages.txt | perl -MCPAN -e shell
[812]227
[1058]228# Install the Python eggs and Ruby gems and PEAR/PECL doohickeys that are on
229# the other scripts.mit.edu servers and do not have RPMs.
[1259]230# The general mode of operation will be to run the "list" command
231# on both servers, see what the differences are, check if those diffs
232# are packaged up as rpms, and install them (rpm if possible, native otherwise)
[1178]233# - Look at /usr/lib/python2.6/site-packages and
234#           /usr/lib64/python2.6/site-packages for Python eggs and modules.
[1259]235#   There will be a lot of gunk that was installed from packages;
[1661]236#   easy-install.pth in /usr/lib/ will tell you what was easy_installed.
[1178]237#   First use 'yum search' to see if the relevant package is now available
238#   as an RPM, and install that if it is.  If not, then use easy_install.
[1432]239#   Pass -Z to easy_install to install them unzipped, as some zipped eggs
240#   want to be able to write to ~/.python-eggs.  (Also makes sourcediving
241#   easier.)
[1058]242# - Look at `gem list` for Ruby gems.
[1178]243#   Again, use 'yum search' and prefer RPMs, but failing that, 'gem install'.
[1259]244#       ezyang: rspec-rails depends on rspec, and will override the Yum
245#       package, so... don't use that RPM yet
[1058]246# - Look at `pear list` for Pear fruits (or whatever they're called).
[1178]247#   Yet again, 'yum search' for RPMs before resorting to 'pear install'.  Note
248#   that for things in the beta repo, you'll need 'pear install package-beta'.
[1259]249#   (you might get complaints about the php_scripts module; ignore them)
[1190]250# - Look at `pecl list` for PECL things.  'yum search', and if you must,
[1462]251#   'pecl install' needed items. If it doesn't work, try 'pear install
[1544]252#   pecl/foo' or 'pecl install foo-beta' or those two combined.
[1259]253    # Automating this... will require a lot of batonning between
254    # the servers. Probably best way to do it is to write an actual
255    # script.
[785]256
[1259]257# Setup some Python config
258    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]259
[1645]260# Install the credentials.  There are a lot of things to remember here.
261# Be sure to make sure the permissions match up (ls -l on an existing
262# server!).
[1259]263#   o This will be different if you're setting up our build/update server.
[1178]264#   o You probably installed the machine keytab long ago
[1259]265    ls -l /etc/krb5.keytab
[1645]266#     Use ktutil to combine the host/scripts.mit.edu and
[1178]267#     host/scripts-vhosts.mit.edu keys with host/this-server.mit.edu in
268#     the keytab.  Do not use 'k5srvutil change' on the combined keytab
[1645]269#     or you'll break the other servers. (real servers only).  Be
270#     careful about writing out the keytab: if you write it to an
271#     existing file the keys will just get appended
[1178]272#   o The daemon.scripts keytab
[1259]273    ls -l /etc/daemon.keytab
274#   o The SSL cert private key (real servers only)
[1645]275    ls -l /etc/pki/tls/private/scripts.key
[1259]276#   o The LDAP password for the signup process (real servers only)
[1645]277    ls -l /etc/signup-ldap-pw
278#   o The SQL password for the signup process (real servers only) (you
[1661]279#     only need one, chown as sql user)
[1645]280    ls -l /usr/local/etc/sql-mit-edu.cfg.php
281    ls -l /etc/sql-mit-edu.cfg.php
[1320]282#   o The whoisd password (real servers only)
[1661]283    ls -l /etc/whoisd-password
[1645]284#   o The LDAP keytab for this server, which will be used later (real
285#     servers only).
286    ls -l /etc/dirsrv/keytab
[1259]287#   o Replace the ssh host keys with the ones common to all scripts servers (real servers only)
[1645]288    ls -l /etc/ssh/*key*
[1178]289#   o Make sure root's .k5login is correct
[1259]290    cat /root/.k5login
291#   o Make sure logview's .k5login is correct (real servers only)
[1645]292    cat /home/logview/.k5login
[387]293
[1661]294# [TEST SERVER] If you are setting up a test server, pay attention to
[1058]295# /etc/sysconfig/network-scripts and do not bind scripts' IP address.
[1259]296# You will also need to modify:
297#   o /etc/ldap.conf
298#       add: host scripts.mit.edu
299#   o /etc/nss-ldapd.conf
300#       replace: uri *****
301#       with: uri ldap://scripts.mit.edu/
302#   o /etc/openldap/ldap.conf
303#       add: URI ldap://scripts.mit.edu/
304#            BASE dc=scripts,dc=mit,dc=edu
305#   o /etc/httpd/conf.d/vhost_ldap.conf
306#       replace: VhostLDAPUrl ****
307#       with: VhostLDAPUrl "ldap://scripts.mit.edu/ou=VirtualHosts,dc=scripts,dc=mit,dc=edu"
[1450]308#   o /etc/postfix/virtual-alias-{domains,maps}-ldap.cf
309#       replace: server_host *****
310#       with: server_host = ldap://scripts.mit.edu
[1259]311# to use scripts.mit.edu instead of localhost.
312# XXX: someone should write sed scripts to do this
[562]313
[1661]314# [TEST SERVER] If you are setting up a test server, afsagent's cronjob
315# will attempt to be renewing with the wrong credentials
316# (daemon.scripts). Change this:
[1259]317    vim /home/afsagent/renew # replace all mentions of daemon.scripts.mit.edu
318
[1661]319# Install 389-ds-base and set up replication (see ./install-ldap).
320    yum install 389-ds-base
321    # [complicated procedure here]
[785]322
[1058]323# Make the services dirsrv, nslcd, nscd, postfix, and httpd start at
324# boot. Run chkconfig to make sure the set of services to be run is
325# correct.
[1259]326    chkconfig dirsrv on
327    chkconfig nslcd on
328    chkconfig nscd on
329    chkconfig postfix on
330    chkconfig httpd on
[818]331
[1259]332# Postfix doesn't actually deliver mail; fix this
333    cd /etc/postfix
334    postmap virtual
[1178]335
[1451]336# Munin might not be monitoring packages that were installed after it
337    munin-node-configure --suggest --shell | sh
338
[1058]339# Run fmtutil-sys --all, which does something that makes TeX work.
[1661]340# (Note: this errors on XeTeX which is ok.)
[1259]341    fmtutil-sys --all
[803]342
[1058]343# Ensure that PHP isn't broken:
[1259]344    mkdir /tmp/sessions
345    chmod 01777 /tmp/sessions
[954]346
[1661]347# Ensure fcgid isn't broken (should be 755)
348    ls -l /var/run/mod_fcgid
[1259]349
350# Fix etc by making sure none of our config files got overwritten
351    cd /etc
[1661]352    svn status -q
353    # Some usual candidates for clobbering include nsswitch.conf and
354    # sysconfig/openafs
[1259]355
[1382]356# ThisCell got clobbered, replace it with athena.mit.edu
357    echo "athena.mit.edu" > /usr/vice/etc/ThisCell
358
[1661]359# Kill unnecessary services. (It's probably good form to look through
360# `chkconfig | grep on` manually)
361    for i in avahi-daemon isdn nfslock pcscd rpcbind rpcgssd rpcidmapd; do
362        chkconfig "$i" off
363    done
364
[1058]365# Reboot the machine to restore a consistent state, in case you
[1661]366# changed anything. (Note: Starting kdump fails (this is ok))
[875]367
[1661]368# [OPTIONAL] Your machine's hostname is baked in at install time;
369# in the rare case you need to change it: it appears to be in:
[1259]370#   o /etc/sysconfig/network
371#   o your lvm thingies; probably don't need to edit
[1382]372
[1661]373# [TEST SERVER] More stuff for test servers
[1382]374#   - You need a self-signed SSL cert.  Generate with:
375    openssl req -new -x509 -keyout /etc/pki/tls/private/scripts.key -out /etc/pki/tls/certs/scripts.cert -nodes
376#     Also make /etc/pki/tls/certs/ca.pem match up
377#   - Make (/etc/aliases) root mail go to /dev/null, so we don't spam people
378#   - Edit /etc/httpd/conf.d/scripts-vhost-names.conf to have scripts-fX-test.xvm.mit.edu
379#     be an accepted vhost name
380#   - Look at the old test server and see what config changes are floating around
[1620]381
382# XXX: our SVN checkout should be updated to use scripts.mit.edu
[1645]383# (repository and etc) once serving actually works.
[1661]384    cd /etc
385    svn switch --relocate svn://$source_server/ svn://scripts.mit.edu/
386    cd /usr/vice/etc
387    svn switch --relocate svn://$source_server/ svn://scripts.mit.edu/
388    cd /srv/repository
389    asbuild svn switch --relocate svn://$source_server/ svn://scripts.mit.edu/
390    asbuild svn up # verify scripts.mit.edu works
Note: See TracBrowser for help on using the repository browser.