25 lines
534 B
Plaintext
25 lines
534 B
Plaintext
|
#!/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"
|