| #!/bin/bash |
| |
| MAILLOG=/tmp/openmex_dashboard_mail_stats.log |
| NEWSLOG=/tmp/openmex_dashboard_news_stats.log |
| BUGSLOG=/tmp/openmex_dashboard_bugs_stats.log |
| LIVELOG=/tmp/openmex_dashboard_live_stats.log |
| ARTICLELOG=/tmp/openmex_dashboard_article_stats.log |
| ERRORLOG=/tmp/openmex_dashboard_stats_errors.log |
| STDERRLOG=/tmp/openmex_dashboard_stats_stderr.log |
| |
| function html() { |
| tmp=`tail -1 $1 | tr -d '<>/'` |
| if [ "X$tmp" == "Xhtml" ]; then |
| return 1 |
| else |
| return 0 |
| fi |
| } |
| |
| if [ $# -ne 1 ]; then |
| echo "You must pass the item to compute" > $ERRORLOG |
| else |
| case "X$1" in |
| "Xbugs") |
| wget http://www.eclipse.org/projects/stats/compute_bugs_stats.php --quiet --output-document=$BUGSLOG 2>> $STDERRLOG |
| ;; |
| "Xlive") |
| wget http://www.eclipse.org/projects/stats/compute_liveness.php --quiet --output-document=$LIVELOG 2>> $STDERRLOG |
| ;; |
| "Xnews") |
| wget http://www.eclipse.org/projects/stats/compute_newsgroups_stats.php --quiet --output-document=$NEWSLOG 2>> $STDERRLOG |
| ;; |
| "Xmail") |
| wget http://www.eclipse.org/projects/stats/compute_mail_stats.php --quiet --output-document=$MAILLOG 2>> $STDERRLOG |
| ;; |
| "Xart") |
| wget http://www.eclipse.org/projects/stats/compute_articles_stats.php --quiet --output-document=$ARTICLELOG 2>> $STDERRLOG |
| ;; |
| "Xcheck") |
| # Check whether all files got generated through the cron |
| test -e $MAILLOG |
| mail=$? |
| test -e $NEWSLOG |
| news=$? |
| test -e $BUGSLOG |
| bugs=$? |
| test -e $LIVELOG |
| live=$? |
| test -e $ARTICLELOG |
| art=$? |
| if [ $mail -eq 1 -o $news -eq 1 -o $live -eq 1 -o $bugs -eq 1 -o $art -eq 1 ] |
| then |
| echo "SIZE m: $mail n: $news l: $live b: $bugs a: $art" >> $ERRORLOG |
| mail 4167169356@pcs.rogers.com < $ERRORLOG |
| exit |
| fi |
| # Determine if all files close HTML properly. If they don't there |
| # might be an error |
| html $MAILLOG |
| mail=$? |
| html $NEWSLOG |
| news=$? |
| html $BUGSLOG |
| bugs=$? |
| html $LIVELOG |
| live=$? |
| html $ARTICLELOG |
| art=$? |
| if [ $mail -eq 0 -o $bugs -eq 0 -o $news -eq 0 -o $live -eq 0 -o $art -eq 0 ]; then |
| echo "HTML m: $mail n: $news l: $live b: $bugs a: $art" > $ERRORLOG |
| mail 4167169356@pcs.rogers.com < $ERRORLOG |
| exit |
| fi |
| if [ -s "$STDERRLOG" ]; then |
| mail 4167169356@pcs.rogers.com < $STDERRLOG |
| mail dfiguero@openmex.com < $STDERRLOG |
| else # No errors |
| rm $MAILLOG $NEWSLOG $BUGSLOG $LIVELOG $ARTICLELOG $ERRORLOG $STDERRLOG |
| fi |
| ;; |
| esac |
| fi |