/
l10nupdate-1
executable file
·123 lines (112 loc) · 3.8 KB
/
l10nupdate-1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/bin/bash
# This script belongs in /usr/local/bin/.
. /usr/local/lib/mw-deployment-vars.sh
. $MW_COMMON_SOURCE/multiversion/MWRealm.sh
BINDIR=/usr/local/bin
MWMULTIDIR=$MW_COMMON_SOURCE/multiversion
# The configuration in CommonSettings.php should match GITDIR and GITREPOS
GITDIR=/var/lib/l10nupdate/mediawiki
GITURL=https://gerrit.wikimedia.org/r/p/mediawiki
GITREPOS="core extensions"
QUIET=--quiet
umask 0002
BEGAN=$(date +"%s")
TEMP=`getopt -o '' -l verbose -- "$@"`
if [ $? -ne 0 ]; then
exit 1
fi
eval set -- "$TEMP"
while true; do
case "$1" in
--verbose)
QUIET=
shift
;;
--)
shift
break
esac
done
echo "Starting l10nupdate at $(date -ud @$BEGAN)."
# Update i18n messages from git to the HEAD of master, or create the clone if it doesn't exist yet
echo "Updating git clone ..."
for path in $GITREPOS
do
if [ -d $GITDIR/$path ]
then
# Checkout exists, update it
if cd $GITDIR/$path && git pull && git submodule update --init
then
echo "Updated $path"
else
$BINDIR/dologmsg "!log LocalisationUpdate failed: git pull of $path failed"
echo "Updating $path FAILED."
exit 1
fi
else
# Create the checkout's parent directory
if mkdir -p `dirname $GITDIR/$path` &&
git clone $GITURL/$path $GITDIR/$path &&
cd $GITDIR/$path &&
git submodule update --init
then
echo "Cloned $path"
else
$BINDIR/dologmsg "!log LocalisationUpdate failed: git clone of $path failed"
echo "Cloning $path FAILED."
exit 1
fi
fi
done
echo "git clone updated."
# Get all MW message cache versions (and a wiki DB name for each)
mwVerDbSets=$($BINDIR/mwversionsinuse --withdb)
if [ -z "$mwVerDbSets" ]; then
$BINDIR/dologmsg "!log LocalisationUpdate failed: mwversionsinuse returned empty list"
echo "Obtaining MediaWiki version list FAILED"
exit 1
fi
# Update l10n cache and clear the message cache for these versions
for i in ${mwVerDbSets[@]}
do
mwVerNum=${i%=*}
mwDbName=${i#*=}
if [ ! -d /var/lib/l10nupdate/cache-"$mwVerNum" ]; then
mkdir /var/lib/l10nupdate/cache-"$mwVerNum"
fi
echo "Running updates for $mwVerNum (on $mwDbName)"
if /usr/local/bin/mwscript extensions/LocalisationUpdate/update.php \
--wiki="$mwDbName" $QUIET
then
echo "Rebuilding localization cache at `date --rfc-3339=seconds`"
/usr/local/bin/mwscript rebuildLocalisationCache.php \
--wiki="$mwDbName" \
--outdir=/var/lib/l10nupdate/cache-${mwVerNum} $QUIET
# Copy the LC files
echo "Completed at `date --rfc-3339=seconds`. Copying LC files to $MW_COMMON_SOURCE"
cp --preserve=timestamps --force /var/lib/l10nupdate/cache-"$mwVerNum"/l10n_cache-* $MW_COMMON_SOURCE/php-"$mwVerNum"/cache/l10n
# Include JSON versions of the CDB files and add MD5 files
/usr/local/bin/refreshCdbJsonFiles --directory="$MW_COMMON_SOURCE/php-$mwVerNum/cache/l10n"
echo "Syncing to Apaches at `date --rfc-3339=seconds`"
SYNC_START=$(date +%s)
$BINDIR/sync-l10nupdate-1 "$mwVerNum"
SYNC_END=$(date +%s)
$BINDIR/dologmsg "!log LocalisationUpdate completed ($mwVerNum) at `date --rfc-3339=seconds`"
echo "All done at `date --rfc-3339=seconds`"
$BINDIR/deploy2graphite l10nupdate-sync $((SYNC_END-SYNC_START))
else
$BINDIR/dologmsg "!log LocalisationUpdate failed ($mwVerNum) at `date --rfc-3339=seconds`"
echo "FAILED"
fi
done
# Clear the ResourceLoader cached messages
echo "Refreshing ResourceLoader caches"
ALLDB=`getRealmSpecificFilename "$MW_COMMON_SOURCE/all.dblist"`
for wiki in `<"$ALLDB"`; do
/usr/local/bin/mwscript extensions/WikimediaMaintenance/refreshMessageBlobs.php --wiki="$wiki"
done
echo "All done"
ENDED=$(date +"%s")
LENGTH=$(($ENDED-$BEGAN))
$BINDIR/deploy2graphite l10n $LENGTH
$BINDIR/dologmsg "!log LocalisationUpdate ResourceLoader cache refresh completed at $(date -ud @$ENDED) (duration $(date -ud @"$LENGTH" +'%-Mm %-Ss'))"