root/other-projects/gti/translation_status.sh @ 31176

Revision 30720, 3.1 KB (checked in by ak19, 3 years ago)

Getting the nightly gti email to be sent again on the new machine after changes to the mail server.

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