r97360 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97359‎ | r97360 | r97361 >
Date:02:29, 17 September 2011
Author:ezachte
Status:deferred
Tags:
Comment:
extra validation checks + introduction rsync
Modified paths:
  • /trunk/wikistats/dumps/publish.sh (modified) (history)

Diff [purge]

Index: trunk/wikistats/dumps/publish.sh
@@ -1,13 +1,34 @@
22 #!/bin/bash
 3+clear
 4+now=`date +%s`
 5+
 6+function echo2 {
 7+ echo $1
 8+ echo $1 >> log_publish_sh.txt
 9+}
 10+
 11+clear
 12+echo2 "----------------"
 13+echo2 "Start publish.sh $1 $2"
 14+date >> log_publish_sh.txt
 15+
 16+# Validate project code
 17+if [ "$1" == "" ]
 18+then
 19+ echo2 "Project code missing! Specify as 1st argument one of wb,wk,wn,wp,wq,ws,wv,wx"
 20+ exit
 21+fi
 22+
 23+# Abort when 3rd argument specifies a threshold in days, which is not met
 24+# This prevents costly processing step when new month has just started and most ocunting still needs to be done
325 abort_before=$3
426 day_of_month=$(date +"%d")
527 if [ $day_of_month -lt ${abort_before:=0} ]
628 then
7 - echo publish.sh: day of month $day_of_month lt $abort_before - exit
 29+ echo2 "publish.sh: day of month $day_of_month lt $abort_before - exit"
830 exit
931 fi
1032
11 -clear
1233 case "$1" in
1334 wb) project='Wikibooks' ; dir='wikibooks' ;;
1435 wk) project='Wiktionaries' ; dir='wiktionary' ;;
@@ -19,51 +40,63 @@
2041 wx) project='Wikispecial' ; dir='wikispecial' ;;
2142 *) project='unknown' ; dir='...' ;;
2243 esac
23 -echo "Publish $project" >> WikiCountsLogConcise.txt
24 -echo "Publish $project"
 44+echo2 "Publish $project"
2545
2646 #case "$2" in
2747 # en) dir="$dir/EN" ;
2848 #esac
2949
30 -echo "Copy csv files"
31 -csv=/a/wikistats/csv_$1
32 -htdocs=/mnt/htdocs/$dir/csv
33 -echo csv $csv
34 -echo htdocs $htdocs
 50+htdocs="/mnt/htdocs/$dir/csv"
 51+csv="/a/wikistats/csv_$1"
 52+archive="/mnt/dumps/xmldatadumps/public/other/pagecounts-ez/wikistats" # odd name, temp location
3553
36 -chmod 774 $csv/*
37 -#cp $csv/csv_$1.zip $csv/csv.zip
38 -#rm $csv/csv.zip # temp, obsolete file
39 -#rm -f $htdocs/*
40 -cp $csv/* $htdocs -rvf
 54+rm -f $csv/csv.zip
 55+chmod 774 $csv/*.csv
4156
42 -cp /a/wikistats/zip_all/csv_$1.zip /mnt/htdocs
 57+echo2 ""
 58+echo2 "Copy new/updated csv files from $csv -> $htdocs"
4359
44 -publish=\#publish.txt
 60+echo2 ""
 61+rsync -av $csv/*.csv $htdocs
 62+
 63+echo2 ""
 64+echo2 "Copy csv and html zip files -> public archive $archive"
 65+echo2 ""
 66+rsync -av /a/wikistats/zip_all/csv*.zip $archive >> log_publish_sh.txt
 67+rsync -av /a/wikistats/zip_all/out*.zip $archive >> log_publish_sh.txt
4568
46 -for lang in EN AST BG BR CA CS DA DE EO ES FR HE HU ID IT JA NL NN PL PT RO RU SK SL SR SV WA ZH
47 -#for lang in EN
 69+publish="#publish.txt"
 70+
 71+for lang in AST BG BR CA CS DA DE EO ES FR HE HU ID IT JA NL NN PL PT RO RU SK SL SR SV WA ZH
 72+#for lang in EN
4873 do
49 - out=/a/out/out_$1/$lang
50 - htdocs=/mnt/htdocs/$dir/$lang
51 - echo out $out
52 - echo htdocs $htdocs
53 - echo dir $dir
54 - echo lang $lang
 74+ out=/a/out/out_$1/$lang/
 75+ htdocs=/mnt/htdocs/$dir/$lang/
 76+
 77+ echo2 ""
 78+ echo2 "Language $lang"
 79+ echo2 ""
 80+ echo2 "Copy new and updated files from $out -> $htdocs"
 81+ rsync -a $out/* $htdocs/ >> log_publish_sh.txt
 82+ ls -l $htdocs
 83+
5584 # if test -e $out/WikiReportsPublish.txt
5685 # then mv $out/WikiReportsPublish.txt "$out/$publish" ; fi ;
5786
58 -
5987 #if test -e $out/$publish
6088 # then
61 - echo "New reports generated:\n"
62 - cat $out/$publish
63 - echo "\n\nCopy $lang\n\n"
64 - cp $out/* $htdocs -rvf
65 - rm $out/$publish
 89+# echo2 "New reports generated"
 90+# cat $out/$publish
 91+# echo2 "Copy $lang"
 92+# cp $out/* $htdocs -rvf
 93+# rm $out/$publish
6694 # else echo "No new files, do not publish"
6795 # fi
6896 done
6997
 98+echo2 ""
 99+echo2 "Ready"
 100+date >> log_publish_sh.txt
 101+echo2 "-----"
70102
 103+

Status & tagging log