update-notifier/pacman-update-count

25 lines
534 B
Plaintext
Raw Normal View History

2020-02-17 13:59:52 +00:00
#!/bin/sh
set -e
_updates_available="-1"
2020-02-17 13:59:52 +00:00
_target_file="/tmp/pacman-update-count"
_user="ray"
2020-02-17 14:41:15 +00:00
_user_id=$(id -u)
if ! [ "$_user_id" -eq 0 ] ; then
echo "pacman-update-count.sh: insufficient priviliges: must be run as root"
exit 1
fi
2020-02-17 13:59:52 +00:00
touch "$_target_file"
chown root: "$_target_file"
echo "$_updates_available" > "$_target_file"
2020-02-17 13:59:52 +00:00
pacman -Sy
_updates_available=$(pacman -Qu | wc -l)
2020-02-17 13:59:52 +00:00
echo "Adding $_updates_available available updates to $_target_file"
2020-02-17 13:59:52 +00:00
echo "$_updates_available" > "$_target_file"
chown "$_user": "$_target_file"