added gotify to login-notify.sh
This commit is contained in:
parent
6332d3028e
commit
8729431f90
1 changed files with 11 additions and 4 deletions
|
@ -1,11 +1,18 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
GOTIFY_FILE=$(<~/.gotify)
|
||||||
|
GOTIFY_TOKEN=${GOTIFY_FILE##*( )}
|
||||||
|
HOST="$(hostname)"
|
||||||
sender="SSH-Notification <notifications@sp-codes.de>"
|
sender="SSH-Notification <notifications@sp-codes.de>"
|
||||||
recipient="codes@samuel-philipp.de"
|
recipient="codes@samuel-philipp.de"
|
||||||
|
|
||||||
if [ "$PAM_TYPE" == "open_session" ] && [ "$PAM_USER" != "root" ]; then
|
|
||||||
HOST="`hostname`"
|
|
||||||
subject="SSH Login: $PAM_USER from $PAM_RHOST on $HOST"
|
subject="SSH Login: $PAM_USER from $PAM_RHOST on $HOST"
|
||||||
message="User $PAM_USER logged in on $HOST from $PAM_RHOST at $(date)."
|
message="User $PAM_USER logged in on $HOST from $PAM_RHOST at $(date)."
|
||||||
|
|
||||||
|
if [ "$PAM_TYPE" == "open_session" ]; then
|
||||||
|
if [ "$PAM_USER" != "root" ]; then
|
||||||
echo "$message" | mailx -a "From: $sender" -s "$subject" "$recipient"
|
echo "$message" | mailx -a "From: $sender" -s "$subject" "$recipient"
|
||||||
fi
|
fi
|
||||||
|
if [ -n "$GOTIFY_TOKEN" ]; then
|
||||||
|
curl -F "title=$subject" -F "message=$message" -F "priority=5" "https://push.sp-codes.de/message?token=$GOTIFY_TOKEN"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
Reference in a new issue