Aggiungi 'updrbchk'
Bash script which looks for available updates and if host needs to be rebooted. Then, a notification is sent with Telegram Bot API on a chatID of your choice with telegram-send auxiliary script.
This commit is contained in:
32
updrbchk
Normal file
32
updrbchk
Normal file
@@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
IFS=';' read updates security_updates < <(/usr/lib/update-notifier/apt-check 2>&1)
|
||||
HOSTNAME=`hostname`
|
||||
|
||||
if [ ! -f ".update-check-status" ] ; then
|
||||
echo "0:0" > .update-check-status
|
||||
fi
|
||||
|
||||
CONTROL="$updates:$security_updates"
|
||||
HASCHANGED=false
|
||||
ACTUALSTATE=`cat .update-check-status`
|
||||
|
||||
if [ "$ACTUALSTATE" != "$CONTROL" ]; then
|
||||
HASCHANGED=true
|
||||
echo $CONTROL > .update-check-status
|
||||
fi
|
||||
|
||||
function send_message {
|
||||
/usr/bin/telegram-send "[ACTION REQUIRED ON $HOSTNAME]
|
||||
|
||||
$1"
|
||||
}
|
||||
|
||||
if [ $updates -gt 0 ] || [ $security_updates -gt 0 ] ; then
|
||||
if $HASCHANGED; then
|
||||
send_message "There are *$updates* updates available for *$HOSTNAME* and *$security_updates* of them are security updates"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -f /var/run/reboot-required ]; then
|
||||
send_message "Reboot needed on *$HOSTNAME*"
|
||||
fi
|
||||
Reference in New Issue
Block a user