source: other-projects/gti/translation_status.sh

Last change on this file was 36401, checked in by anupama, 20 months ago

Part 2 of commits relating to updating GTI to support translations for DEC (Documented Example Collections) description strings. Previous commit was macros/english2.dm to add a new column for the new gs3-dec-col-cfgs module in the table on the GTI status page. This commit: Updating translation_status.sh to take into account the new gs3-dec-col-cfg module (to check if there have been translator modifications in there and send off an email to notify us).

  • Property svn:executable set to *
File size: 4.4 KB
Line 
1#!/bin/bash
2
3# This script makes a report of any language files that have been modified via the online GTI,
4# and sends off an email containing this report if any have been modified.
5# Although it works in local GS2 installations as well, this file needs to live in the top-level
6# of the GTI greenstone installation on nzdl. It's called by the cronjobs running on nzdl.
7
8[email protected]
9# Need this now on gti
10MAIL=/var/spool/mail/gs2
11
12# get rid of any old reports
13report=translation_status_report.txt
14if test -f $report; then
15 rm -f $report
16fi
17
18filelisting=("macros/*.dm" "perllib/strings*.properties" "gli/classes/dictionary*.properties" "gli/help/" "gsinstaller/LanguagePack*.properties" "greenstone3/*.properties" "gs3-collection-configs/*.properties" "greenstoneorg/website/classes/Gsc*.properties" "gs3-dec-col-cfgs/*.properties")
19
20date=`date +"%d-%m-%y"`
21echo "Translation status report for date: $date" >> $report
22echo "Checked in ${filelisting[@]}" >> $report
23echo "---------------------------------------------" >> $report
24
25# store backup of Internal Field Separator value, then set IFS to newline for splitting on newline
26IFS_BAK=$IFS
27# IFS='\n' # splits on all whitespace
28IFS='
29'
30
31num_modified=0
32num_added=0
33num_conflict=0
34
35# in the lines returned from the diff, test for archives or newline
36# http://stackoverflow.com/questions/229551/string-contains-in-bash
37# http://stackoverflow.com/questions/10515964/counter-increment-in-bash-loop-not-working
38for file in ${filelisting[@]}; do
39 if [[ "$file" != *"zz"* && "$file" != *"test"* ]]; then
40 # let's update the files first
41 #`svn up $file`
42 svn up $file > /dev/null
43 #status=`svn status $file`
44 svn status $file > tmpstatus.txt
45 status=`cat tmpstatus.txt`
46 # "LINE: $file - status: $status"
47 # if the file's svn status is modified, write the filename out to the report
48 if [[ "$status" == *"M "* ]]; then
49 #echo "$file has been modified: $status"
50 echo $status >> $report #echo $file >> $report
51 ((num_modified++))
52 fi
53 fi
54done
55
56
57if [[ $num_modified == 0 ]]; then
58 echo "No files modified" >> $report
59else
60 echo "" >> $report
61 echo "The above $num_modified files were modified." >> $report
62fi
63
64echo "---------------------------------------------" >> $report
65
66# repeat, this time looking for any newly added files
67for file in ${filelisting[@]}; do
68 if [[ "$file" != *"zz"* && "$file" != *"test"* ]]; then
69 #status=`svn status $file`
70 svn status $file > tmpstatus.txt
71 status=`cat tmpstatus.txt`
72 if [[ "$status" == *"? "* ]]; then
73 #echo "$file has been added: $status"
74 echo $status >> $report
75 ((num_added++))
76 fi
77 fi
78done
79
80if [[ $num_added == 0 ]]; then
81 echo "No files added" >> $report
82else
83 echo "" >> $report
84 echo "The above $num_added files were added." >> $report
85fi
86
87echo "---------------------------------------------" >> $report
88
89
90# repeat again, this time looking for any files in conflict
91for file in ${filelisting[@]}; do
92 status=`svn status $file`
93 if [[ "$status" == *"C "* ]]; then
94 #echo "$file is in conflict: $status"
95 echo $status >> $report
96 ((num_conflict++))
97 fi
98done
99
100if [[ $num_conflict == 0 ]]; then
101 echo "No files in conflict" >> $report
102 echo "---------------------------------------------" >> $report
103else
104 echo "" >> $report
105 echo "The above $num_conflict files were IN CONFLICT." >> $report
106 echo "---------------------------------------------" >> $report
107fi
108
109
110# restore IFS
111IFS=$IFS_BAK
112IFS_BAK=
113
114
115
116# if no files are modified, we don't send email, otherwise we do
117if [[ $num_modified != 0 || $num_added != 0 ]]; then
118# echo "Files were modified or added. Sending email..."
119 cat $report | mail -s 'GTI: '$num_modified/$num_added/$num_conflict' language file(s) on gti (nzdl) have been updated/added or conflict' $GREENSTONE_EMAIL
120 echo "Sent mail of report: $report"
121elif [[ $num_conflict != 0 ]]; then
122# echo "Files were modified or added. Sending email..."
123 cat $report | mail -s 'GTI: '$num_conflict' language file(s) on gti (nzdl) are IN CONFLICT' $GREENSTONE_EMAIL
124 echo "Sent mail of report: $report"
125else
126 echo "No files modified. Not sending mail."
127fi
128
129
130# delete tmp files
131rm tmpstatus.txt
132
133
134# Debugging
135# print env vars
136# if cron behaves differently from running this script from cmd line
137#set
Note: See TracBrowser for help on using the repository browser.