You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
740 B
30 lines
740 B
#!/bin/bash |
|
|
|
GOTIFY_FILE=$(<~/.gotify) |
|
GOTIFY_TOKEN=${GOTIFY_FILE##*( )} |
|
HOST="$(hostname)" |
|
TITLE="Updates available on $HOST" |
|
|
|
if [ "$EUID" -ne 0 ]; then |
|
echo "Please run as root" |
|
exit |
|
fi |
|
|
|
apt update |
|
|
|
UPDATE=$(apt list --upgradable) |
|
|
|
echo "$UPDATE" |
|
|
|
if [[ $UPDATE == *$'\n'* ]]; then |
|
curl -F "title=$TITLE" -F "message=$UPDATE" -F "priority=5" "https://push.sp-codes.de/message?token=$GOTIFY_TOKEN" |
|
fi |
|
|
|
if [ -f /var/run/reboot-required ]; then |
|
TITLE="Reboot required on $HOST" |
|
MESSAGE="Reboot required\n" |
|
if [ -f /var/run/reboot-required.pkgs ]; then |
|
MESSAGE+=$(cat /var/run/reboot-required.pkgs) |
|
fi |
|
curl -F "title=$TITLE" -F "message=$MESSAGE" -F "priority=5" "https://push.sp-codes.de/message?token=$GOTIFY_TOKEN" |
|
fi
|
|
|