Added support for push notifications using PushOver

This commit is contained in:
Malte Bublitz 2022-04-11 09:20:57 +02:00
parent 74fadc6387
commit 734467bb44
2 changed files with 37 additions and 0 deletions

View file

@ -178,3 +178,11 @@ SCRIPT_RUNTIME=$(echo "scale=3;$SCRIPT_END-$SCRIPT_START" | bc)
message "Done after ${SCRIPT_RUNTIME} seconds." message "Done after ${SCRIPT_RUNTIME} seconds."
message "Everything was stored in ${BACKUP_DEST}" message "Everything was stored in ${BACKUP_DEST}"
#
# Notify admin via Pushover
#
_backup_size=$(du -sh ${BACKUP_DEST} | awk '{print $1}')
echo "${SCRIPT_NAME} finished after $(echo $SCRIPT_RUNTIME | cut -d. -f1) seconds.
Backup location: $BACKUP_DEST
Size: $_backup_size" | pushover-notify "${SCRIPT_NAME} successfull"

29
pushover-notify Normal file
View file

@ -0,0 +1,29 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import os
from pushover import Pushover # https://github.com/Wyattjoh/pushover
class Config(object):
api_key = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
user_key = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
def main(message, title):
po = Pushover(Config.api_key)
po.user(Config.user_key)
msg = po.msg(message)
msg.set("title", title)
po.send(msg)
if __name__ == "__main__":
if len(sys.argv) < 2:
title = os.uname().nodename
else:
title = sys.argv[1]
message = sys.stdin.read()
main(message, title)