Index: trunk/debs/wikimedia-task-appserver/apache-sanity-check |
— | — | @@ -0,0 +1,57 @@ |
| 2 | +#!/bin/bash |
| 3 | +# |
| 4 | +# This is an aggregated version of /home/w/bin/apache-sanity-check, |
| 5 | +# which does not depend on mounted NFS /home. |
| 6 | + |
| 7 | +set -ex |
| 8 | + |
| 9 | +export PATH=/bin:/usr/bin:/sbin:/usr/sbin |
| 10 | + |
| 11 | +# FIXME: move this to PyBal runcommand check, and/or replace with Puppet logic. |
| 12 | +VIP="10\\.2\\.1\\.\(1\|21\)" |
| 13 | +if ! /sbin/ip addr | grep -q "$VIP.*lo"; then |
| 14 | + echo "System failed sanity check: VIP not configured on lo" |
| 15 | + exit 1 |
| 16 | +fi |
| 17 | + |
| 18 | +check-time |
| 19 | + |
| 20 | +# Check for presence of shell commands used by MW |
| 21 | +# We use fixed paths instead of a $PATH search, because that's how they're specified in CommonSettings.php |
| 22 | +shell_cmds="/usr/bin/djvudump /usr/bin/tidy" |
| 23 | +for cmd in $shell_cmds; do |
| 24 | + if [ ! -x $cmd ]; then |
| 25 | + echo "$cmd missing" |
| 26 | + exit 1 |
| 27 | + fi |
| 28 | +done |
| 29 | + |
| 30 | +# Test for LaTeX packages |
| 31 | +tmpdir=/tmp/sanity-check-latex.`date +%s` |
| 32 | +mkdir $tmpdir |
| 33 | +if ! cd $tmpdir; then |
| 34 | + rm -rf $tmpdir |
| 35 | + echo "Unable to change to directory /tmp/sanity-check-latex" |
| 36 | + exit 1 |
| 37 | +fi |
| 38 | +echo ' |
| 39 | +\nonstopmode |
| 40 | +\documentclass[12pt]{article} |
| 41 | +\usepackage{amsmath} |
| 42 | +\usepackage{amsfonts} |
| 43 | +\usepackage{amssymb} |
| 44 | +\usepackage[dvips,usenames]{color} |
| 45 | +\pagestyle{empty} |
| 46 | +\begin{document} |
| 47 | +\end{document} |
| 48 | +' > test.tex |
| 49 | +latex test.tex > /dev/null |
| 50 | +exit_status=$? |
| 51 | +if [ $exit_status -ne 0 ]; then |
| 52 | + echo "LaTeX returned exit status $exit_status, may be missing packages" |
| 53 | + echo "See logs in $tmpdir" |
| 54 | + exit 1 |
| 55 | +fi |
| 56 | +rm -rf $tmpdir |
| 57 | + |
| 58 | +exit 0 |
Index: trunk/debs/wikimedia-task-appserver/debian/control |
— | — | @@ -7,7 +7,7 @@ |
8 | 8 | |
9 | 9 | Package: wikimedia-task-appserver |
10 | 10 | Architecture: all |
11 | | -Depends: wikimedia-nis-client, wikimedia-lvs-realserver, apache2-mpm-prefork, librsvg2-bin, dvipng, tetex-bin, tetex-extra, gsfonts, ocaml, ploticus, php5-mysql, php5-curl, php5-xmlrpc, php5-cli, php5-apc, php5-wikidiff2, php5-fss, libapache2-mod-php5, file, djvulibre-bin, tidy (>= 20070821), libtidy-0.99-0 (>= 20070821), php-pear |
| 11 | +Depends: wikimedia-lvs-realserver, apache2-mpm-prefork, librsvg2-bin, dvipng, tetex-bin, tetex-extra, gsfonts, ocaml, ploticus, php5-mysql, php5-curl, php5-xmlrpc, php5-cli, php5-apc, php5-wikidiff2, php5-fss, libapache2-mod-php5, file, djvulibre-bin, tidy (>= 20070821), libtidy-0.99-0 (>= 20070821), php-pear, rsync |
12 | 12 | Description: Wikimedia application server |
13 | 13 | This package depends on all packages needed to setup a standard |
14 | 14 | application server. |
Index: trunk/debs/wikimedia-task-appserver/debian/postinst |
— | — | @@ -35,6 +35,19 @@ |
36 | 36 | } |
37 | 37 | } |
38 | 38 | |
| 39 | +create_apache_user() { |
| 40 | + # Create apache user/group with correct uid/gid |
| 41 | + if ! getent group apache > /dev/null |
| 42 | + then |
| 43 | + addgroup --system --gid 48 apache |
| 44 | + fi |
| 45 | + |
| 46 | + if ! getent passwd apache > /dev/null |
| 47 | + then |
| 48 | + adduser --system --home /var/www --shell /sbin/nologin --no-create-home --uid 48 --gid 48 --disabled-password apache |
| 49 | + fi |
| 50 | +} |
| 51 | + |
39 | 52 | case "$1" in |
40 | 53 | configure) |
41 | 54 | # Add a line to /etc/motd describing the task of this server |
— | — | @@ -57,18 +70,17 @@ |
58 | 71 | fi |
59 | 72 | fi |
60 | 73 | |
| 74 | + create_apache_user |
| 75 | + |
61 | 76 | chown -R pybal-check:pybal-check /var/lib/pybal-check/.ssh |
62 | 77 | |
63 | | - checkmount amane:/export/upload /mnt/upload3 |
64 | | - checkmount amane:/export/math /mnt/math |
65 | 78 | checkmount ms1.wikimedia.org:/export/upload /mnt/upload5 |
66 | 79 | |
67 | 80 | CLUSTER=$(cat /etc/wikimedia-cluster) |
68 | 81 | if [ $CLUSTER="pmtpa" ] |
69 | 82 | then |
70 | | - rsync -a /home/wikipedia/conf/httpd/ /usr/local/apache/conf |
| 83 | + rsync -a 10.0.5.8::httpdconf/ /usr/local/apache/conf |
71 | 84 | |
72 | | - PATH=$PATH:/home/wikipedia/bin |
73 | 85 | sync-common |
74 | 86 | apache-start |
75 | 87 | else |
Index: trunk/debs/wikimedia-task-appserver/debian/postrm |
— | — | @@ -29,15 +29,19 @@ |
30 | 30 | |
31 | 31 | case "$1" in |
32 | 32 | purge) |
| 33 | + # Remove apache user |
| 34 | + deluser apache || true |
| 35 | + delgroup apache || true |
| 36 | + |
33 | 37 | # Remove PyBal check user account |
34 | 38 | deluser pybal-check |
35 | | - rm -rf /var/lib/pybal-check |
| 39 | + rm -rf /var/lib/pybal-check |
36 | 40 | |
37 | | - dpkg-divert --package wikimedia-task-appserver --rename --remove /etc/apache2/apache2.conf |
38 | | - dpkg-divert --package wikimedia-task-appserver --rename --remove /etc/php5/apache2/php.ini |
39 | | - dpkg-divert --package wikimedia-task-appserver --rename --remove /usr/share/php5/php.ini-dist |
40 | | - dpkg-divert --package wikimedia-task-appserver --rename --remove /etc/sudoers |
41 | | - dpkg-divert --package wikimedia-task-appserver --rename --remove /etc/apache2/envvars |
| 41 | + dpkg-divert --package wikimedia-task-appserver --rename --remove /etc/apache2/apache2.conf |
| 42 | + dpkg-divert --package wikimedia-task-appserver --rename --remove /etc/php5/apache2/php.ini |
| 43 | + dpkg-divert --package wikimedia-task-appserver --rename --remove /usr/share/php5/php.ini-dist |
| 44 | + dpkg-divert --package wikimedia-task-appserver --rename --remove /etc/sudoers |
| 45 | + dpkg-divert --package wikimedia-task-appserver --rename --remove /etc/apache2/envvars |
42 | 46 | ;; |
43 | 47 | remove) |
44 | 48 | removemount /mnt/upload3 |
Index: trunk/debs/wikimedia-task-appserver/debian/preinst |
— | — | @@ -14,7 +14,6 @@ |
15 | 15 | # for details, see http://www.debian.org/doc/debian-policy/ or |
16 | 16 | # the debian-policy package |
17 | 17 | |
18 | | - |
19 | 18 | case "$1" in |
20 | 19 | install) |
21 | 20 | dpkg-divert --package wikimedia-task-appserver --add --rename \ |
— | — | @@ -27,6 +26,7 @@ |
28 | 27 | --divert /etc/sudoers.default /etc/sudoers |
29 | 28 | dpkg-divert --package wikimedia-task-appserver --add --rename \ |
30 | 29 | --divert /etc/apache2/envvars.default /etc/apache2/envvars |
| 30 | + |
31 | 31 | |
32 | 32 | # Create user for the PyBal checks |
33 | 33 | adduser --system --home /var/lib/pybal-check --group --disabled-password --shell /bin/sh pybal-check |
Index: trunk/debs/wikimedia-task-appserver/debian/changelog |
— | — | @@ -1,3 +1,11 @@ |
| 2 | +wikimedia-task-appserver (1.34) hardy; urgency=low |
| 3 | + |
| 4 | + * Include local version of sync/sanity check scripts |
| 5 | + * Remove old amane NFS mounts |
| 6 | + * No longer depend on wikimedia-nis-client |
| 7 | + |
| 8 | + -- Mark Bergsma <mark@wikimedia.org> Sat, 25 Apr 2009 15:43:11 +0000 |
| 9 | + |
2 | 10 | wikimedia-task-appserver (1.33) hardy; urgency=low |
3 | 11 | |
4 | 12 | * Added /mnt/upload5 to the remove list, removed /mnt/upload4 from the |
Index: trunk/debs/wikimedia-task-appserver/debian/rules |
— | — | @@ -54,6 +54,10 @@ |
55 | 55 | install -m 0644 php.ini $(DESTDIR)/usr/share/php5/php.ini-dist |
56 | 56 | install -m 0400 sudoers $(DESTDIR)/etc/ |
57 | 57 | |
| 58 | + # Install sync/check scripts |
| 59 | + install -d -m 0755 $(DESTDIR)/usr/bin |
| 60 | + install -m 0750 sync-common apache-sanity-check apache-start check-time $(DESTDIR)/usr/bin |
| 61 | + |
58 | 62 | install -d -m 0750 $(DESTDIR)/var/lib/pybal-check/.ssh |
59 | 63 | install -m 0640 authorized_keys $(DESTDIR)/var/lib/pybal-check/.ssh/authorized_keys |
60 | 64 | |
Index: trunk/debs/wikimedia-task-appserver/sync-common |
— | — | @@ -0,0 +1,25 @@ |
| 2 | +#!/bin/sh |
| 3 | +# |
| 4 | +# This is an aggregated version of the scripts called by /home/w/bin/sync-common, |
| 5 | +# not depending on NFS /home. |
| 6 | + |
| 7 | +set -e |
| 8 | +umask 002 |
| 9 | + |
| 10 | +export PATH=/bin:/usr/bin:/sbin:/usr/sbin |
| 11 | + |
| 12 | +# Set ownership |
| 13 | +find /apache/common/php-1.5 -group wikidev -not -perm -020 -perm -200 -exec chmod g+w '{}' ';' |
| 14 | + |
| 15 | +# Compile texvc |
| 16 | +echo -n Compiling texvc... |
| 17 | +[ -d /var/tmp/texvc ] || mkdir /var/tmp/texvc |
| 18 | +rsync -r --exclude=.svn/ 10.0.5.8::common/php-1.5/math/ /var/tmp/texvc |
| 19 | +cd /var/tmp/texvc |
| 20 | +make -f Makefile texvc >/dev/null 2>/dev/null && echo ok || echo failed |
| 21 | +cp /var/tmp/texvc/texvc /usr/local/bin/ |
| 22 | + |
| 23 | +# rsync common |
| 24 | +echo -n Copying to `hostname -s`... |
| 25 | +rsync -a --delete 10.0.5.8::common/ /usr/local/apache/common-local |
| 26 | +echo Done. |
Index: trunk/debs/wikimedia-task-appserver/check-time |
— | — | @@ -0,0 +1,18 @@ |
| 2 | +#!/usr/bin/perl -w |
| 3 | + |
| 4 | +$threshold = 0.5; |
| 5 | +$server = 'ntp.pmtpa.wmnet'; |
| 6 | + |
| 7 | +$time = `/usr/sbin/ntpdate -q $server`; |
| 8 | +if ( $time =~ /offset ([0-9.-]*) sec/ ) { |
| 9 | + $offset = $1; |
| 10 | + if ( abs( $offset ) > $threshold ) { |
| 11 | + print "Warning: clock offset is $offset seconds\n"; |
| 12 | + exit 1; |
| 13 | + } else { |
| 14 | + exit 0; |
| 15 | + } |
| 16 | +} else { |
| 17 | + print "Error: unable to contact NTP server\n"; |
| 18 | + exit 2; |
| 19 | +} |
Index: trunk/debs/wikimedia-task-appserver/apache-start |
— | — | @@ -0,0 +1,6 @@ |
| 2 | +#!/bin/sh |
| 3 | + |
| 4 | +set -e |
| 5 | + |
| 6 | +cd / |
| 7 | +apache-sanity-check && sudo /usr/sbin/apache2ctl start |