24 lines
727 B
Bash
24 lines
727 B
Bash
|
#!/bin/bash
|
||
|
|
||
|
PATH=$PATH:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
|
||
|
|
||
|
# vars gotify
|
||
|
readonly TOKEN="<TOKEN_GOTIFY_APP>"
|
||
|
|
||
|
apt update -qq
|
||
|
|
||
|
#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 "Example host updates notifier" "$OUT" 5 $TOKEN
|
||
|
fi
|