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

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