-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsendpush
59 lines (53 loc) · 1.13 KB
/
sendpush
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
function RTFM() {
echo Usage: $0 \[ login \| \<other app\> \]
echo
echo Sends a push notification to phone.
exit 1
}
if [[ -e /opt/projectsentinel/gotify-fqdn.txt ]]; then
fqdn=$(cat /opt/projectsentinel/gotify-fqdn.txt)
fi
if [[ -e /opt/projectsentinel/gotify-apptoken.txt ]]; then
AppToken=$(cat /opt/projectsentinel/gotify-apptoken.txt)
fi
function sendmsg() {
case $1 in
login)
case $2 in
*)
case $3 in
*)
user=$2
ipadr=$3
;;
esac
;;
esac
# Set the priority to make it appear on lockscreen
# Priority "anything higher than 7"\ is highest
curl -X POST "https://${fqdn}/message?token=${AppToken}" -F "title=Login notificaiton" -F "message=Login detected for user $user at IP $ipadr" -F "priority=7"
;;
smart)
drive=$1
curl -X POST "https://${fqdn}/message?token=${AppToken}" -F "title=SMART notification" -F "message=Drive $drive returned not PASSED, investigate." -F "priority=7"
;;
*)
echo Invalid args!
RTFM
exit 1
;;
esac
}
case $1 in
login)
if grep $3 /opt/projectsentinel/whitelist.txt >/dev/null; then
:
else
sendmsg login $2 $3
fi
;;
smart)
sendmsg smart $1
;;
esac