#!/bin/bash
# see if there are any Debian updates and pop-up a notice if there are
# needs an /etc/sudoers.d/adm-apt-privs that has
# Cmnd_Alias ADM_COMMANDS = /usr/bin/apt update
# %adm ALL = (root) NOPASSWD: ADM_COMMANDS
# get a temporary file
tempf=$(mktemp -q --tmpdir=/tmp -t updXXXXX)
stat=$?
if [ ${stat} != 0 ]; then
echo "OhNoes!!! Unable to create a temporary file. Status: ${stat}"
exit 9
fi
size=$(ls -s $tempf | awk '{print $1}')
[ $size != "0" ] && \
notify-send -u critical "Debian updates available" "$(cat $tempf)"
Also, you should quote "$tempf".
[ -s "$tempf" ] && notify-send ...
is there any way that
$(mktemp -q --tmpdir=/tmp -t updXXXXX)
would return a 0 status and a filename with embedded spaces .. or with anything that would require quoting?
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 546 |
Nodes: | 16 (2 / 14) |
Uptime: | 09:00:59 |
Calls: | 10,388 |
Calls today: | 3 |
Files: | 14,061 |
Messages: | 6,416,841 |
Posted today: | 1 |