Ver Fonte

adding in error checking

Daniel Gibbs há 10 anos atrás
pai
commit
021df3d9ec
2 ficheiros alterados com 13 adições e 7 exclusões
  1. 12 3
      lgsm/functions/alert_pushbullet.sh
  2. 1 4
      lgsm/functions/command_test_alert.sh

+ 12 - 3
lgsm/functions/alert_pushbullet.sh

@@ -8,7 +8,16 @@ lgsm_version="140516"
 
 local modulename="Alert"
 function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
+fn_print_dots "Sending Pushbullet alert"
+sleep 1
+
+pushbulletsend=$(curl --silent -u """${pushbullettoken}"":" -d type="note" -d body="${alertbody}" -d title="${alertsubject}" 'https://api.pushbullet.com/v2/pushes'|grep -o invalid_access_token|uniq)
+
+if [ "${pushbulletsend}" == "invalid_access_token" ]; then
+	fn_print_fail_nl "Sending Pushbullet alert: invalid_access_token"
+	fn_scriptlog "Failure! Sending Pushbullet alert: invalid_access_token"
+else
+	fn_print_ok_nl "Sending Pushbullet alert"
+	fn_scriptlog "Complete! Sent Pushbullet alert"
+fi
 
-curl -u """${pushbullettoken}"":" -d type="note" -d body="${alertbody}" -d title="${alertsubject}" 'https://api.pushbullet.com/v2/pushes' >/dev/null 2>&1
-fn_print_ok_nl "Sent Pushbullet alert"
-fn_scriptlog "Sent Pushbullet alert"

+ 1 - 4
lgsm/functions/command_test_alert.sh

@@ -12,7 +12,4 @@ function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
 check.sh
 info_config.sh
 alert="test"
-	alert.sh
-	fn_print_fail_nl "alerts not enabled"
-	fn_scriptlog "alerts not enabled"
-fi
+alert.sh