.config/sway/scripts/checkUpdates.sh
This commit is contained in:
parent
1566384225
commit
9cb85af1a1
@ -1,21 +1,37 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Variables
|
||||||
|
checkupdates_file=/tmp/checkupdates
|
||||||
|
checkupdates_run="7200" # 2 hours
|
||||||
|
|
||||||
|
# checkupdates file init
|
||||||
|
if [ ! -f ${checkupdates_file} ] ; then
|
||||||
|
touch ${checkupdates_file}
|
||||||
|
echo "0" > ${checkupdates_file}
|
||||||
|
else
|
||||||
|
checkupdates_value=$(cat ${checkupdates_file})
|
||||||
|
checkupdates_incr=$(expr ${checkupdates_value} + 1)
|
||||||
|
echo "${checkupdates_incr}" > ${checkupdates_file}
|
||||||
|
fi
|
||||||
|
|
||||||
# Check updates on Arch Linux
|
# Check updates on Arch Linux
|
||||||
# Note: Create cron on /etc/cron.d/checkupdates with the following lines:
|
checkupdate=$(cat ${checkupdates_file})
|
||||||
# 0 * * * * root /usr/bin/pacman -Sy
|
|
||||||
# 30 * * * * root /usr/bin/pacman -Sy
|
|
||||||
if [ -f /usr/bin/pacman ] ; then
|
if [ -f /usr/bin/pacman ] ; then
|
||||||
|
if [ ${checkupdate} -ge ${checkupdates_run} ] ; then
|
||||||
|
sudo -A pacman -Syy > /dev/null 2>&1
|
||||||
|
echo "0" > ${checkupdates_file}
|
||||||
|
fi
|
||||||
num_packages=$(pacman -Qu | wc -l)
|
num_packages=$(pacman -Qu | wc -l)
|
||||||
echo " ${num_packages} "
|
echo " ${num_packages} "
|
||||||
|
|
||||||
# Check updates on Ubuntu/Debian/Devuan
|
# Check updates on Ubuntu/Debian/Devuan
|
||||||
# Note: Create cron on /etc/cron.d/checkupdates with the following lines:
|
elif [ -f /usr/bin/apt ] ; then
|
||||||
# 0 * * * * root /usr/bin/aptitude update
|
if [ ${checkupdate} -ge ${checkupdates_run} ] ; then
|
||||||
# 30 * * * * root /usr/bin/aptitude update
|
sudo -A apt-get update > /dev/null 2>&1
|
||||||
elif [ -f /usr/bin/aptitude ] ; then
|
echo "0" > ${checkupdates_file}
|
||||||
num_packages=$(aptitude search "~U" | wc -l)
|
fi
|
||||||
|
num_packages=$(apt list --upgradable 2>/dev/null | grep -c ^)
|
||||||
|
num_packages=$(expr ${num_packages} - 1)
|
||||||
echo " ${num_packages} "
|
echo " ${num_packages} "
|
||||||
|
|
||||||
# Disable for other distros
|
# Disable for other distros
|
||||||
else
|
else
|
||||||
echo " 0 "
|
echo " 0 "
|
||||||
|
Loading…
x
Reference in New Issue
Block a user