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

Last change on this file since 30613 was 30613, checked in by ak19, 8 years ago

Don't send nightly email messages about updates to the test language files, since they're never committed and always appear updated, resulting in daily emails.

  • Property svn:executable set to *
File size: 3.0 KB
RevLine 
[29830]1#!/bin/bash
[28490]2
[28492]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
[28490]8[email protected]
9
10# get rid of any old reports
11report=translation_status_report.txt
12if test -f $report; then
13 rm -f $report
14fi
15
[30581]16filelisting=("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")
[28490]17
18date=`date +"%d-%m-%y"`
19echo "Translation status report for date: $date" >> $report
20echo "Checked in ${filelisting[@]}" >> $report
21echo "---------------------------------------------" >> $report
22
23# store backup of Internal Field Separator value, then set IFS to newline for splitting on newline
24IFS_BAK=$IFS
25# IFS='\n' # splits on all whitespace
26IFS='
27'
28
29num_modified=0
[29830]30num_added=0
[28490]31
32# in the lines returned from the diff, test for archives or newline
33# http://stackoverflow.com/questions/229551/string-contains-in-bash
34# http://stackoverflow.com/questions/10515964/counter-increment-in-bash-loop-not-working
35for file in ${filelisting[@]}; do
[30613]36 if [[ "$file" != *"zz"* && "$file" != *"test"* ]]; then
37 status=`svn status $file`
38 # "LINE: $file - status: $status"
39 # if the file's svn status is modified, write the filename out to the report
40 if [[ "$status" == *"M "* ]]; then
41 #echo "$file has been modified: $status"
42 echo $status >> $report #echo $file >> $report
43 ((num_modified++))
44 fi
[28490]45 fi
46done
47
48
49if [[ $num_modified == 0 ]]; then
50 echo "No files modified" >> $report
51else
[28491]52 echo "" >> $report
53 echo "The above $num_modified files were modified." >> $report
[28490]54fi
55
56echo "---------------------------------------------" >> $report
57
[29830]58# repeat, this time looking for any newly added files
59for file in ${filelisting[@]}; do
[30613]60 if [[ "$file" != *"zz"* && "$file" != *"test"* ]]; then
61 status=`svn status $file`
62 if [[ "$status" == *"? "* ]]; then
63 #echo "$file has been added: $status"
64 echo $status >> $report
65 ((num_added++))
66 fi
[29830]67 fi
68done
69
70if [[ $num_added == 0 ]]; then
71 echo "No files added" >> $report
72else
73 echo "" >> $report
74 echo "The above $num_added files were added." >> $report
75fi
76
77echo "---------------------------------------------" >> $report
78
79# restore IFS
80IFS=$IFS_BAK
81IFS_BAK=
82
83
84
[28490]85# if no files are modified, we don't send email, otherwise we do
[29830]86if [[ $num_modified != 0 || $num_added != 0 ]]; then
87# echo "Files were modified or added. Sending email..."
[30605]88 cat $report | mail -s 'GTI: '$num_modified/$num_added' language file(s) on gti (nzdl) have been updated/added' $GREENSTONE_EMAIL
[28491]89 echo "Sent mail of report: $report"
90else
91 echo "No files modified. Not sending mail."
[28490]92fi
Note: See TracBrowser for help on using the repository browser.