rename pacman-update-count.sh

This commit is contained in:
ray 2020-02-17 15:36:23 +00:00
commit dcaf306edd

24
pacman-update-count Executable file
View file

@ -0,0 +1,24 @@
#!/bin/sh
set -e
_updates_available="-1"
_target_file="/tmp/pacman-update-count"
_user="ray"
_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
touch "$_target_file"
chown root: "$_target_file"
echo "$_updates_available" > "$_target_file"
pacman -Sy
_updates_available=$(pacman -Qu | wc -l)
echo "Adding $_updates_available available updates to $_target_file"
echo "$_updates_available" > "$_target_file"
chown "$_user": "$_target_file"