source: branches/fc13-dev/server/doc/install-howto.sh @ 1668

Last change on this file since 1668 was 1668, checked in by ezyang, 11 years ago
Remove instructions obsoleted by kickstart.
File size: 14.7 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
5set -e -x
6
7# Some commands should be run as the scripts-build user, not root.
8
9alias asbuild="sudo -u scripts-build"
10
11# Old versions of this install document advised setting
12# NSS_NONLOCAL_IGNORE=1 anytime you're setting up anything, e.g. using
13# yum, warning that useradd will query LDAP in a stupid way that makes
14# it hang forever.  As of Fedora 13, this does not seem to be a problem,
15# so it's been removed from the instructions.  If an install is hanging,
16# though, try adding NSS_NONLOCAL_IGNORE.
17
18# This is actually just "pick an active scripts server".  It can't be
19# scripts.mit.edu because our networking config points that domain
20# at localhost, and if our server is not setup at that point things
21# will break.
22source_server="cats-whiskers.mit.edu"
23
24# 'branch' is the current svn branch you are on.  You want to
25# use trunk if your just installing a new server, and branches/fcXX-dev
26# if your preparing a server on a new Fedora release.
27branch="trunk"
28
29# Start with a Scripts kickstarted install of Fedora (install-fedora)
30
31# Take updates, reboot if there's a kernel update.
32
33    yum update
34
35# Check out the scripts.mit.edu svn repository. Configure svn not to cache
36# credentials.
37
38    cd /srv
39    # We must use an explicit source_server while setting up the Scripts
40    # server, because once we load the Scripts /etc configuration,
41    # scripts.mit.edu will start resolving to localhost and
42    # updates/commits will stop working.  This will be switched to
43    # scripts.mit.edu at the end of the install process.
44    svn co svn://$source_server/$branch repository
45
46    sed -i 's/^\(# *\)?store-passwords.*/store-passwords = no/' /root/.subversion/config
47    sed -i 's/^\(# *\)?store-auth-creds.*/store-auth-creds = no/' /root/.subversion/config
48
49    chown -R scripts-build /srv/repository
50
51    asbuild svn up # generate the config file
52    asbuild sed -i 's/^\(# *\)?store-passwords.*/store-passwords = no/' /home/scripts-build/.subversion/config
53    asbuild sed -i 's/^\(# *\)?store-auth-creds.*/store-auth-creds = no/' /home/scripts-build/.subversion/config
54
55# cd to server/fedora in the svn repository.
56    cd /srv/repository/server/fedora
57
58# Run "make install-deps" to install various prereqs.  Nonstandard
59# deps are in /mit/scripts/rpm.
60    make install-deps
61    # You should pay close attention to the output of this command, and
62    # note if packages you think should exist don't exist anymore.
63
64# Copy over root's dotfiles from one of the other machines.
65# Perhaps a useful change is to remove the default aliases
66    cd /root
67    ls -l .bashrc
68    ls -l .ldapvirc
69    ls -l .screenrc
70    ls -l .ssh
71    ls -l .vimrc
72    # Trying to scp from server to server won't work, as scp
73    # will attempt to negotiate a server-to-server connection.
74    # Instead, scp to your trusted machine as a temporary file,
75    # and then push to the other server
76
77# Check out the scripts /etc configuration
78    cd /root
79    svn co svn://$source_server/$branch/server/fedora/config/etc etc
80    # backslash to make us not use the alias
81    \cp -a etc /
82
83# NOTE: You will have just lost DNS resolution and the ability
84# to do password SSH in.  If you managed to botch this step without
85# having named setup, you can do a quick fix by frobbing /etc/resolv.conf
86# with a non 127.0.0.1 address for the DNS server.  Be sure to revert it once
87# you have named.
88
89# You can get password SSH back by editing /etc/ssh/sshd_config (allow
90# password auth) and /etc/pam.d/sshd (comment out the first three auth
91# lines).  However, you can also temporarily install krb5 and setup the
92# keytabs and k5login to get Kerberized authentication.
93
94# Make sure network is working.  If this is a new server name, you'll
95# need to add it to /etc/hosts and
96# /etc/sysconfig/network-scripts/route-eth1.  Kickstart should have
97# configured eth0 and eth1 correctly; use service network restart
98# to add the new routes in route-eth1.
99    route
100    ifconfig
101    cat /etc/hosts
102    cat /etc/sysconfig/network-scripts/route-eth1
103    service network restart
104
105# This is the point at which you should start updating scriptsified
106# packages for a new Fedora release.  Consult 'upgrade-tips' for more
107# information.
108
109    yum install -y scripts-base
110
111# Check that fs sysname is correct.  You should see, among others,
112# 'amd64_fedoraX_scripts' (vary X) and 'scripts'. If it's not, you
113# probably did a distro upgrade and should update /etc/sysconfig/openafs.
114    fs sysname
115
116# Replace rsyslog with syslog-ng by doing:
117    rpm -e --nodeps rsyslog
118    yum install -y syslog-ng
119    chkconfig syslog-ng on
120
121# Fix the openafs /usr/vice/etc <-> /etc/openafs mapping.
122    echo "/afs:/usr/vice/cache:10000000" > /usr/vice/etc/cacheinfo
123    echo "athena.mit.edu" > /usr/vice/etc/ThisCell
124
125# [TEST SERVER] If you're installing a test server, this needs to be
126# much smaller; the max filesize on XVM is 10GB.  Pick something like
127# 500000. Also, some of the AFS parameters are kind of retarded (and if
128# you're low on disk space, will actually exhaust our inodes).  Edit
129# these parameters in /etc/sysconfig/openafs
130
131# Test that zephyr is working
132    chkconfig zhm on
133    service zhm start
134    echo 'Test!' | zwrite -d -c scripts -i test
135
136# Install the full list of RPMs that users expect to be on the
137# scripts.mit.edu servers.
138rpm -qa --queryformat "%{Name}.%{Arch}\n" | sort > packages.txt
139# arrange for packages.txt to be passed to the server, then run:
140# --skip-broken will (usually) prevent you from having to sit through
141# several minutes of dependency resolution until it decides that
142# it can't install /one/ package.
143    cat packages.txt | xargs yum install -y --skip-broken
144
145# Check which packages are installed on your new server that are not
146# in the snapshot, and remove ones that aren't needed for some reason
147# on the new machine.  Otherwise, aside from bloat, you may end up
148# with undesirable things for security, like sendmail.
149    rpm -qa --queryformat "%{Name}.%{Arch}\n" | grep -v kernel | sort > newpackages.txt
150    diff -u packages.txt newpackages.txt | grep -v kernel | less
151    # here's a cute script that removes all extra packages
152    diff -u packages.txt newpackages.txt | grep -v kernel | grep '+' | cut -c2- | grep -v "@" | grep -v "++" | xargs yum erase -y
153
154# We need an upstream version of cgi which we've packaged ourselves, but
155# it doesn't work with the haskell-platform package which expects
156# explicit versions.  So temporarily rpm -e the package, and then
157# install it again after you install haskell-platform.  [Note: You
158# probably won't need this in Fedora 15 or something, when the Haskell
159# Platform gets updated.]
160    rpm -e ghc-cgi-devel ghc-cgi
161    yum install haskell-platform
162    yumdownloader ghc-cgi
163    yumdownloader ghc-cgi-devel
164    rpm -i ghc-cgi*.rpm
165    rpm -i ghc-cgi-devel*.rpm
166
167# Check out the scripts /usr/vice/etc configuration
168    cd /root
169    mkdir vice
170    cd vice
171    svn co svn://scripts.mit.edu/$branch/server/fedora/config/usr/vice/etc etc
172    \cp -a etc /usr/vice
173
174# Install the full list of perl modules that users expect to be on the
175# scripts.mit.edu servers.
176    export PERL_MM_USE_DEFAULT=1
177    cpan # this is interactive, enter the next two lines
178        o conf prerequisites_policy follow
179        o conf commit
180# on a reference server
181perldoc -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
182# arrange for perl-packages.txt to be transferred to server
183    cat perl-packages.txt | perl -MCPAN -e shell
184
185# Install the Python eggs and Ruby gems and PEAR/PECL doohickeys that are on
186# the other scripts.mit.edu servers and do not have RPMs.
187# The general mode of operation will be to run the "list" command
188# on both servers, see what the differences are, check if those diffs
189# are packaged up as rpms, and install them (rpm if possible, native otherwise)
190# - Look at /usr/lib/python2.6/site-packages and
191#           /usr/lib64/python2.6/site-packages for Python eggs and modules.
192#   There will be a lot of gunk that was installed from packages;
193#   easy-install.pth in /usr/lib/ will tell you what was easy_installed.
194#   First use 'yum search' to see if the relevant package is now available
195#   as an RPM, and install that if it is.  If not, then use easy_install.
196#   Pass -Z to easy_install to install them unzipped, as some zipped eggs
197#   want to be able to write to ~/.python-eggs.  (Also makes sourcediving
198#   easier.)
199    cat /usr/lib/python2.6/site-packages/easy-install.pth
200# - Look at `gem list` for Ruby gems.
201#   Again, use 'yum search' and prefer RPMs, but failing that, 'gem install'.
202#       ezyang: rspec-rails depends on rspec, and will override the Yum
203#       package, so... don't use that RPM yet
204    gem list
205# - Look at `pear list` for Pear fruits (or whatever they're called).
206#   Yet again, 'yum search' for RPMs before resorting to 'pear install'.  Note
207#   that for things in the beta repo, you'll need 'pear install package-beta'.
208#   (you might get complaints about the php_scripts module; ignore them)
209    pear list
210# - Look at `pecl list` for PECL things.  'yum search', and if you must,
211#   'pecl install' needed items. If it doesn't work, try 'pear install
212#   pecl/foo' or 'pecl install foo-beta' or those two combined.
213    pecl list
214# Automating this... will require a lot of batonning between
215# the servers. Probably best way to do it is to write an actual
216# script.
217
218# Setup some Python config
219    echo 'import site, os.path; site.addsitedir(os.path.expanduser("~/lib/python2.6/site-packages"))' > /usr/lib/python2.6/site-packages/00scripts-home.pth
220
221# Install the credentials.  There are a lot of things to remember here.
222# Be sure to make sure the permissions match up (ls -l on an existing
223# server!).
224#   o This will be different if you're setting up our build/update server.
225#   o You probably installed the machine keytab long ago
226    ls -l /etc/krb5.keytab
227#     Use ktutil to combine the host/scripts.mit.edu and
228#     host/scripts-vhosts.mit.edu keys with host/this-server.mit.edu in
229#     the keytab.  Do not use 'k5srvutil change' on the combined keytab
230#     or you'll break the other servers. (real servers only).  Be
231#     careful about writing out the keytab: if you write it to an
232#     existing file the keys will just get appended
233#   o The daemon.scripts keytab
234    ls -l /etc/daemon.keytab
235#   o The SSL cert private key (real servers only)
236    ls -l /etc/pki/tls/private/scripts.key
237#   o The LDAP password for the signup process (real servers only)
238    ls -l /etc/signup-ldap-pw
239#   o The SQL password for the signup process (real servers only) (you
240#     only need one, chown as sql user)
241    ls -l /usr/local/etc/sql-mit-edu.cfg.php
242    ls -l /etc/sql-mit-edu.cfg.php
243#   o The whoisd password (real servers only)
244    ls -l /etc/whoisd-password
245#   o The LDAP keytab for this server, which will be used later (real
246#     servers only).
247    ls -l /etc/dirsrv/keytab
248#   o Replace the ssh host keys with the ones common to all scripts servers (real servers only)
249    ls -l /etc/ssh/*key*
250#   o Make sure root's .k5login is correct
251    cat /root/.k5login
252#   o Make sure logview's .k5login is correct (real servers only)
253    cat /home/logview/.k5login
254
255# [TEST SERVER] If you are setting up a test server, pay attention to
256# /etc/sysconfig/network-scripts and do not bind scripts' IP address.
257# You will also need to modify:
258#   o /etc/ldap.conf
259#       add: host scripts.mit.edu
260#   o /etc/nss-ldapd.conf
261#       replace: uri *****
262#       with: uri ldap://scripts.mit.edu/
263#   o /etc/openldap/ldap.conf
264#       add: URI ldap://scripts.mit.edu/
265#            BASE dc=scripts,dc=mit,dc=edu
266#   o /etc/httpd/conf.d/vhost_ldap.conf
267#       replace: VhostLDAPUrl ****
268#       with: VhostLDAPUrl "ldap://scripts.mit.edu/ou=VirtualHosts,dc=scripts,dc=mit,dc=edu"
269#   o /etc/postfix/virtual-alias-{domains,maps}-ldap.cf
270#       replace: server_host *****
271#       with: server_host = ldap://scripts.mit.edu
272# to use scripts.mit.edu instead of localhost.
273# XXX: someone should write sed scripts to do this
274
275# [TEST SERVER] If you are setting up a test server, afsagent's cronjob
276# will attempt to be renewing with the wrong credentials
277# (daemon.scripts). Change this:
278    vim /home/afsagent/renew # replace all mentions of daemon.scripts.mit.edu
279
280# Set up replication (see ./install-ldap).
281    cat install-ldap
282
283# Make the services dirsrv, nslcd, nscd, postfix, and httpd start at
284# boot. Run chkconfig to make sure the set of services to be run is
285# correct.
286    chkconfig dirsrv on
287    chkconfig nslcd on
288    chkconfig nscd on
289    chkconfig postfix on
290    chkconfig httpd on
291
292# Postfix doesn't actually deliver mail; fix this
293    cd /etc/postfix
294    postmap virtual
295
296# Munin might not be monitoring packages that were installed after it
297    munin-node-configure --suggest --shell | sh
298
299# Run fmtutil-sys --all, which does something that makes TeX work.
300# (Note: this errors on XeTeX which is ok.)
301    fmtutil-sys --all
302
303# Ensure that PHP isn't broken:
304    mkdir /tmp/sessions
305    chmod 01777 /tmp/sessions
306
307# Ensure fcgid isn't broken (should be 755)
308    ls -l /var/run/mod_fcgid
309
310# Fix etc by making sure none of our config files got overwritten
311    cd /etc
312    svn status -q
313    # Some usual candidates for clobbering include nsswitch.conf and
314    # sysconfig/openafs
315
316# ThisCell got clobbered, replace it with athena.mit.edu
317    echo "athena.mit.edu" > /usr/vice/etc/ThisCell
318
319# Reboot the machine to restore a consistent state, in case you
320# changed anything. (Note: Starting kdump fails (this is ok))
321
322# [OPTIONAL] Your machine's hostname is baked in at install time;
323# in the rare case you need to change it: it appears to be in:
324#   o /etc/sysconfig/network
325#   o your lvm thingies; probably don't need to edit
326
327# [TEST SERVER] More stuff for test servers
328#   - You need a self-signed SSL cert.  Generate with:
329    openssl req -new -x509 -keyout /etc/pki/tls/private/scripts.key -out /etc/pki/tls/certs/scripts.cert -nodes
330#     Also make /etc/pki/tls/certs/ca.pem match up
331#   - Make (/etc/aliases) root mail go to /dev/null, so we don't spam people
332#   - Edit /etc/httpd/conf.d/scripts-vhost-names.conf to have scripts-fX-test.xvm.mit.edu
333#     be an accepted vhost name
334#   - Look at the old test server and see what config changes are floating around
335
336# XXX: our SVN checkout should be updated to use scripts.mit.edu
337# (repository and etc) once serving actually works.
338    cd /etc
339    svn switch --relocate svn://$source_server/ svn://scripts.mit.edu/
340    cd /usr/vice/etc
341    svn switch --relocate svn://$source_server/ svn://scripts.mit.edu/
342    cd /srv/repository
343    asbuild svn switch --relocate svn://$source_server/ svn://scripts.mit.edu/
344    asbuild svn up # verify scripts.mit.edu works
Note: See TracBrowser for help on using the repository browser.