#!/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"
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)
curl -F "title=$TITLE" -F "message=$MESSAGE" -F "priority=5" "https://push.sp-codes.de/message?token=$GOTIFY_TOKEN"