wikiNewPageAlert.sh 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/bin/bash
  2. # Created By : mrkips (Cybergavin)
  3. # Created On : 31st March 2012
  4. # Description : This script queries the mediawiki database and sends a notification regarding page creation. Reminds users about the existence of the wiki and what's in there.
  5. #####################################################################################
  6. #
  7. # Variables
  8. #
  9. EMAIL_RECIPIENTS="wikiusers@abc.com"
  10. REPORT_DATE=$(date '+%Y%m%d' --date="yesterday")
  11. REPORT_DATE_FORMAIL=$(date '+%d-%b-%Y' --date="yesterday")
  12. WIKI_BASEURL="http://wiki.abc.com/wiki/index.php/"
  13. #
  14. # Functions
  15. #
  16. getDBdata()
  17. {
  18. mysql -u wiki -p'xxxxx' --skip-column-names wiki <<EOSQL
  19. connect wiki;
  20. select rc_title, rc_user_text from recentchanges
  21. where rc_timestamp like '$REPORT_DATE%'
  22. and rc_type = 1
  23. and rc_namespace=0;
  24. quit
  25. EOSQL
  26. }
  27. #
  28. # Main
  29. #
  30. mail -s "ABC Wiki : New Page Notification For $REPORT_DATE_FORMAIL" $EMAIL_RECIPIENTS <<EOMAIL
  31. Hi
  32. Given below are Pages created on the ABC Wiki ( http://wiki.abc.com ) yesterday ($REPORT_DATE_FORMAIL) along with their authors:
  33. `getDBdata | awk -v a="$WIKI_BASEURL" '{printf "%-70s %s %s\n", a$1,"-", $2}'`
  34. EOMAIL
  35. #
  36. ##################################### T H E E N D ###############################