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

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