source: branches/fc15-dev/server/doc/install-howto.sh @ 2046

Last change on this file since 2046 was 2046, checked in by ezyang, 12 years ago
Massive doc updates.
File size: 15.8 KB
RevLine 
[1058]1# This document is a how-to for installing a Fedora scripts.mit.edu server.
[1693]2# It is semi-vaguely in the form of a shell script, but is not really
3# runnable as it stands.
[181]4
[1973]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
10# [TESTSERVER] Completely untrusted server
11
[1693]12# This is actually just "pick an active scripts server".  It can't be
13# scripts.mit.edu because our networking config points that domain
14# at localhost, and if our server is not setup at that point things
15# will break.
[1973]16source_server="shining-armor.mit.edu"
[1259]17
[1693]18# 'branch' is the current svn branch you are on.  You want to
19# use trunk if your just installing a new server, and branches/fcXX-dev
20# if your preparing a server on a new Fedora release.
21branch="trunk"
[1063]22
[1693]23# 'server' is the public hostname of your server, for SCP'ing files
24# to and from.
25server=YOUR-SERVER-NAME-HERE
[1063]26
[2046]27# ----------------------------->8--------------------------------------
28#                       FIRST TIME INSTRUCTIONS
29#
[1973]30# [PRODUCTION] If this is the first time you've installed this hostname,
31# you will need to update a bunch of files to add support for it. These
32# include:
[1696]33#   o Adding all aliases to /etc/httpd/conf.d/scripts-vhost-names.conf
34#     (usually this is hostname, hostname.mit.edu, h-n, h-n.mit.edu,
35#     scriptsN, scriptsN.mit.edu, and the IP address.)
36#   o Adding routing rules for the static IP in
37#     /etc/sysconfig/network-scripts/route-eth1
38#   o Adding the IP address to the hosts file (same hosts as for
39#     scripts-vhost-names)
[1704]40#   o Update SSH config at
41#       - server/fedora/config/etc/ssh/shosts.equiv
42#       - server/fedora/config/etc/ssh/ssh_known_hosts
43#       - server/fedora/config/etc/ssh/sshd_config : DenyUsers
44#     (the last part is critical to ensure that rooting one server
45#     doesn't give you root to all the other servers)
[1696]46#   o Put the hostname information in LDAP so SVN and Git work
47#   o Set up Nagios monitoring on sipb-noc for the host
48#   o Set up the host as in the pool on r-b/r-b /etc/heartbeat/ldirectord.cf
[2046]49#   o Update locker/etc/known_hosts
50#
51# You will also need to prepare the keytabs for credit-card.  In particular,
52# use ktutil to combine the host/scripts.mit.edu and
53# host/scripts-vhosts.mit.edu keys with host/this-server.mit.edu in
54# the keytab.  Do not use 'k5srvutil change' on the combined keytab
55# or you'll break the other servers. (real servers only).  Be
56# careful about writing out the keytab: if you write it to an
57# existing file the keys will just get appended.  The correct
58# credential list should look like:
59#   ktutil:  l
60#   slot KVNO Principal
61#   ---- ---- ---------------------------------------------------------------------
62#      1    5 host/old-faithful.mit.edu@ATHENA.MIT.EDU
63#      2    3 host/scripts-vhosts.mit.edu@ATHENA.MIT.EDU
64#      3    2      host/scripts.mit.edu@ATHENA.MIT.EDU
65#
66# The LDAP keytab should be by itself, so be sure to delete it and
67# put it in its own file.
68# ----------------------------->8--------------------------------------
[1696]69
[2046]70# Start with a Scripts kickstarted install of Fedora (install-fedora)
[1259]71
[2046]72# Take updates, reboot if there's a kernel update.
73    yum update -y
[1259]74
[2046]75# Get rid of network manager
76    yum remove NetworkManager
77
78# This is superseded by credit-card, but only for [PRODUCTION]
79# Don't use credit-card on [WIZARD]: it will put in the wrong creds!
80#
81#   # All types of servers will have an /etc/daemon.keytab file, however,
82#   # different types of server will have different credentials in this
83#   # keytab.
84#   #   [PRODUCTION] daemon.scripts
85#   #   [WIZARD]     daemon.scripts-security-upd
86#   #   [TESTSERVER] daemon.scripts-test
87
88# Check out the scripts /etc configuration
89    cd /root
90    \cp -a etc /
91    chmod 0440 /etc/sudoers
92
93# Make sure network is working.  Kickstart should have
[1693]94# configured eth0 and eth1 correctly; use service network restart
[2046]95# to add the new routes from etc in route-eth1.
96    systemctl restart network.service
97    # Check everything worked:
[1693]98    route
99    ifconfig
100    cat /etc/hosts
101    cat /etc/sysconfig/network-scripts/route-eth1
[1259]102
[1693]103# This is the point at which you should start updating scriptsified
104# packages for a new Fedora release.  Consult 'upgrade-tips' for more
105# information.
106    yum install -y scripts-base
107    # Some of these packages are naughty and clobber some of our files
108    cd /etc
109    svn revert resolv.conf hosts sysconfig/openafs
[1259]110
[1058]111# Replace rsyslog with syslog-ng by doing:
[1259]112    rpm -e --nodeps rsyslog
[1693]113    yum install -y syslog-ng
[2046]114    systemctl enable syslog-ng.service
[861]115
[1058]116# Install the full list of RPMs that users expect to be on the
[1259]117# scripts.mit.edu servers.
118rpm -qa --queryformat "%{Name}.%{Arch}\n" | sort > packages.txt
119# arrange for packages.txt to be passed to the server, then run:
[1693]120# --skip-broken will (usually) prevent you from having to sit through
121# several minutes of dependency resolution until it decides that
122# it can't install /one/ package.
123    yum install -y --skip-broken $(cat packages.txt)
[1259]124
[1698]125# Make sure sendmail isn't installed
126    yum remove sendmail
127
[1190]128# Check which packages are installed on your new server that are not
129# in the snapshot, and remove ones that aren't needed for some reason
130# on the new machine.  Otherwise, aside from bloat, you may end up
131# with undesirable things for security, like sendmail.
[1693]132    rpm -qa --queryformat "%{Name}.%{Arch}\n" | grep -v kernel | sort > newpackages.txt
133    diff -u packages.txt newpackages.txt | grep -v kernel | less
[1382]134    # here's a cute script that removes all extra packages
[1693]135    yum erase -y $(grep -Fxvf packages.txt newpackages.txt)
[1973]136    # 20101208 - Mysteriously we manage to get these extra packages
137    # from kickstart: mcelog mobile-broadband-provider-info
138    # ModemManager PackageKit
[1190]139
[1693]140# We need an upstream version of cgi which we've packaged ourselves, but
141# it doesn't work with the haskell-platform package which expects
142# explicit versions.  So temporarily rpm -e the package, and then
143# install it again after you install haskell-platform.  [Note: You
144# probably won't need this in Fedora 15 or something, when the Haskell
145# Platform gets updated.]
146    rpm -e ghc-cgi-devel ghc-cgi
147    yum install -y haskell-platform
148    yumdownloader ghc-cgi
149    yumdownloader ghc-cgi-devel
150    rpm -i ghc-cgi*1.8.1*.rpm
151
[2046]152# Note: Since ultimately we'd like to move away from using per-language
153# package manager and all of these be RPMs, it is of questionable
154# importance how much /good/ automation for these is necessary.
[1237]155
[2046]156# Warning: For a new release, we're supposed to check if Fedora has
157# packaged up the RPM.  Unfortunately we don't really have good incants
158# for this.
159
[1058]160# Install the full list of perl modules that users expect to be on the
[1108]161# scripts.mit.edu servers.
[1693]162    cd /root
[1259]163    export PERL_MM_USE_DEFAULT=1
[1693]164    cpan # this is interactive, enter the next two lines
[1259]165        o conf prerequisites_policy follow
166        o conf commit
167# on a reference server
168perldoc -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
169# arrange for perl-packages.txt to be transferred to server
170    cat perl-packages.txt | perl -MCPAN -e shell
[812]171
[1058]172# Install the Python eggs and Ruby gems and PEAR/PECL doohickeys that are on
173# the other scripts.mit.edu servers and do not have RPMs.
[1259]174# The general mode of operation will be to run the "list" command
175# on both servers, see what the differences are, check if those diffs
176# are packaged up as rpms, and install them (rpm if possible, native otherwise)
[1178]177# - Look at /usr/lib/python2.6/site-packages and
178#           /usr/lib64/python2.6/site-packages for Python eggs and modules.
[1259]179#   There will be a lot of gunk that was installed from packages;
[1693]180#   easy-install.pth in /usr/lib/ will tell you what was easy_installed.
[1178]181#   First use 'yum search' to see if the relevant package is now available
182#   as an RPM, and install that if it is.  If not, then use easy_install.
[1432]183#   Pass -Z to easy_install to install them unzipped, as some zipped eggs
184#   want to be able to write to ~/.python-eggs.  (Also makes sourcediving
185#   easier.)
[2046]186# 'easy_install AuthKit jsonlib2 pygit'
187cat /usr/lib/python2.7/site-packages/easy-install.pth | grep "^./" | cut -c3- | cut -f1 -d- > egg.txt
[1698]188    cat egg.txt | xargs easy_install -Z
[2046]189
[1058]190# - Look at `gem list` for Ruby gems.
[1178]191#   Again, use 'yum search' and prefer RPMs, but failing that, 'gem install'.
[1259]192#       ezyang: rspec-rails depends on rspec, and will override the Yum
193#       package, so... don't use that RPM yet
[2046]194# XXX This doesn't do the right thing for old version gems
[1693]195gem list --no-version > gem.txt
196    gem install $(gem list --no-version | grep -Fxvf - gem.txt)
[2046]197    # Also, we need to install the old rails version
198
[1058]199# - Look at `pear list` for Pear fruits (or whatever they're called).
[1178]200#   Yet again, 'yum search' for RPMs before resorting to 'pear install'.  Note
201#   that for things in the beta repo, you'll need 'pear install package-beta'.
[1259]202#   (you might get complaints about the php_scripts module; ignore them)
[1693]203pear list | tail -n +4 | cut -f 1 -d " " > pear.txt
204    pear config-set preferred_state beta
205    pear channel-update pear.php.net
206    pear install $(pear list | tail -n +4 | cut -f 1 -d " " | grep -Fxvf - pear.txt)
[2046]207
[1190]208# - Look at `pecl list` for PECL things.  'yum search', and if you must,
[1462]209#   'pecl install' needed items. If it doesn't work, try 'pear install
[1544]210#   pecl/foo' or 'pecl install foo-beta' or those two combined.
[1693]211pecl list | tail -n +4 | cut -f 1 -d " " > pecl.txt
212    pecl install --nodeps $(pecl list | tail -n +4 | cut -f 1 -d " " | grep -Fxvf - pecl.txt)
[785]213
[2046]214# ----------------------------->8--------------------------------------
215#                       INFINITE CONFIGURATION
[387]216
[2046]217# Run credit-card to clone in credentials and make things runabble
218python host.py push $server
[1973]219
[2046]220# [PRODUCTION/WIZARD] Fix the openafs /usr/vice/etc <-> /etc/openafs
221# mapping.
222    echo "/afs:/usr/vice/cache:10000000" > /usr/vice/etc/cacheinfo
223    echo "athena.mit.edu" > /usr/vice/etc/ThisCell
224# [TESTSERVER] If you're installing a test server, this needs to be
225# much smaller; the max filesize on XVM is 10GB.  Pick something like
226# 500000. Also, some of the AFS parameters are kind of retarded (and if
227# you're low on disk space, will actually exhaust our inodes).  Edit
228# these parameters in /etc/sysconfig/openafs
229    echo "/afs:/usr/vice/cache:500000" > /usr/vice/etc/cacheinfo
230    XXX TODO COMMANDS
[1693]231
[2046]232# Test that zephyr is working
233    systemctl enable zhm.service
234    systemctl start zhm.service
235    echo 'Test!' | zwrite -d -c scripts -i test
[562]236
[2046]237# Check out the scripts /usr/vice/etc configuration
238    cd /root/vice
239    \cp -a etc /usr/vice
[1259]240
[1973]241# [PRODUCTION] Set up replication (see ./install-ldap).
[1693]242# You'll need the LDAP keytab for this server: be sure to chown it
243# fedora-ds after you create the fedora-ds user
244    ls -l /etc/dirsrv/keytab
245    cat install-ldap
[785]246
[2046]247    systemctl enable openafs-client.service
248    systemctl enable dirsrv.service
249    systemctl enable nslcd.service
250    systemctl enable nscd.service
251    systemctl enable postfix.service
252    systemctl enable nrpe.service
253    systemctl enable httpd.service # not for [WIZARD]
[1973]254
[2046]255    systemctl start openafs-client.service
256    systemctl start dirsrv.service
257    systemctl start nslcd.service
258    systemctl start nscd.service
259    systemctl start postfix.service
260    systemctl start nrpe.service
261    systemctl start httpd.service # not for [WIZARD]
[1973]262
[2046]263# Note about OpenAFS: Check that fs sysname is correct.  You should see,
264# among others, 'amd64_fedoraX_scripts' (vary X) and 'scripts'. If it's
265# not, you probably did a distro upgrade and should update
266# /etc/sysconfig/openafs (XXX this is wrong: figuring out new
267# systemd world order).
268    fs sysname
[818]269
[1259]270# Postfix doesn't actually deliver mail; fix this
271    cd /etc/postfix
272    postmap virtual
[1178]273
[1451]274# Munin might not be monitoring packages that were installed after it
275    munin-node-configure --suggest --shell | sh
276
[1058]277# Run fmtutil-sys --all, which does something that makes TeX work.
[1693]278# (Note: this errors on XeTeX which is ok.)
[1259]279    fmtutil-sys --all
[803]280
[1058]281# Ensure that PHP isn't broken:
[1259]282    mkdir /tmp/sessions
283    chmod 01777 /tmp/sessions
[1699]284    # XXX: this seems to get deleted if tmp gets cleaned up, so we
285    # might need something a little better (maybe init script.)
[954]286
[1259]287# Fix etc by making sure none of our config files got overwritten
288    cd /etc
[1693]289    svn status -q
290    # Some usual candidates for clobbering include nsswitch.conf and
291    # sysconfig/openafs
[1973]292    # [WIZARD/TEST] Remember that changes you made should not get
293    # reverted!
[1259]294
[1382]295# ThisCell got clobbered, replace it with athena.mit.edu
296    echo "athena.mit.edu" > /usr/vice/etc/ThisCell
297
[1058]298# Reboot the machine to restore a consistent state, in case you
[1693]299# changed anything. (Note: Starting kdump fails (this is ok))
[875]300
[2046]301# When all is said and done, fix up the Subversion checkouts
302    cd /etc
303    svn switch --relocate svn://$source_server/ svn://scripts.mit.edu/
304    cd /usr/vice/etc
305    svn switch --relocate svn://$source_server/ svn://scripts.mit.edu/
306    cd /srv/repository
307    # Some commands should be run as the scripts-build user, not root.
308    alias asbuild="sudo -u scripts-build"
309    asbuild svn switch --relocate svn://$source_server/ svn://scripts.mit.edu/
310    asbuild svn up # verify scripts.mit.edu works
311
312# ------------------------------->8-------------------------------
313#                ADDENDA AND MISCELLANEOUS THINGS
314
[1693]315# [OPTIONAL] Your machine's hostname is baked in at install time;
316# in the rare case you need to change it: it appears to be in:
[1259]317#   o /etc/sysconfig/network
318#   o your lvm thingies; probably don't need to edit
[1382]319
[2046]320# [WIZARD/TESTSERVER] If you are setting up a non-production server,
321# there are some services that it won't provide, and you will need to
322# make it talk to a real server instead.  In particular:
323#   - We don't serve the web, so don't bind scripts.mit.edu
324#   - We don't serve LDAP, so use another server
325# This involves editing the following files:
326#   o /etc/sysconfig/network-scripts/ifcfg-lo:0
327#   o /etc/sysconfig/network-scripts/ifcfg-lo:1
328#   o /etc/sysconfig/network-scripts/ifcfg-lo:2
329#   o /etc/sysconfig/network-scripts/ifcfg-lo:3
330       \rm /etc/sysconfig/network-scripts/ifcfg-lo:{0,1,2,3}
331#   o /etc/ldap.conf
332#       add: host scripts.mit.edu
333#   o /etc/{nss-ldapd,nslcd}.conf
334#       replace: uri ldapi://%2fvar%2frun%2fdirsrv%2fslapd-scripts.socket/
335#       with: uri ldap://scripts.mit.edu/
336#   o /etc/openldap/ldap.conf
337#       add: URI ldap://scripts.mit.edu/
338#            BASE dc=scripts,dc=mit,dc=edu
339#   o /etc/httpd/conf.d/vhost_ldap.conf
340#       replace: VhostLDAPUrl "ldap://127.0.0.1/ou=VirtualHosts,dc=scripts,dc=mit,dc=edu"
341#       with: VhostLDAPUrl "ldap://scripts.mit.edu/ou=VirtualHosts,dc=scripts,dc=mit,dc=edu"
342#   o /etc/postfix/virtual-alias-{domains,maps}-ldap.cf
343#       replace: server_host ldapi://%2fvar%2frun%2fdirsrv%2fslapd-scripts.socket/
344#       with: server_host = ldap://scripts.mit.edu
345# to use scripts.mit.edu instead of localhost.
346# XXX: someone should write sed scripts to do this
347
348# [WIZARD/TESTSERVER] If you are setting up a non-production server,
349# afsagent's cronjob will attempt to be renewing with the wrong
350# credentials (daemon.scripts). Change this:
351    vim /home/afsagent/renew # replace all mentions of daemon.scripts.mit.edu
352
[1973]353# [TESTERVER]
354#   - You need a self-signed SSL cert or Apache will refuse to start
355#     or do SSL.  Generate with:
[1382]356    openssl req -new -x509 -keyout /etc/pki/tls/private/scripts.key -out /etc/pki/tls/certs/scripts.cert -nodes
[1973]357#     Also make /etc/pki/tls/certs/ca.pem match up (XXX what's the
358#     incant for that?)
359
360# [TESTSERVER] More stuff for test servers
[1382]361#   - Make (/etc/aliases) root mail go to /dev/null, so we don't spam people
362#   - Edit /etc/httpd/conf.d/scripts-vhost-names.conf to have scripts-fX-test.xvm.mit.edu
363#     be an accepted vhost name
364#   - Look at the old test server and see what config changes are floating around
Note: See TracBrowser for help on using the repository browser.