From 16196010afcbcab562378e02fd4cb9173b0f810b Mon Sep 17 00:00:00 2001 From: Roger Pamies Date: Sat, 21 Jan 2023 00:33:52 +0100 Subject: [PATCH] new script update notifier --- gotifypush.sh | 2 +- updates-notifier.sh | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100755 updates-notifier.sh diff --git a/gotifypush.sh b/gotifypush.sh index 888ab22..d362e84 100644 --- a/gotifypush.sh +++ b/gotifypush.sh @@ -9,7 +9,7 @@ PATH=$PATH:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin TITLE=$1 MESSAGE=$2 PRIORITY=$3 -URL="https://push.example.com/message?token=$4" +URL="https://push.studi7.com/message?token=$4" #if url passed by parameter, set to extras if [ -n "$5" ] then diff --git a/updates-notifier.sh b/updates-notifier.sh new file mode 100755 index 0000000..bebc5a9 --- /dev/null +++ b/updates-notifier.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +PATH=$PATH:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin + +# vars gotify +readonly TOKEN="AIbX-rqHb6h0-BZ" + +#https://askubuntu.com/questions/269606/apt-get-count-the-number-of-updates-available +num=`apt-get -q -y --ignore-hold --allow-change-held-packages --allow-unauthenticated -s dist-upgrade | /bin/grep ^Inst | wc -l`; + +if [ "$num" -eq "0" ]; then + echo "No updates"; + exit; +else + #echo "There are $num updates"; + updates=`apt-get --fix-missing --no-download -s dist-upgrade -V | grep '=>' | awk '{print$1}';` + updates=$(echo $updates|tr -d '\n') + OUT="There are **$num** updates: \r" + OUT="${OUT} Packages: *$updates*" + sh ./gotifypush.sh "Kerolap updates notifier" "$OUT" 5 $TOKEN +fi