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

Last change on this file since 1661 was 1661, checked in by ezyang, 12 years ago
Mass documentation update.
File size: 15.9 KB
Line 
1# This document is a how-to for installing a Fedora scripts.mit.edu server.
2
3set -e -x
4
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
16[ -e /scripts-boot-count ] || echo 0 > /scripts-boot-count
17
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.
22source_server="cats-whiskers.mit.edu"
23
24boot=${1:$(cat /scripts-boot-count)}
25
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.
29
30doreboot() {
31    echo $(( $boot + 1 )) > /scripts-boot-count;
32    shutdown -r now "Rebooting for step $(cat /scripts-boot-count)"
33}
34
35# Helper files for the install are located in server/fedora/config.
36
37# Start with a minimal install of Fedora.
38
39# Take updates
40    yum update
41
42if [ $boot = 0 ]; then
43
44echo "--disabled" > /etc/sysconfig/system-config-firewall
45
46# Turn on network, so we can connect at boot
47chkconfig network on
48
49# Edit /etc/selinux/config so it has SELINUX=disabled and reboot.
50    sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config
51    doreboot
52fi
53
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
62# Check out the scripts.mit.edu svn repository. Configure svn not to cache
63# credentials.
64
65    yum install -y subversion
66
67    cd /srv
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
74
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
77
78    chown -R scripts-build /srv/repository
79
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
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.
93
94# Get some packages necessary for OpenAFS
95    yum install -y redhat-lsb
96    yum install -y autofs
97
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
111# Add scripts-build to the group 'mock'
112    usermod -a -G mock scripts-build
113
114# Install bind
115    yum install -y bind
116
117# Check out the scripts /etc configuration
118    cd /root
119    svn co svn://$source_server/$branch/server/fedora/config/etc etc
120    # backslash to make us not use the alias
121    \cp -a etc /
122
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.
128
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
131# lines).  However, you can also temporarily install krb5 and setup the
132# keytabs and k5login to get Kerberized authentication.
133
134    service named start
135    chkconfig named on
136
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
141    yum install -y scripts-base
142
143# Reload the iptables config to take down the restrictive firewall
144    service iptables restart
145
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
150
151# Replace rsyslog with syslog-ng by doing:
152    rpm -e --nodeps rsyslog
153    yum install -y syslog-ng
154    chkconfig syslog-ng on
155
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.
159    yum install -y mod_fcgid
160    yum install -y nrpe
161    yum install -y nagios-plugins-all
162    yum install -y fprintd-pam
163
164# Fix the openafs /usr/vice/etc <-> /etc/openafs mapping.
165    echo "/afs:/usr/vice/cache:10000000" > /usr/vice/etc/cacheinfo
166    echo "athena.mit.edu" > /usr/vice/etc/ThisCell
167
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
174# Test that zephyr is working
175    chkconfig zhm on
176    service zhm start
177    echo 'Test!' | zwrite -d -c scripts -i test
178
179# Install the full list of RPMs that users expect to be on the
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:
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
187
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.
192    rpm -qa --queryformat "%{Name}.%{Arch}\n" | grep -v kernel | sort > newpackages.txt
193    diff -u packages.txt newpackages.txt | grep -v kernel | less
194    # here's a cute script that removes all extra packages
195    diff -u packages.txt newpackages.txt | grep -v kernel | grep '+' | cut -c2- | grep -v "@" | grep -v "++" | xargs yum erase -y
196
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
210# Check out the scripts /usr/vice/etc configuration
211    cd /root
212    mkdir vice
213    cd vice
214    svn co svn://scripts.mit.edu/$branch/server/fedora/config/usr/vice/etc etc
215    \cp -a etc /usr/vice
216
217# Install the full list of perl modules that users expect to be on the
218# scripts.mit.edu servers.
219    export PERL_MM_USE_DEFAULT=1
220    cpan # this is interactive, enter the next two lines
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
227
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.
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)
233# - Look at /usr/lib/python2.6/site-packages and
234#           /usr/lib64/python2.6/site-packages for Python eggs and modules.
235#   There will be a lot of gunk that was installed from packages;
236#   easy-install.pth in /usr/lib/ will tell you what was easy_installed.
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.
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.)
242# - Look at `gem list` for Ruby gems.
243#   Again, use 'yum search' and prefer RPMs, but failing that, 'gem install'.
244#       ezyang: rspec-rails depends on rspec, and will override the Yum
245#       package, so... don't use that RPM yet
246# - Look at `pear list` for Pear fruits (or whatever they're called).
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'.
249#   (you might get complaints about the php_scripts module; ignore them)
250# - Look at `pecl list` for PECL things.  'yum search', and if you must,
251#   'pecl install' needed items. If it doesn't work, try 'pear install
252#   pecl/foo' or 'pecl install foo-beta' or those two combined.
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.
256
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
259
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!).
263#   o This will be different if you're setting up our build/update server.
264#   o You probably installed the machine keytab long ago
265    ls -l /etc/krb5.keytab
266#     Use ktutil to combine the host/scripts.mit.edu and
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
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
272#   o The daemon.scripts keytab
273    ls -l /etc/daemon.keytab
274#   o The SSL cert private key (real servers only)
275    ls -l /etc/pki/tls/private/scripts.key
276#   o The LDAP password for the signup process (real servers only)
277    ls -l /etc/signup-ldap-pw
278#   o The SQL password for the signup process (real servers only) (you
279#     only need one, chown as sql user)
280    ls -l /usr/local/etc/sql-mit-edu.cfg.php
281    ls -l /etc/sql-mit-edu.cfg.php
282#   o The whoisd password (real servers only)
283    ls -l /etc/whoisd-password
284#   o The LDAP keytab for this server, which will be used later (real
285#     servers only).
286    ls -l /etc/dirsrv/keytab
287#   o Replace the ssh host keys with the ones common to all scripts servers (real servers only)
288    ls -l /etc/ssh/*key*
289#   o Make sure root's .k5login is correct
290    cat /root/.k5login
291#   o Make sure logview's .k5login is correct (real servers only)
292    cat /home/logview/.k5login
293
294# [TEST SERVER] If you are setting up a test server, pay attention to
295# /etc/sysconfig/network-scripts and do not bind scripts' IP address.
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"
308#   o /etc/postfix/virtual-alias-{domains,maps}-ldap.cf
309#       replace: server_host *****
310#       with: server_host = ldap://scripts.mit.edu
311# to use scripts.mit.edu instead of localhost.
312# XXX: someone should write sed scripts to do this
313
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:
317    vim /home/afsagent/renew # replace all mentions of daemon.scripts.mit.edu
318
319# Install 389-ds-base and set up replication (see ./install-ldap).
320    yum install 389-ds-base
321    # [complicated procedure here]
322
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.
326    chkconfig dirsrv on
327    chkconfig nslcd on
328    chkconfig nscd on
329    chkconfig postfix on
330    chkconfig httpd on
331
332# Postfix doesn't actually deliver mail; fix this
333    cd /etc/postfix
334    postmap virtual
335
336# Munin might not be monitoring packages that were installed after it
337    munin-node-configure --suggest --shell | sh
338
339# Run fmtutil-sys --all, which does something that makes TeX work.
340# (Note: this errors on XeTeX which is ok.)
341    fmtutil-sys --all
342
343# Ensure that PHP isn't broken:
344    mkdir /tmp/sessions
345    chmod 01777 /tmp/sessions
346
347# Ensure fcgid isn't broken (should be 755)
348    ls -l /var/run/mod_fcgid
349
350# Fix etc by making sure none of our config files got overwritten
351    cd /etc
352    svn status -q
353    # Some usual candidates for clobbering include nsswitch.conf and
354    # sysconfig/openafs
355
356# ThisCell got clobbered, replace it with athena.mit.edu
357    echo "athena.mit.edu" > /usr/vice/etc/ThisCell
358
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
365# Reboot the machine to restore a consistent state, in case you
366# changed anything. (Note: Starting kdump fails (this is ok))
367
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:
370#   o /etc/sysconfig/network
371#   o your lvm thingies; probably don't need to edit
372
373# [TEST SERVER] More stuff for test servers
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
381
382# XXX: our SVN checkout should be updated to use scripts.mit.edu
383# (repository and etc) once serving actually works.
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.