source: other-projects/gti/translation_status.sh@ 33141

Last change on this file since 33141 was 31961, checked in by ak19, 7 years ago

Adding support in our automated daily GTI status emails for reporting translation files that are in SVN conflict. This is experiimental (untested) since nothing is presently in conflict. The need for the change became apparent when one translator-modified translation file was in conflict since late August and we weren't informed that it had been modified in our daily GTI status emails, since the script used to only report SVN modified and newly added files, not those whose svn status was marked as in conflict.

  • Property svn:executable set to *
File size: 4.2 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")
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 `svn up $file` # let's update the files first
41 status=`svn status $file`
42 # "LINE: $file - status: $status"
43 # if the file's svn status is modified, write the filename out to the report
44 if [[ "$status" == *"M "* ]]; then
45 #echo "$file has been modified: $status"
46 echo $status >> $report #echo $file >> $report
47 ((num_modified++))
48 fi
49 fi
50done
51
52
53if [[ $num_modified == 0 ]]; then
54 echo "No files modified" >> $report
55else
56 echo "" >> $report
57 echo "The above $num_modified files were modified." >> $report
58fi
59
60echo "---------------------------------------------" >> $report
61
62# repeat, this time looking for any newly added files
63for file in ${filelisting[@]}; do
64 if [[ "$file" != *"zz"* && "$file" != *"test"* ]]; then
65 status=`svn status $file`
66 if [[ "$status" == *"? "* ]]; then
67 #echo "$file has been added: $status"
68 echo $status >> $report
69 ((num_added++))
70 fi
71 fi
72done
73
74if [[ $num_added == 0 ]]; then
75 echo "No files added" >> $report
76else
77 echo "" >> $report
78 echo "The above $num_added files were added." >> $report
79fi
80
81echo "---------------------------------------------" >> $report
82
83
84# repeat again, this time looking for any files in conflict
85for file in ${filelisting[@]}; do
86 status=`svn status $file`
87 if [[ "$status" == *"C "* ]]; then
88 #echo "$file is in conflict: $status"
89 echo $status >> $report
90 ((num_conflict++))
91 fi
92done
93
94if [[ $num_conflict == 0 ]]; then
95 echo "No files in conflict" >> $report
96 echo "---------------------------------------------" >> $report
97else
98 echo "" >> $report
99 echo "The above $num_conflict files were IN CONFLICT." >> $report
100 echo "---------------------------------------------" >> $report
101fi
102
103
104
105
106# restore IFS
107IFS=$IFS_BAK
108IFS_BAK=
109
110
111
112# if no files are modified, we don't send email, otherwise we do
113if [[ $num_modified != 0 || $num_added != 0 ]]; then
114# echo "Files were modified or added. Sending email..."
115 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
116 echo "Sent mail of report: $report"
117elif [[ $num_conflict != 0 ]]; then
118# echo "Files were modified or added. Sending email..."
119 cat $report | mail -s 'GTI: '$num_conflict' language file(s) on gti (nzdl) are IN CONFLICT' $GREENSTONE_EMAIL
120 echo "Sent mail of report: $report"
121else
122 echo "No files modified. Not sending mail."
123fi
124
125# Debugging
126# print env vars
127# if cron behaves differently from running this script from cmd line
128#set
Note: See TracBrowser for help on using the repository browser.