ntfy
ntfy lets you send push notifications to your phone or desktop via scripts from any computer, using simple HTTP PUT or POST requests.
🔔 Low Space
Script
#!/bin/bash
mingigs=20
avail=$(df | awk '$6 == "/" && $4 < '$mingigs' * 1024*1024 { print $4/1024/1024 }')
if [ -n "$avail" ]; then
curl \
-H "Title: Low Disk Space" \
-H "Priority: urgent" \
-H "Tags: warning,cd" \
-d "Hello TTBB! Only $avail GB available on the root disk. Better clean that up." \
https://notify.boreux.work/raspberrypi?auth=<TOKEN>
fi
Cron
0 * * * * root /bin/bash /root/ntfy/low-disk-space.sh
⛔️ SSH Access
Script
#!/bin/bash
if [ "${PAM_TYPE}" = "open_session" ]; then
curl \
-H "Title: SSH Login" \
-H "Priority: urgent" \
-H "Tags: warning,door" \
-d "Hello TTBB! There was an SSH login with user ${PAM_USER} from ${PAM_RHOST} host" \
https://notify.boreux.work/pihole?auth=<TOKEN>
fi
/etc/pam.d/sshd
At the end of the file, add the following line:
session optional pam_exec.so /root/ntfy/ssh-login.sh
🐚 Useful Commands
Creating an Administrator
docker exec -it <NTFY_CONTAINER_NAME> ntfy user add --role=admin <USERNAME>