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

Last change on this file since 2047 was 2047, checked in by ezyang, 11 years ago
Slight reorganization.
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# Check out the scripts /etc configuration
82    cd /root
83    \cp -a etc /
84    chmod 0440 /etc/sudoers
85
86# Make sure network is working.  Kickstart should have
87# configured eth0 and eth1 correctly; use service network restart
88# to add the new routes from etc in route-eth1.
89    systemctl restart network.service
90    # Check everything worked:
91    route
92    ifconfig
93    cat /etc/hosts
94    cat /etc/sysconfig/network-scripts/route-eth1
95
96# This is the point at which you should start updating scriptsified
97# packages for a new Fedora release.  Consult 'upgrade-tips' for more
98# information.
99    yum install -y scripts-base
100    # Some of these packages are naughty and clobber some of our files
101    cd /etc
102    svn revert resolv.conf hosts sysconfig/openafs
103
104# Replace rsyslog with syslog-ng by doing:
105    rpm -e --nodeps rsyslog
106    yum install -y syslog-ng
107    systemctl enable syslog-ng.service
108
109# Install the full list of RPMs that users expect to be on the
110# scripts.mit.edu servers.
111rpm -qa --queryformat "%{Name}.%{Arch}\n" | sort > packages.txt
112# arrange for packages.txt to be passed to the server, then run:
113# --skip-broken will (usually) prevent you from having to sit through
114# several minutes of dependency resolution until it decides that
115# it can't install /one/ package.
116    yum install -y --skip-broken $(cat packages.txt)
117
118# Make sure sendmail isn't installed
119    yum remove sendmail
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 15 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
195# - Look at `pear list` for Pear fruits (or whatever they're called).
196#   Yet again, 'yum search' for RPMs before resorting to 'pear install'.  Note
197#   that for things in the beta repo, you'll need 'pear install package-beta'.
198#   (you might get complaints about the php_scripts module; ignore them)
199pear list | tail -n +4 | cut -f 1 -d " " > pear.txt
200    pear config-set preferred_state beta
201    pear channel-update pear.php.net
202    pear install $(pear list | tail -n +4 | cut -f 1 -d " " | grep -Fxvf - pear.txt)
203
204# - Look at `pecl list` for PECL things.  'yum search', and if you must,
205#   'pecl install' needed items. If it doesn't work, try 'pear install
206#   pecl/foo' or 'pecl install foo-beta' or those two combined.
207pecl list | tail -n +4 | cut -f 1 -d " " > pecl.txt
208    pecl install --nodeps $(pecl list | tail -n +4 | cut -f 1 -d " " | grep -Fxvf - pecl.txt)
209
210# ----------------------------->8--------------------------------------
211#                       INFINITE CONFIGURATION
212
213# Run credit-card to clone in credentials and make things runabble
214python host.py push $server
215
216# This is superseded by credit-card, but only for [PRODUCTION]
217# Don't use credit-card on [WIZARD]: it will put in the wrong creds!
218#
219#   # All types of servers will have an /etc/daemon.keytab file, however,
220#   # different types of server will have different credentials in this
221#   # keytab.
222#   #   [PRODUCTION] daemon.scripts
223#   #   [WIZARD]     daemon.scripts-security-upd
224#   #   [TESTSERVER] daemon.scripts-test
225
226# [PRODUCTION/WIZARD] Fix the openafs /usr/vice/etc <-> /etc/openafs
227# mapping.
228    echo "/afs:/usr/vice/cache:10000000" > /usr/vice/etc/cacheinfo
229    echo "athena.mit.edu" > /usr/vice/etc/ThisCell
230# [TESTSERVER] If you're installing a test server, this needs to be
231# much smaller; the max filesize on XVM is 10GB.  Pick something like
232# 500000. Also, some of the AFS parameters are kind of retarded (and if
233# you're low on disk space, will actually exhaust our inodes).  Edit
234# these parameters in /etc/sysconfig/openafs (but wait, that won't
235# work, will it...)
236    echo "/afs:/usr/vice/cache:500000" > /usr/vice/etc/cacheinfo
237    vim /etc/sysconfig/openafs
238
239# Test that zephyr is working
240    systemctl enable zhm.service
241    systemctl start zhm.service
242    echo 'Test!' | zwrite -d -c scripts -i test
243
244# Check out the scripts /usr/vice/etc configuration
245    cd /root/vice
246    \cp -a etc /usr/vice
247
248# [PRODUCTION] Set up replication (see ./install-ldap).
249# You'll need the LDAP keytab for this server: be sure to chown it
250# fedora-ds after you create the fedora-ds user
251    ls -l /etc/dirsrv/keytab
252    cat install-ldap
253
254# Enable lots of services
255    systemctl enable openafs-client.service
256    systemctl enable dirsrv.service
257    systemctl enable nslcd.service
258    systemctl enable nscd.service
259    systemctl enable postfix.service
260    systemctl enable nrpe.service
261    systemctl enable httpd.service # not for [WIZARD]
262
263    systemctl start openafs-client.service
264    systemctl start dirsrv.service
265    systemctl start nslcd.service
266    systemctl start nscd.service
267    systemctl start postfix.service
268    systemctl start nrpe.service
269    systemctl start httpd.service # not for [WIZARD]
270
271# Note about OpenAFS: Check that fs sysname is correct.  You should see,
272# among others, 'amd64_fedoraX_scripts' (vary X) and 'scripts'. If it's
273# not, you probably did a distro upgrade and should update
274# /etc/sysconfig/openafs (XXX this is wrong: figuring out new
275# systemd world order).
276    fs sysname
277
278# Postfix doesn't actually deliver mail; fix this
279    cd /etc/postfix
280    postmap virtual
281
282# Munin might not be monitoring packages that were installed after it
283    munin-node-configure --suggest --shell | sh
284
285# Run fmtutil-sys --all, which does something that makes TeX work.
286# (Note: this errors on XeTeX which is ok.)
287    fmtutil-sys --all
288
289# Ensure that PHP isn't broken:
290    mkdir /tmp/sessions
291    chmod 01777 /tmp/sessions
292    # XXX: this seems to get deleted if tmp gets cleaned up, so we
293    # might need something a little better (maybe init script.)
294
295# Fix etc by making sure none of our config files got overwritten
296    cd /etc
297    svn status -q
298    # Some usual candidates for clobbering include nsswitch.conf and
299    # sysconfig/openafs
300    # [WIZARD/TEST] Remember that changes you made should not get
301    # reverted!
302
303# ThisCell got clobbered, replace it with athena.mit.edu
304    echo "athena.mit.edu" > /usr/vice/etc/ThisCell
305
306# Reboot the machine to restore a consistent state, in case you
307# changed anything. (Note: Starting kdump fails (this is ok))
308
309# When all is said and done, fix up the Subversion checkouts
310    cd /etc
311    svn switch --relocate svn://$source_server/ svn://scripts.mit.edu/
312    cd /usr/vice/etc
313    svn switch --relocate svn://$source_server/ svn://scripts.mit.edu/
314    cd /srv/repository
315    # Some commands should be run as the scripts-build user, not root.
316    alias asbuild="sudo -u scripts-build"
317    asbuild svn switch --relocate svn://$source_server/ svn://scripts.mit.edu/
318    asbuild svn up # verify scripts.mit.edu works
319
320# ------------------------------->8-------------------------------
321#                ADDENDA AND MISCELLANEOUS THINGS
322
323# [OPTIONAL] Your machine's hostname is baked in at install time;
324# in the rare case you need to change it: it appears to be in:
325#   o /etc/sysconfig/network
326#   o your lvm thingies; probably don't need to edit
327
328# [WIZARD/TESTSERVER] If you are setting up a non-production server,
329# there are some services that it won't provide, and you will need to
330# make it talk to a real server instead.  In particular:
331#   - We don't serve the web, so don't bind scripts.mit.edu
332#   - We don't serve LDAP, so use another server
333# This involves editing the following files:
334#   o /etc/sysconfig/network-scripts/ifcfg-lo:0
335#   o /etc/sysconfig/network-scripts/ifcfg-lo:1
336#   o /etc/sysconfig/network-scripts/ifcfg-lo:2
337#   o /etc/sysconfig/network-scripts/ifcfg-lo:3
338       \rm /etc/sysconfig/network-scripts/ifcfg-lo:{0,1,2,3}
339#   o /etc/ldap.conf
340#       add: host scripts.mit.edu
341#   o /etc/{nss-ldapd,nslcd}.conf
342#       replace: uri ldapi://%2fvar%2frun%2fdirsrv%2fslapd-scripts.socket/
343#       with: uri ldap://scripts.mit.edu/
344#   o /etc/openldap/ldap.conf
345#       add: URI ldap://scripts.mit.edu/
346#            BASE dc=scripts,dc=mit,dc=edu
347#   o /etc/httpd/conf.d/vhost_ldap.conf
348#       replace: VhostLDAPUrl "ldap://127.0.0.1/ou=VirtualHosts,dc=scripts,dc=mit,dc=edu"
349#       with: VhostLDAPUrl "ldap://scripts.mit.edu/ou=VirtualHosts,dc=scripts,dc=mit,dc=edu"
350#   o /etc/postfix/virtual-alias-{domains,maps}-ldap.cf
351#       replace: server_host ldapi://%2fvar%2frun%2fdirsrv%2fslapd-scripts.socket/
352#       with: server_host = ldap://scripts.mit.edu
353# to use scripts.mit.edu instead of localhost.
354# XXX: someone should write sed scripts to do this
355
356# [WIZARD/TESTSERVER] If you are setting up a non-production server,
357# afsagent's cronjob will attempt to be renewing with the wrong
358# credentials (daemon.scripts). Change this:
359    vim /home/afsagent/renew # replace all mentions of daemon.scripts.mit.edu
360
361# [TESTERVER]
362#   - You need a self-signed SSL cert or Apache will refuse to start
363#     or do SSL.  Generate with:
364    openssl req -new -x509 -keyout /etc/pki/tls/private/scripts.key -out /etc/pki/tls/certs/scripts.cert -nodes
365#     Also make /etc/pki/tls/certs/ca.pem match up (XXX what's the
366#     incant for that?)
367
368# [TESTSERVER] More stuff for test servers
369#   - Make (/etc/aliases) root mail go to /dev/null, so we don't spam people
370#   - Edit /etc/httpd/conf.d/scripts-vhost-names.conf to have scripts-fX-test.xvm.mit.edu
371#     be an accepted vhost name
372#   - Look at the old test server and see what config changes are floating around
Note: See TracBrowser for help on using the repository browser.