diff --git a/nutNotify.conf.txt b/nutNotify.conf.txt index 7583c0d..780d37e 100644 --- a/nutNotify.conf.txt +++ b/nutNotify.conf.txt @@ -36,4 +36,11 @@ telegramProviderApi='https://api.telegram.org' telegramAccessToken='' telegramChatID='' telegramSubject="UPS event $argument" #subject sent by telegram -telegramMessage="$bodyDefault" #body message sent by telegram \ No newline at end of file +telegramMessage="$bodyDefault" #body message sent by telegram + +#--- Data for Pushover ---# +pushoverProviderApi='https://api.pushover.net/1/messages.json' +pushoverAppToken='xxxxxxxxxxxxxxxxxxxxxxxxxxxx' #ApplicationToken +pushoverUserkey='xxxxxxxxxxxxxxxxxxxxxxxxxxxx' #UserKey +pushoverSubject="UPS event $argument" #subject sent by Pushover +pushoverMessage="$bodyDefault" #body message sent by Pushover \ No newline at end of file diff --git a/nutNotify.sh b/nutNotify.sh index 5299235..71873c4 100644 --- a/nutNotify.sh +++ b/nutNotify.sh @@ -53,6 +53,7 @@ ONLINE) writeLog sendMail "$subjectMail" "$text" #sendPushBullet "$pushbulletSubject" "$text" + #sendPushover "$pushoverSubject" "$text" sendTelegram "$text" "$telegramSubject" ;; @@ -61,6 +62,7 @@ ONBATT) writeLog #sendMail "$subjectMail" "$text" #sendPushBullet "$pushbulletSubject" "$text" + #sendPushover "$pushoverSubject" "$text" emoji=$(echo -e "\xE2\x9A\xA0") sendTelegram "$text" "$telegramSubject" "$emoji" # sendSms "$text" @@ -72,6 +74,7 @@ LOWBATT) writeLog #sendMail "$subjectMail" "$text" #sendPushBullet "$pushbulletSubject" "$text" + #sendPushover "$pushoverSubject" "$text" emoji=$(echo -e "\xF0\x9F\x94\xA5") sendTelegram "$text" "$telegramSubject" "$emoji" # sendSms "$text" @@ -83,6 +86,7 @@ FSD) writeLog #sendMail "$subjectMail" "$text" #sendPushBullet "$pushbulletSubject" "$text" + #sendPushover "$pushoverSubject" "$text" emoji=$(echo -e "\xE2\x9A\xA0") sendTelegram "$text" "$telegramSubject" "$emoji" # sendSms "$text" @@ -94,6 +98,7 @@ SHUTDOWN) writeLog #sendMail "$subjectMail" "$text" #sendPushBullet "$pushbulletSubject" "$text" + #sendPushover "$pushoverSubject" "$text" emoji=$(echo -e "\xF0\x9F\x94\xA5") sendTelegram "$text" "$telegramSubject" "$emoji" # sendSms "$text" @@ -103,6 +108,7 @@ COMMOK|COMMBAD|REPLBATT|NOCOMM) writeLog #sendMail #sendPushBullet + #sendPushover "$pushoverSubject" "$text" sendTelegram "$text" "$telegramSubject" # sendSms ;; @@ -116,7 +122,8 @@ SERVERONLINE) rm -f $powerdownflag && \ writeLog && \ sendMail "$subjectMail" "$text" - sendPushBullet "$pushbulletSubject" "$text" + #sendPushBullet "$pushbulletSubject" "$text" + #sendPushover "$pushoverSubject" "$text" sendTelegram "$text" "$telegramSubject" fi ;; diff --git a/nutNotifyFct.sh b/nutNotifyFct.sh index ec2b44a..74010f6 100644 --- a/nutNotifyFct.sh +++ b/nutNotifyFct.sh @@ -86,8 +86,8 @@ function sendPushBullet { #var verification if [ "$pushbulletProviderApi" == "" ] || [ "$pushbulletAccessToken" == "" ] ; then - echo "Can't sen push notification without complete variables for PushBullet" 1>&2 - addLog "Can't sen push notification without complete variables for PushBullet" + echo "Can't send push notification without complete variables for PushBullet" 1>&2 + addLog "Can't send push notification without complete variables for PushBullet" return 1 fi @@ -125,4 +125,33 @@ function sendTelegram { if [ $returnCurl -ne 0 ] ; then cat $tempfile ; fi rm $tempfile return $returnCurl +} + +function sendPushover { + #replace default mesg + if [ "$1" != "" ] ; then + subjectPushover=$1 + fi + if [ "$2" != "" ] ; then + textPushover=$2 + fi + + #var verification + if [ "$pushoverProviderApi" == "" ] || [ "$pushoverAppToken" == "" ] || [ "$pushoverUserkey" == "" ] ; then + echo "Can't send push notification without complete variables for Pushover" 1>&2 + addLog "Can't send push notification without complete variables for Pushover" + return 1 + fi + + tempfile=$(mktemp --suffix '.nutNotifyPushOver') + curl -s \ + --form-string "token=$pushoverAppToken" \ + --form-string "user=$pushoverUserkey" \ + --form-string "title=$subjectPushover" \ + --form-string "message=$textPushover" \ + $pushoverProviderApi + returnCurl=$? + if [ $returnCurl -ne 0 ] ; then cat $tempfile ; fi + rm $tempfile + return $returnCurl } \ No newline at end of file