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

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

Not sure if there was a reason why we weren't svn updating the translation files every night, but it seems like a good idea. So adding the svn update line in, and we'll see if there's any problem that had earlier discouraged us from svn updating the translation files.

  • Property svn:executable set to *
File size: 3.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
33
34# in the lines returned from the diff, test for archives or newline
35# http://stackoverflow.com/questions/229551/string-contains-in-bash
36# http://stackoverflow.com/questions/10515964/counter-increment-in-bash-loop-not-working
37for file in ${filelisting[@]}; do
38 if [[ "$file" != *"zz"* && "$file" != *"test"* ]]; then
39 `svn up $file` # let's update the files first
40 status=`svn status $file`
41 # "LINE: $file - status: $status"
42 # if the file's svn status is modified, write the filename out to the report
43 if [[ "$status" == *"M "* ]]; then
44 #echo "$file has been modified: $status"
45 echo $status >> $report #echo $file >> $report
46 ((num_modified++))
47 fi
48 fi
49done
50
51
52if [[ $num_modified == 0 ]]; then
53 echo "No files modified" >> $report
54else
55 echo "" >> $report
56 echo "The above $num_modified files were modified." >> $report
57fi
58
59echo "---------------------------------------------" >> $report
60
61# repeat, this time looking for any newly added files
62for file in ${filelisting[@]}; do
63 if [[ "$file" != *"zz"* && "$file" != *"test"* ]]; then
64 status=`svn status $file`
65 if [[ "$status" == *"? "* ]]; then
66 #echo "$file has been added: $status"
67 echo $status >> $report
68 ((num_added++))
69 fi
70 fi
71done
72
73if [[ $num_added == 0 ]]; then
74 echo "No files added" >> $report
75else
76 echo "" >> $report
77 echo "The above $num_added files were added." >> $report
78fi
79
80echo "---------------------------------------------" >> $report
81
82# restore IFS
83IFS=$IFS_BAK
84IFS_BAK=
85
86
87
88# if no files are modified, we don't send email, otherwise we do
89if [[ $num_modified != 0 || $num_added != 0 ]]; then
90# echo "Files were modified or added. Sending email..."
91 cat $report | mail -s 'GTI: '$num_modified/$num_added' language file(s) on gti (nzdl) have been updated/added' $GREENSTONE_EMAIL
92 echo "Sent mail of report: $report"
93else
94 echo "No files modified. Not sending mail."
95fi
96
97# Debugging
98# print env vars
99# if cron behaves differently from running this script from cmd line
100#set
Note: See TracBrowser for help on using the repository browser.