alert.sh 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/bin/bash
  2. # LGSM alert.sh function
  3. # Author: Daniel Gibbs
  4. # Website: https://gameservermanagers.com
  5. lgsm_version="210516"
  6. # Description: Overall function for managing alerts.
  7. fn_alert_test(){
  8. fn_scriptlog "Sending test alert"
  9. alertsubject="LGSM - Test Alert - ${servername}"
  10. alertbody="LGSM test alert, how you read?"
  11. }
  12. fn_alert_restart(){
  13. fn_scriptlog "Sending restart alert: ${executable} process not running"
  14. alertsubject="LGSM - Restarted - ${servername}"
  15. alertbody="${servicename} ${executable} process not running"
  16. }
  17. fn_alert_restart_query(){
  18. fn_scriptlog "Sending restart alert: ${gsquerycmd}"
  19. alertsubject="LGSM - Restarted - ${servername}"
  20. alertbody="gsquery.py failed to query: ${gsquerycmd}"
  21. }
  22. fn_alert_update(){
  23. fn_scriptlog "Sending update alert"
  24. alertsubject="LGSM - Updated - ${servername}"
  25. alertbody="${servicename} recieved update"
  26. }
  27. if [ "${alert}" == "restart" ]; then
  28. fn_alert_restart
  29. elif [ "${alert}" == "restartquery" ]; then
  30. fn_alert_restart_query
  31. elif [ "${alert}" == "update" ]; then
  32. fn_alert_update
  33. elif [ "${alert}" == "test" ]; then
  34. fn_alert_test
  35. fi
  36. if [ "${emailnotification}" == "on" ]||[ "${emailalert}" == "on" ]&&[ -n "${email}" ]; then
  37. alert_email.sh
  38. elif [ "${emailnotification}" != "on" ]||[ "${emailalert}" != "on" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then
  39. fn_print_info_nl "Email alerts not enabled"
  40. fn_scriptlog "Email alerts not enabled"
  41. elif [ -z "${email}" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then
  42. fn_print_fail_nl "Email no set"
  43. fn_scriptlog "Email no set"
  44. fi
  45. if [ "${pushbulletalert}" == "on" ]&&[ -n "${pushbullettoken}" ]; then
  46. alert_pushbullet.sh
  47. elif [ "${pushbulletalert}" != "on" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then
  48. fn_print_info_nl "Pushbullet alerts not enabled"
  49. fn_scriptlog "Pushbullet alerts not enabled"
  50. elif [ -z "${pushbullettoken}" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then
  51. fn_print_fail_nl "Pushbullet token not set"
  52. fn_scriptlog "Pushbullet token not set"
  53. fi