source: trunk/server/doc/install-howto.sh @ 1983

Last change on this file since 1983 was 1961, checked in by ezyang, 13 years ago
Split up install instructions for different types.
File size: 18.6 KB
Line 
1# This document is a how-to for installing a Fedora scripts.mit.edu server.
2# It is semi-vaguely in the form of a shell script, but is not really
3# runnable as it stands.
4
5# Notation
6# [PRODUCTION] Production server that will be put into the pool
7# [WIZARD]     Semi-production server that will only have
8#              daemon.scripts-security-upd bits, among other
9#              restricted permissions bits, among other
10#              restricted permissions bits, among other
11#              restricted permissions bits, among other
12#              restricted permissions
13# [TESTSERVER] Completely untrusted server
14
15set -e -x
16
17# Some commands should be run as the scripts-build user, not root.
18
19alias asbuild="sudo -u scripts-build"
20
21# Old versions of this install document advised setting
22# NSS_NONLOCAL_IGNORE=1 anytime you're setting up anything, e.g. using
23# yum, warning that useradd will query LDAP in a stupid way that makes
24# it hang forever.  As of Fedora 13, this does not seem to be a problem,
25# so it's been removed from the instructions.  If an install is hanging,
26# though, try adding NSS_NONLOCAL_IGNORE.
27
28# This is actually just "pick an active scripts server".  It can't be
29# scripts.mit.edu because our networking config points that domain
30# at localhost, and if our server is not setup at that point things
31# will break.
32source_server="shining-armor.mit.edu"
33
34# 'branch' is the current svn branch you are on.  You want to
35# use trunk if your just installing a new server, and branches/fcXX-dev
36# if your preparing a server on a new Fedora release.
37branch="trunk"
38
39# 'server' is the public hostname of your server, for SCP'ing files
40# to and from.
41server=YOUR-SERVER-NAME-HERE
42
43# Start with a Scripts kickstarted install of Fedora (install-fedora)
44
45# Take updates, reboot if there's a kernel update.
46    yum update -y
47
48# Get rid of network manager
49    yum remove NetworkManager
50
51# Copy over root's dotfiles from one of the other machines.
52# Perhaps a useful change is to remove the default aliases
53    cd /root
54    ls -l .bashrc
55    ls -l .screenrc
56    ls -l .ssh
57    ls -l .vimrc
58    ls -l .k5login
59    # [PRODUCTION] This rc file has sensitive data on it and should only
60    # be pushed onto production servers.
61    ls -l .ldapvirc
62    # Trying to scp from server to server won't work, as scp
63    # will attempt to negotiate a server-to-server connection.
64    # Instead, scp to your trusted machine as a temporary file,
65    # and then push to the other server
66scp -r root@$source_server:~/{.bashrc,.screenrc,.ssh,.vimrc,.k5login} .
67scp -r {.bashrc,.screenrc,.ssh,.vimrc,.k5login} root@$server:~
68# [PRODUCTION]
69scp root@$source_server:~/.ldapvirc .
70scp .ldapvirc root@$server:~
71
72# Install the initial set of credentials (to get Kerberized logins once
73# krb5 is installed).  Otherwise, SCP'ing things in will be annoying.
74#   o Install the machine keytab.
75    ls -l /etc/krb5.keytab
76#     Use ktutil to combine the host/scripts.mit.edu and
77#     host/scripts-vhosts.mit.edu keys with host/this-server.mit.edu in
78#     the keytab.  Do not use 'k5srvutil change' on the combined keytab
79#     or you'll break the other servers. (real servers only).  Be
80#     careful about writing out the keytab: if you write it to an
81#     existing file the keys will just get appended.  The correct
82#     credential list should look like:
83#       ktutil:  l
84#       slot KVNO Principal
85#       ---- ---- ---------------------------------------------------------------------
86#          1    5 host/old-faithful.mit.edu@ATHENA.MIT.EDU
87#          2    3 host/scripts-vhosts.mit.edu@ATHENA.MIT.EDU
88#          3    2      host/scripts.mit.edu@ATHENA.MIT.EDU
89#   o [PRODUCTION] Replace the ssh host keys with the ones common to all
90#     scripts servers (real servers only)
91    ls -l /etc/ssh/*key*
92#     You can do that with:
93scp root@$source_server:/etc/ssh/*key* .
94scp *key* root@$server:/etc/ssh/
95    service sshd reload
96
97# Check out the scripts /etc configuration
98    # backslash to make us not use the alias
99    cd /root
100    \cp -a etc /
101    chmod 0440 /etc/sudoers
102
103# [PRODUCTION] If this is the first time you've installed this hostname,
104# you will need to update a bunch of files to add support for it. These
105# include:
106#   o Adding all aliases to /etc/httpd/conf.d/scripts-vhost-names.conf
107#     (usually this is hostname, hostname.mit.edu, h-n, h-n.mit.edu,
108#     scriptsN, scriptsN.mit.edu, and the IP address.)
109#   o Adding routing rules for the static IP in
110#     /etc/sysconfig/network-scripts/route-eth1
111#   o Adding the IP address to the hosts file (same hosts as for
112#     scripts-vhost-names)
113#   o Update SSH config at
114#       - server/fedora/config/etc/ssh/shosts.equiv
115#       - server/fedora/config/etc/ssh/ssh_known_hosts
116#       - server/fedora/config/etc/ssh/sshd_config : DenyUsers
117#     (the last part is critical to ensure that rooting one server
118#     doesn't give you root to all the other servers)
119#   o Put the hostname information in LDAP so SVN and Git work
120#   o Set up Nagios monitoring on sipb-noc for the host
121#   o Set up the host as in the pool on r-b/r-b /etc/heartbeat/ldirectord.cf
122    XXX TODO COMMANDS
123
124# NOTE: You will have just lost DNS resolution and the ability
125# to do password SSH in.  If you managed to botch this step without
126# having named setup, you can do a quick fix by frobbing /etc/resolv.conf
127# with a non 127.0.0.1 address for the DNS server.  Be sure to revert it once
128# you have named.
129
130# NOTE: You can get password SSH back by editing /etc/ssh/sshd_config (allow
131# password auth) and /etc/pam.d/sshd (comment out the first three auth
132# lines).  However, you should have the Kerberos credentials in place
133# so as soon as you install the full set of Scripts packages, you'll get
134# Kerberized logins.
135
136# Make sure network is working.  If this is a new server name, you'll
137# need to add it to /etc/hosts and
138# /etc/sysconfig/network-scripts/route-eth1.  Kickstart should have
139# configured eth0 and eth1 correctly; use service network restart
140# to add the new routes in route-eth1.
141    service network restart
142    route
143    ifconfig
144    cat /etc/hosts
145    cat /etc/sysconfig/network-scripts/route-eth1
146
147# This is the point at which you should start updating scriptsified
148# packages for a new Fedora release.  Consult 'upgrade-tips' for more
149# information.
150    yum install -y scripts-base
151    # Some of these packages are naughty and clobber some of our files
152    cd /etc
153    svn revert resolv.conf hosts sysconfig/openafs
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# [PRODUCTION/WIZARD] Fix the openafs /usr/vice/etc <-> /etc/openafs
161# mapping.
162    echo "/afs:/usr/vice/cache:10000000" > /usr/vice/etc/cacheinfo
163    echo "athena.mit.edu" > /usr/vice/etc/ThisCell
164
165# [TESTSERVER] If you're installing a test server, this needs to be
166# much smaller; the max filesize on XVM is 10GB.  Pick something like
167# 500000. Also, some of the AFS parameters are kind of retarded (and if
168# you're low on disk space, will actually exhaust our inodes).  Edit
169# these parameters in /etc/sysconfig/openafs
170    echo "/afs:/usr/vice/cache:500000" > /usr/vice/etc/cacheinfo
171    XXX TODO COMMANDS
172
173# Test that zephyr is working
174    chkconfig zhm on
175    service zhm start
176    echo 'Test!' | zwrite -d -c scripts -i test
177
178# Install the full list of RPMs that users expect to be on the
179# scripts.mit.edu servers.
180rpm -qa --queryformat "%{Name}.%{Arch}\n" | sort > packages.txt
181# arrange for packages.txt to be passed to the server, then run:
182# --skip-broken will (usually) prevent you from having to sit through
183# several minutes of dependency resolution until it decides that
184# it can't install /one/ package.
185    yum install -y --skip-broken $(cat packages.txt)
186
187# Make sure sendmail isn't installed
188    yum remove sendmail
189
190# Check which packages are installed on your new server that are not
191# in the snapshot, and remove ones that aren't needed for some reason
192# on the new machine.  Otherwise, aside from bloat, you may end up
193# with undesirable things for security, like sendmail.
194    rpm -qa --queryformat "%{Name}.%{Arch}\n" | grep -v kernel | sort > newpackages.txt
195    diff -u packages.txt newpackages.txt | grep -v kernel | less
196    # here's a cute script that removes all extra packages
197    yum erase -y $(grep -Fxvf packages.txt newpackages.txt)
198    # 20101208 - Mysteriously we manage to get these extra packages
199    # from kickstart: mcelog mobile-broadband-provider-info
200    # ModemManager PackageKit
201
202# We need an upstream version of cgi which we've packaged ourselves, but
203# it doesn't work with the haskell-platform package which expects
204# explicit versions.  So temporarily rpm -e the package, and then
205# install it again after you install haskell-platform.  [Note: You
206# probably won't need this in Fedora 15 or something, when the Haskell
207# Platform gets updated.]
208    rpm -e ghc-cgi-devel ghc-cgi
209    yum install -y haskell-platform
210    yumdownloader ghc-cgi
211    yumdownloader ghc-cgi-devel
212    rpm -i ghc-cgi*1.8.1*.rpm
213
214# Check out the scripts /usr/vice/etc configuration
215    cd /root/vice
216    \cp -a etc /usr/vice
217
218# Install the full list of perl modules that users expect to be on the
219# scripts.mit.edu servers.
220    cd /root
221    export PERL_MM_USE_DEFAULT=1
222    cpan # this is interactive, enter the next two lines
223        o conf prerequisites_policy follow
224        o conf commit
225# on a reference server
226perldoc -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
227# arrange for perl-packages.txt to be transferred to server
228    cat perl-packages.txt | perl -MCPAN -e shell
229
230# Install the Python eggs and Ruby gems and PEAR/PECL doohickeys that are on
231# the other scripts.mit.edu servers and do not have RPMs.
232# The general mode of operation will be to run the "list" command
233# on both servers, see what the differences are, check if those diffs
234# are packaged up as rpms, and install them (rpm if possible, native otherwise)
235# - Look at /usr/lib/python2.6/site-packages and
236#           /usr/lib64/python2.6/site-packages for Python eggs and modules.
237#   There will be a lot of gunk that was installed from packages;
238#   easy-install.pth in /usr/lib/ will tell you what was easy_installed.
239#   First use 'yum search' to see if the relevant package is now available
240#   as an RPM, and install that if it is.  If not, then use easy_install.
241#   Pass -Z to easy_install to install them unzipped, as some zipped eggs
242#   want to be able to write to ~/.python-eggs.  (Also makes sourcediving
243#   easier.)
244cat /usr/lib/python2.6/site-packages/easy-install.pth | grep "^./" | cut -c3- | cut -f1 -d- > egg.txt
245    cat egg.txt | xargs easy_install -Z
246# - Look at `gem list` for Ruby gems.
247#   Again, use 'yum search' and prefer RPMs, but failing that, 'gem install'.
248#       ezyang: rspec-rails depends on rspec, and will override the Yum
249#       package, so... don't use that RPM yet
250gem list --no-version > gem.txt
251    gem install $(gem list --no-version | grep -Fxvf - gem.txt)
252# - Look at `pear list` for Pear fruits (or whatever they're called).
253#   Yet again, 'yum search' for RPMs before resorting to 'pear install'.  Note
254#   that for things in the beta repo, you'll need 'pear install package-beta'.
255#   (you might get complaints about the php_scripts module; ignore them)
256pear list | tail -n +4 | cut -f 1 -d " " > pear.txt
257    pear config-set preferred_state beta
258    pear channel-update pear.php.net
259    pear install $(pear list | tail -n +4 | cut -f 1 -d " " | grep -Fxvf - pear.txt)
260# - Look at `pecl list` for PECL things.  'yum search', and if you must,
261#   'pecl install' needed items. If it doesn't work, try 'pear install
262#   pecl/foo' or 'pecl install foo-beta' or those two combined.
263pecl list | tail -n +4 | cut -f 1 -d " " > pecl.txt
264    pecl install --nodeps $(pecl list | tail -n +4 | cut -f 1 -d " " | grep -Fxvf - pecl.txt)
265
266# Setup some Python config
267    echo 'import site, os.path; site.addsitedir(os.path.expanduser("~/lib/python2.6/site-packages"))' > /usr/lib/python2.6/site-packages/00scripts-home.pth
268
269# [PRODUCTION] Install the credentials.  There are a lot of things to
270# remember here.  Be sure to make sure the permissions match up (ls -l
271# on an existing server!).
272scp root@$source_server:{/etc/{sql-mit-edu.cfg.php,pki/tls/private/scripts.key,signup-ldap-pw,whoisd-password},/home/logview/.k5login} .
273scp signup-ldap-pw whoisd-password sql-mit-edu.cfg.php root@$server:/etc
274scp scripts.key root@$server:/etc/pki/tls/private
275scp .k5login root@$server:/home/logview
276#   o The SSL cert private key (real servers only)
277    ls -l /etc/pki/tls/private/scripts.key
278#   o The LDAP password for the signup process (real servers only)
279    ls -l /etc/signup-ldap-pw
280#   o The whoisd password (real servers only)
281    ls -l /etc/whoisd-password
282#   o Make sure logview's .k5login is correct (real servers only)
283    cat /home/logview/.k5login
284
285# All types of servers will have an /etc/daemon.keytab file, however,
286# different types of server will have different credentials in this
287# keytab.
288#   [PRODUCTION] daemon.scripts
289#   [WIZARD]     daemon.scripts-security-upd
290#   [TESTSERVER] daemon.scripts-test
291k5srvutil list -f daemon.keytab
292scp daemon.keytab root@$server:/etc
293    chown afsagent:afsagent /etc/daemon.keytab
294#   o The daemon.scripts keytab (will be daemon.scripts-test for test)
295    ls -l /etc/daemon.keytab
296
297# Spin up OpenAFS.  This will fail if there's been a new kernel since
298# when you last tried.  In that case, you can hold on till later to
299# start OpenAFS.  This will take a little bit of time;
300    service openafs-client start
301# Then, check that fs sysname is correct.  You should see, among others,
302# 'amd64_fedoraX_scripts' (vary X) and 'scripts'. If it's not, you
303# probably did a distro upgrade and should update /etc/sysconfig/openafs.
304    fs sysname
305
306# [WIZARD/TESTSERVER] If you are setting up a non-production server,
307# there are some services that it won't provide, and you will need to
308# make it talk to a real server instead.  In particular:
309#   - We don't serve the web, so don't bind scripts.mit.edu
310#   - We don't serve LDAP, so use another server
311# This involves editing the following files:
312#   o /etc/sysconfig/network-scripts/ifcfg-lo:0
313#   o /etc/sysconfig/network-scripts/ifcfg-lo:1
314#   o /etc/sysconfig/network-scripts/ifcfg-lo:2
315#   o /etc/sysconfig/network-scripts/ifcfg-lo:3
316       \rm /etc/sysconfig/network-scripts/ifcfg-lo:{0,1,2,3}
317#   o /etc/ldap.conf
318#       add: host scripts.mit.edu
319#   o /etc/{nss-ldapd,nslcd}.conf
320#       replace: uri ldapi://%2fvar%2frun%2fdirsrv%2fslapd-scripts.socket/
321#       with: uri ldap://scripts.mit.edu/
322#   o /etc/openldap/ldap.conf
323#       add: URI ldap://scripts.mit.edu/
324#            BASE dc=scripts,dc=mit,dc=edu
325#   o /etc/httpd/conf.d/vhost_ldap.conf
326#       replace: VhostLDAPUrl "ldap://127.0.0.1/ou=VirtualHosts,dc=scripts,dc=mit,dc=edu"
327#       with: VhostLDAPUrl "ldap://scripts.mit.edu/ou=VirtualHosts,dc=scripts,dc=mit,dc=edu"
328#   o /etc/postfix/virtual-alias-{domains,maps}-ldap.cf
329#       replace: server_host ldapi://%2fvar%2frun%2fdirsrv%2fslapd-scripts.socket/
330#       with: server_host = ldap://scripts.mit.edu
331# to use scripts.mit.edu instead of localhost.
332# XXX: someone should write sed scripts to do this
333
334# [WIZARD/TESTSERVER] If you are setting up a non-production server,
335# afsagent's cronjob will attempt to be renewing with the wrong
336# credentials (daemon.scripts). Change this:
337    vim /home/afsagent/renew # replace all mentions of daemon.scripts.mit.edu
338
339# [PRODUCTION] Set up replication (see ./install-ldap).
340# You'll need the LDAP keytab for this server: be sure to chown it
341# fedora-ds after you create the fedora-ds user
342    ls -l /etc/dirsrv/keytab
343    cat install-ldap
344
345# Make the services dirsrv, nslcd, nscd, postfix, and httpd start at
346# boot. Run chkconfig to make sure the set of services to be run is
347# correct.
348    service nslcd start
349    service nscd start
350    service postfix start
351    chkconfig nslcd on
352    chkconfig nscd on
353    chkconfig postfix on
354
355# [PRODUCTION]
356    chkconfig dirsrv on
357
358# [PRODUCTION/TESTSERVER]
359# (Maybe WIZARD too once we start doing strange things to autoupgrade
360# installs behind firewalls.)
361    service httpd start # will fail if AFS is not running
362    chkconfig httpd on
363
364# nrpe is required for nagios alerts
365    chkconfig nrpe on
366
367# [PRODUCTION] Check sql user credentials (needs to be done after LDAP
368# is setup)
369    chown sql /etc/sql-mit-edu.cfg.php
370
371# Postfix doesn't actually deliver mail; fix this
372    cd /etc/postfix
373    postmap virtual
374
375# Munin might not be monitoring packages that were installed after it
376    munin-node-configure --suggest --shell | sh
377
378# Run fmtutil-sys --all, which does something that makes TeX work.
379# (Note: this errors on XeTeX which is ok.)
380    fmtutil-sys --all
381
382# Ensure that PHP isn't broken:
383    mkdir /tmp/sessions
384    chmod 01777 /tmp/sessions
385    # XXX: this seems to get deleted if tmp gets cleaned up, so we
386    # might need something a little better (maybe init script.)
387
388# Ensure fcgid isn't broken (should be 755)
389    ls -ld /var/run/mod_fcgid
390
391# Fix etc by making sure none of our config files got overwritten
392    cd /etc
393    svn status -q
394    # Some usual candidates for clobbering include nsswitch.conf and
395    # sysconfig/openafs
396    # [WIZARD/TEST] Remember that changes you made should not get
397    # reverted!
398
399# ThisCell got clobbered, replace it with athena.mit.edu
400    echo "athena.mit.edu" > /usr/vice/etc/ThisCell
401
402# Reboot the machine to restore a consistent state, in case you
403# changed anything. (Note: Starting kdump fails (this is ok))
404
405# [OPTIONAL] Your machine's hostname is baked in at install time;
406# in the rare case you need to change it: it appears to be in:
407#   o /etc/sysconfig/network
408#   o your lvm thingies; probably don't need to edit
409
410# [TESTERVER]
411#   - You need a self-signed SSL cert or Apache will refuse to start
412#     or do SSL.  Generate with:
413    openssl req -new -x509 -keyout /etc/pki/tls/private/scripts.key -out /etc/pki/tls/certs/scripts.cert -nodes
414#     Also make /etc/pki/tls/certs/ca.pem match up (XXX what's the
415#     incant for that?)
416
417# [TESTSERVER] More stuff for test servers
418#   - Make (/etc/aliases) root mail go to /dev/null, so we don't spam people
419#   - Edit /etc/httpd/conf.d/scripts-vhost-names.conf to have scripts-fX-test.xvm.mit.edu
420#     be an accepted vhost name
421#   - Look at the old test server and see what config changes are floating around
422
423# XXX: our SVN checkout should be updated to use scripts.mit.edu
424# (repository and etc) once serving actually works.
425    cd /etc
426    svn switch --relocate svn://$source_server/ svn://scripts.mit.edu/
427    cd /usr/vice/etc
428    svn switch --relocate svn://$source_server/ svn://scripts.mit.edu/
429    cd /srv/repository
430    asbuild svn switch --relocate svn://$source_server/ svn://scripts.mit.edu/
431    asbuild svn up # verify scripts.mit.edu works
Note: See TracBrowser for help on using the repository browser.