| [1058] | 1 | # This document is a how-to for installing a Fedora scripts.mit.edu server. | 
|---|
| [181] | 2 |  | 
|---|
| [1063] | 3 | set -e -x | 
|---|
 | 4 |  | 
|---|
 | 5 | [ -e /scripts-boot-count ] || echo 0 > /scripts-boot-count | 
|---|
 | 6 |  | 
|---|
 | 7 | source_server="old-faithful.mit.edu" | 
|---|
 | 8 |  | 
|---|
 | 9 | boot=${1:$(cat /scripts-boot-count)} | 
|---|
 | 10 |  | 
|---|
| [1205] | 11 | branch=branches/fc11-dev | 
|---|
 | 12 |  | 
|---|
| [1063] | 13 | doreboot() { | 
|---|
 | 14 |     echo $(( $boot + 1 )) > /scripts-boot-count; | 
|---|
 | 15 |     shutdown -r now "Rebooting for step $(cat /scripts-boot-count)" | 
|---|
 | 16 | } | 
|---|
 | 17 |  | 
|---|
 | 18 | YUM() { | 
|---|
 | 19 |     NSS_NONLOCAL_IGNORE=1 yum "$@" | 
|---|
 | 20 | } | 
|---|
 | 21 |  | 
|---|
| [1058] | 22 | # Helper files for the install are located in server/fedora/config. | 
|---|
| [861] | 23 |  | 
|---|
| [1058] | 24 | # Start with a normal install of Fedora. | 
|---|
| [861] | 25 |  | 
|---|
| [1063] | 26 | if [ $boot = 0 ]; then | 
|---|
| [1058] | 27 | # When the initial configuration screen comes up, under "Firewall | 
|---|
 | 28 | # configuration", disable the firewall, and under "System services", leave | 
|---|
 | 29 | # enabled (as of Fedora 9) acpid, anacron, atd, cpuspeed, crond, | 
|---|
 | 30 | # firstboot, fuse, haldaemon, ip6tables, iptables, irqbalance, | 
|---|
 | 31 | # kerneloops, mdmonitor, messagebus, microcode_ctl, netfs, network, nscd, ntpd, | 
|---|
 | 32 | # sshd, udev-post, and nothing else. | 
|---|
| [1063] | 33 |     echo "--disabled" > /etc/sysconfig/system-config-firewall | 
|---|
 | 34 |     for i in NetworkManager avahi-daemon bluetooth cups isdn nfslock pcscd restorecond rpcbind rpcgssd rpcidmapd sendmail; do | 
|---|
 | 35 |         chkconfig "$i" off | 
|---|
 | 36 |     done | 
|---|
| [1056] | 37 |  | 
|---|
| [1058] | 38 | # Edit /etc/selinux/config so it has SELINUX=disabled and reboot. | 
|---|
| [1063] | 39 |     sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config | 
|---|
 | 40 |     doreboot | 
|---|
 | 41 | fi | 
|---|
| [861] | 42 |  | 
|---|
| [1063] | 43 | if [ $boot = 1 ]; then | 
|---|
 | 44 | # Create a scripts-build user account, and set up rpm to build in  | 
|---|
 | 45 | # $HOME by doing a  | 
|---|
 | 46 | # cp config/home/scripts-build/.rpmmacros /home/scripts-build/ | 
|---|
 | 47 | # (If you just use the default setup, it will generate packages  | 
|---|
 | 48 | # in /usr/src/redhat.) | 
|---|
 | 49 |     adduser scripts-build | 
|---|
 | 50 |  | 
|---|
| [1058] | 51 | # Check out the scripts.mit.edu svn repository. Configure svn not to cache | 
|---|
 | 52 | # credentials. | 
|---|
| [387] | 53 |  | 
|---|
| [1063] | 54 |     YUM install -y subversion | 
|---|
 | 55 |  | 
|---|
 | 56 |     cd /srv | 
|---|
| [1205] | 57 |     svn co svn://$source_server/$branch repository | 
|---|
| [1063] | 58 |  | 
|---|
 | 59 |     sed -i 's/^(# *)*store-passwords.*/store-passwords = no/' /root/.subversion/config | 
|---|
 | 60 |     sed -i 's/^(# *)*store-auth-creds.*/store-auth-creds = no/' /root/.subversion/config | 
|---|
 | 61 |  | 
|---|
 | 62 |     chown -R scripts-build /srv/repository | 
|---|
 | 63 |  | 
|---|
| [1058] | 64 | # cd to server/fedora in the svn repository. | 
|---|
| [1063] | 65 |     cd /srv/repository/server/fedora | 
|---|
| [387] | 66 |  | 
|---|
| [1058] | 67 | # Run "make install-deps" to install various prereqs.  Nonstandard | 
|---|
 | 68 | # deps are in /mit/scripts/rpm. | 
|---|
| [1205] | 69 |     YUM install -y make | 
|---|
| [1063] | 70 |     make install-deps | 
|---|
| [387] | 71 |  | 
|---|
| [1063] | 72 | # Install bind | 
|---|
 | 73 |     YUM install -y bind | 
|---|
| [934] | 74 |  | 
|---|
| [1063] | 75 | # Check out the scripts /etc configuration | 
|---|
 | 76 |     cd /root | 
|---|
| [1205] | 77 |     svn co svn://scripts.mit.edu/$branch/server/fedora/config/etc etc | 
|---|
 | 78 |     # backslash to make us not use the alias | 
|---|
| [1063] | 79 |     \cp -a etc / | 
|---|
| [785] | 80 |  | 
|---|
| [1205] | 81 | # NOTE: You will have just lost DNS resolution and the abilit | 
|---|
 | 82 | # to do password SSH in | 
|---|
 | 83 |  | 
|---|
 | 84 |     service named start | 
|---|
 | 85 |     chkconfig named on | 
|---|
 | 86 |  | 
|---|
 | 87 | # XXX: This sometimes doesn't exist, but it really sucks if it | 
|---|
 | 88 | # does exist. So check for it. | 
|---|
| [1179] | 89 | # yum remove nss_ldap, because nss-ldapd conflicts with it | 
|---|
 | 90 |  | 
|---|
| [1205] | 91 | # In the case of the Kerberos libraries, you'll be told that | 
|---|
 | 92 | # there are conflicting files with the 64-bit versions of the packages, | 
|---|
 | 93 | # which we scriptsify.  You'll have to use --force to install those | 
|---|
 | 94 | # rpms despite the conflicts.  After doing that, you may want to | 
|---|
 | 95 | # install the corresponding 64-bit scriptsified versions again, just | 
|---|
 | 96 | # to be safe in case the 32-bit versions overwrite files that differ. | 
|---|
 | 97 | # When you try this, it will complain that you already have the same | 
|---|
 | 98 | # version installed; again, you'll need to use --force to do it anyway. | 
|---|
 | 99 |  | 
|---|
 | 100 | # We need yumdownloader to force some RPMs | 
|---|
 | 101 |     # XXX: This might be wrong. Sanity check what packages ou | 
|---|
 | 102 |     # have when done | 
|---|
 | 103 |     YUM install -y yum-utils | 
|---|
 | 104 |     yumdownloader krb5-libs | 
|---|
 | 105 |     # XXX: These version numbers are hardcoded, need some cli-fu to generalize | 
|---|
 | 106 |     rpm -i krb5-libs-1.6.3-20.fc11.i586.rpm | 
|---|
 | 107 |     rpm -U --force krb5-libs-1.6.3-20.fc11.scripts.1138.x86_64.rpm | 
|---|
 | 108 |  | 
|---|
| [1058] | 109 | # env NSS_NONLOCAL_IGNORE=1 yum install scripts-base | 
|---|
| [1063] | 110 |     YUM install -y scripts-base | 
|---|
| [387] | 111 |  | 
|---|
| [1205] | 112 | # Install mit-zephyr | 
|---|
 | 113 |     YUM install -y mit-zephyr | 
|---|
| [796] | 114 |  | 
|---|
| [1058] | 115 | # Remember to set NSS_NONLOCAL_IGNORE=1 anytime you're setting up | 
|---|
 | 116 | # anything, e.g. using yum. Otherwise useradd will query LDAP in a stupid way | 
|---|
| [1205] | 117 | # that makes it hang forever. (This is why we're using YUM, not yum) | 
|---|
| [881] | 118 |  | 
|---|
| [1058] | 119 | # Reload the iptables config to take down the restrictive firewall  | 
|---|
| [1205] | 120 |     service iptables restart | 
|---|
| [862] | 121 |  | 
|---|
| [1058] | 122 | # Copy over root's dotfiles from one of the other machines. | 
|---|
| [1205] | 123 | # Perhaps a useful change is to remove the default aliases | 
|---|
| [803] | 124 |  | 
|---|
| [1058] | 125 | # Replace rsyslog with syslog-ng by doing: | 
|---|
| [1205] | 126 |     rpm -e --nodeps rsyslog | 
|---|
 | 127 |     YUM install -y syslog-ng | 
|---|
| [861] | 128 |  | 
|---|
| [1205] | 129 | # Install various dependencies of the scripts system, including | 
|---|
 | 130 | # glibc-devel.i586 (ezyang: already installed for me), | 
|---|
 | 131 | # python-twisted-core (ditto), mod_fcgid, nrpe, nagios-plugins-all. | 
|---|
 | 132 |     YUM install -y mod_fcgid | 
|---|
 | 133 |     YUM install -y nrpe | 
|---|
 | 134 |     YUM install -y nagios-plugins-all | 
|---|
| [788] | 135 |  | 
|---|
| [1058] | 136 | # Disable NetworkManager with chkconfig NetworkManager off. Configure | 
|---|
 | 137 | # networking on the front end and back end, and the routing table to send | 
|---|
 | 138 | # traffic over the back end. Make sure that chkconfig reports "network" on, so | 
|---|
 | 139 | # that the network will still be configured at next boot. | 
|---|
| [1205] | 140 | # ezyang: For me, NetworkManager was not installed at this point, and | 
|---|
 | 141 | # we had already done the basic config for networking front end and | 
|---|
 | 142 | # back end (because I wanted ssh access, and not just conserver access) | 
|---|
| [788] | 143 |  | 
|---|
| [1058] | 144 | # Fix the openafs /usr/vice/etc <-> /etc/openafs mapping by changing | 
|---|
 | 145 | #  /usr/vice/etc/cacheinfo to contain: | 
|---|
 | 146 | #       /afs:/usr/vice/cache:10000000 | 
|---|
| [1179] | 147 | # Also fix ThisCell to contain athena.mit.edu in both directories | 
|---|
| [1205] | 148 |     echo "/afs:/usr/vice/cache:10000000" > /usr/vice/etc/cacheinfo | 
|---|
 | 149 |     # ezyang: ThisCell on b-k and c-w don't have anything special | 
|---|
 | 150 |     # written here | 
|---|
| [788] | 151 |  | 
|---|
| [1058] | 152 | # Figure out why Zephyr isn't working. Most recently, it was because there | 
|---|
 | 153 | # was a 64-bit RPM installed; remove it and install Joe's 32-bit one | 
|---|
| [1205] | 154 |     YUM erase -y mit-zephyr | 
|---|
 | 155 |     # mit-zephyr has a spurious dependency on mit-krb-config | 
|---|
 | 156 |     yumdownloader mit-zephyr.i386 | 
|---|
 | 157 |     # if deps change, this breaks | 
|---|
 | 158 |     YUM install -y libXaw.i586 libXext.i586 libXmu.i586 ncurses-libs.i586 readline.i58 | 
|---|
 | 159 |     rpm -i --nodeps mit-zephyr-2.1-6-linux.i386.rpm | 
|---|
| [861] | 160 |  | 
|---|
| [1179] | 161 | # Install the athena-base, athena-lprng, and athena-lprng-misc RPMs | 
|---|
 | 162 | # from the Athena 9 build (these are present in our yum repo).  Note | 
|---|
 | 163 | # that you will have to use --nodeps for at least one of the lprng | 
|---|
 | 164 | # ones because it thinks it needs the Athena hesiod RPM.  It doesn't | 
|---|
 | 165 | # really.  Before doing this, run it without --nodeps and arrange to | 
|---|
 | 166 | # install the rest of the things it really does depend on.  This will | 
|---|
 | 167 | # include a bunch of 32-bit rpms; go ahead and install the .i586 versions | 
|---|
| [1205] | 168 | # of them. | 
|---|
 | 169 |     YUM install -y athena-base | 
|---|
 | 170 |     YUM install -y athena-lprng | 
|---|
 | 171 |     yumdownloader athena-lprng-misc | 
|---|
 | 172 |     # ezyang: I couldn't find any deps for this that existed in the repos | 
|---|
 | 173 |     # You might get a "find: `/usr/athena/info': No such file or directory" | 
|---|
 | 174 |     # error; this is fine | 
|---|
 | 175 |     rpm -i --nodeps athena-lprng-misc-9.4-0.i386.rpm | 
|---|
| [1179] | 176 |  | 
|---|
| [1058] | 177 | # Install the full list of RPMs that users expect to be on the | 
|---|
| [1205] | 178 | # scripts.mit.edu servers. | 
|---|
| [387] | 179 |  | 
|---|
| [1205] | 180 | # ezyang: Running the below I got file conflicts. To fix (since I had | 
|---|
 | 181 | # botched steps above), I manually compared package lists and installed | 
|---|
 | 182 | # them.  If you've done the krb5 setup originally correctly, then | 
|---|
 | 183 | # write down what you had to do here. | 
|---|
 | 184 |     yumdownloader krb5-devel | 
|---|
 | 185 |     rpm -i --force krb5-devel-1.6.3-20.fc11.i586.rpm | 
|---|
 | 186 |     rpm -U --force krb5-devel-1.6.3-20.fc11.scripts.1138.x86_64.rpm | 
|---|
 | 187 |     yumdownloader krb5-server | 
|---|
 | 188 |     rpm -i --force krb5-server-1.6.3-20.fc11.scripts.1138.x86_64.rpm | 
|---|
 | 189 |  | 
|---|
 | 190 |  | 
|---|
 | 191 | # on another server, run: | 
|---|
 | 192 | rpm -qa --queryformat "%{Name}.%{Arch}\n" | sort > packages.txt | 
|---|
 | 193 | # arrange for packages.txt to be passed to the server, then run: | 
|---|
 | 194 |     # notice that yum is not capitalized | 
|---|
 | 195 |     # Also notice skip-broken | 
|---|
 | 196 |     NSS_NONLOCAL_IGNORE=1 cat packages.txt | xargs yum install -y --skip-broken | 
|---|
 | 197 |  | 
|---|
| [1198] | 198 | # Check which packages are installed on your new server that are not | 
|---|
 | 199 | # in the snapshot, and remove ones that aren't needed for some reason | 
|---|
 | 200 | # on the new machine.  Otherwise, aside from bloat, you may end up | 
|---|
 | 201 | # with undesirable things for security, like sendmail. | 
|---|
| [1205] | 202 |     rpm -qa --queryformat "%{Name}.%{Arch}\n" | sort > newpackages.txt | 
|---|
 | 203 |     diff -u packages.txt newpackages.txt  | less | 
|---|
 | 204 |     # if all went well, you'll probably see multiple kernel versions | 
|---|
 | 205 |     # as the only diff | 
|---|
 | 206 |     # ezyang: I got exim installed as another package | 
|---|
| [1198] | 207 |  | 
|---|
| [1058] | 208 | # Install the full list of perl modules that users expect to be on the | 
|---|
| [1108] | 209 | # scripts.mit.edu servers. | 
|---|
| [1058] | 210 | # - export PERL_MM_USE_DEFAULT=1 | 
|---|
 | 211 | # - Run 'cpan', accept the default configuration, and do 'o conf | 
|---|
 | 212 | #   prerequisites_policy follow'. | 
|---|
 | 213 | # - Parse the output of perldoc -u perllocal | grep head2 on an existing | 
|---|
 | 214 | #   server, and "notest install" them from the cpan prompt. | 
|---|
| [1109] | 215 | # TO DO THIS: | 
|---|
 | 216 | # On another server, run: | 
|---|
| [1179] | 217 | # perldoc -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")' > /mit/scripts/config/perl-packages.txt | 
|---|
| [1109] | 218 | # Then on the server you're installing, | 
|---|
| [1198] | 219 | #    cat perl-packages.txt | perl -MCPAN -e shell | 
|---|
| [1206] | 220 |     export PERL_MM_USE_DEFAULT=1 | 
|---|
 | 221 |     # XXX: Some interactive gobbeldygook | 
|---|
 | 222 |     cpan | 
|---|
 | 223 |         o conf prerequisites_policy follow | 
|---|
 | 224 |         o conf commit | 
|---|
 | 225 | # on a reference server | 
|---|
 | 226 | perldoc -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 | 
|---|
 | 227 | # arrange for perl-packages.txt to be transferred to server | 
|---|
 | 228 |     cat perl-packages.txt | perl -MCPAN -e shell | 
|---|
| [812] | 229 |  | 
|---|
| [1058] | 230 | # Install the Python eggs and Ruby gems and PEAR/PECL doohickeys that are on | 
|---|
 | 231 | # the other scripts.mit.edu servers and do not have RPMs. | 
|---|
| [1206] | 232 | # The general mode of operation will be to run the "list" command | 
|---|
 | 233 | # on both servers, see what the differences are, check if those diffs | 
|---|
 | 234 | # are packaged up as rpms, and install them (rpm if possible, native otherwise) | 
|---|
| [1179] | 235 | # - Look at /usr/lib/python2.6/site-packages and | 
|---|
 | 236 | #           /usr/lib64/python2.6/site-packages for Python eggs and modules. | 
|---|
| [1206] | 237 | #   There will be a lot of gunk that was installed from packages; | 
|---|
 | 238 | #   easy-install.pth will tell you what was easy_installed. | 
|---|
| [1179] | 239 | #   First use 'yum search' to see if the relevant package is now available | 
|---|
 | 240 | #   as an RPM, and install that if it is.  If not, then use easy_install. | 
|---|
| [1058] | 241 | # - Look at `gem list` for Ruby gems. | 
|---|
| [1179] | 242 | #   Again, use 'yum search' and prefer RPMs, but failing that, 'gem install'. | 
|---|
| [1206] | 243 | #       ezyang: rspec-rails depends on rspec, and will override the Yum | 
|---|
 | 244 | #       package, so... don't use that RPM yet | 
|---|
| [1058] | 245 | # - Look at `pear list` for Pear fruits (or whatever they're called). | 
|---|
| [1179] | 246 | #   Yet again, 'yum search' for RPMs before resorting to 'pear install'.  Note | 
|---|
 | 247 | #   that for things in the beta repo, you'll need 'pear install package-beta'. | 
|---|
| [1206] | 248 | #   (you might get complaints about the php_scripts module; ignore them) | 
|---|
| [1198] | 249 | # - Look at `pecl list` for PECL things.  'yum search', and if you must, | 
|---|
 | 250 | #   'pecl install' needed items. | 
|---|
| [1206] | 251 |     # Automating this... will require a lot of batonning between | 
|---|
 | 252 |     # the servers. Probably best way to do it is to write an actual | 
|---|
 | 253 |     # script. | 
|---|
| [785] | 254 |  | 
|---|
| [1206] | 255 | # Setup some Python config | 
|---|
 | 256 |     echo 'import site, os.path; site.addsitedir(os.path.expanduser("~/lib/python2.6/site-packages"))' > /usr/lib/python2.6/site-packages/00scripts-home.pth | 
|---|
| [812] | 257 |  | 
|---|
| [1198] | 258 | # Build and install the scripts php module that enhances error logging info | 
|---|
 | 259 | # XXX This thing really ought to be packaged | 
|---|
| [1206] | 260 |     cp -r /srv/repository/server/common/oursrc/php_scripts /root | 
|---|
 | 261 |     cd /root/php_scripts | 
|---|
 | 262 |     ./build.sh | 
|---|
 | 263 |     cp test/modules/scripts.so /usr/lib64/php/modules | 
|---|
| [1198] | 264 |  | 
|---|
| [1179] | 265 | # Install the credentials.  There are a lot of things to remember here: | 
|---|
 | 266 | #   o You probably installed the machine keytab long ago | 
|---|
 | 267 | #   o Use ktutil to combine the host/scripts.mit.edu and | 
|---|
 | 268 | #     host/scripts-vhosts.mit.edu keys with host/this-server.mit.edu in | 
|---|
 | 269 | #     the keytab.  Do not use 'k5srvutil change' on the combined keytab | 
|---|
 | 270 | #     or you'll break the other servers. | 
|---|
 | 271 | #   o The daemon.scripts keytab | 
|---|
 | 272 | #   o The SSL cert private key | 
|---|
 | 273 | #   o The LDAP password for the signup process | 
|---|
 | 274 | #   o The SQL password for the signup process | 
|---|
 | 275 | #   o The LDAP keytab for this server, which will be used later | 
|---|
 | 276 | #   o Replace the ssh host keys with the ones common to all scripts servers | 
|---|
 | 277 | #   o You'll install an LDAP certificate signed by the scripts CA later | 
|---|
 | 278 | #   o Make sure root's .k5login is correct | 
|---|
 | 279 | #   o Make sure logview's .k5login is correct | 
|---|
| [387] | 280 |  | 
|---|
| [1058] | 281 | # If you are setting up a test server, pay attention to | 
|---|
 | 282 | # /etc/sysconfig/network-scripts and do not bind scripts' IP address. | 
|---|
 | 283 | # You will also need to modify /etc/ldap.conf, /etc/nss-ldapd.conf, | 
|---|
 | 284 | # /etc/openldap/ldap.conf, and /etc/httpd/conf.d/vhost_ldap.conf to | 
|---|
 | 285 | # use scripts.mit.edu instead of localhost. | 
|---|
| [562] | 286 |  | 
|---|
| [1058] | 287 | # Install fedora-ds-base and set up replication (see ./HOWTO-SETUP-LDAP | 
|---|
 | 288 | #   and ./fedora-ds-enable-ssl-and-kerberos.diff). | 
|---|
| [785] | 289 |  | 
|---|
| [1058] | 290 | # Make the services dirsrv, nslcd, nscd, postfix, and httpd start at | 
|---|
 | 291 | # boot. Run chkconfig to make sure the set of services to be run is | 
|---|
 | 292 | # correct. | 
|---|
| [818] | 293 |  | 
|---|
| [1206] | 294 | # Postfix doesn't actually deliver mail; fix this | 
|---|
 | 295 |     cd /etc/postfix | 
|---|
 | 296 |     postmap virtual | 
|---|
| [1179] | 297 |  | 
|---|
| [1058] | 298 | # Run fmtutil-sys --all, which does something that makes TeX work. | 
|---|
| [803] | 299 |  | 
|---|
| [1058] | 300 | # Ensure that PHP isn't broken: | 
|---|
| [1206] | 301 |     mkdir /tmp/sessions | 
|---|
 | 302 |     chmod 01777 /tmp/sessions | 
|---|
| [954] | 303 |  | 
|---|
| [1186] | 304 | # Ensure that fcgid isn't broken: | 
|---|
| [1206] | 305 |     chmod 755 /var/run/httpd | 
|---|
 | 306 |     chmod 755 /var/run/httpd/mod_fcgid | 
|---|
| [1186] | 307 |  | 
|---|
| [1058] | 308 | # Reboot the machine to restore a consistent state, in case you | 
|---|
 | 309 | # changed anything. | 
|---|
| [875] | 310 |  | 
|---|
| [1058] | 311 | # (Optional) Beat your head against a wall. | 
|---|
| [562] | 312 |  | 
|---|
| [1058] | 313 | # Possibly perform other steps that I've neglected to put in this | 
|---|
 | 314 | # document. | 
|---|