-
-
Save miri64/1717917 to your computer and use it in GitHub Desktop.
apticron for arch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# copy this file to /usr/local/sbin (or any other $PATH location) | |
# add to daily.cron | |
# ensure exits | |
VAR_FILE="/var/lib/pacicron/sha" | |
MAIL_TO="root" | |
HOST=$(uname -n) | |
PKGMGR=$(which yaourt || which pacman) | |
AURFLAG=$(which yaourt &> /dev/null && echo -en "a") | |
if [[ ! -f ${VAR_FILE} ]]; then | |
mkdir $(dirname ${VAR_FILE}) | |
touch ${VAR_FILE} | |
fi | |
# syncs and downloads all packages, without asking | |
${PKGMGR} -Swuy --noconfirm > /dev/null | |
${PKGMGR} -Sy${AURFLAG} > /dev/null | |
PKGLIST=$(${PKGMGR} -Q${AURFLAG}u | echo) # echo for trimming | |
SHA_NEW=$(echo "$PKGLIST" | sha1sum | cut -d" " -f1) | |
SHA_OLD=$(cat ${VAR_FILE}) | |
if [[ ${SHA_NEW} != ${SHA_OLD} && ${PKGLIST} != "" ]]; then | |
MSG="Following packages would be installed:\n\r\n\r${PKGLIST}\r\n\r\nSincerly yours pacicron\r\n" | |
echo -e ${MSG} | mail -s "New updates avaible on ${HOST}" -q /dev/stdin ${MAIL_TO} | |
echo ${SHA_NEW} > ${VAR_FILE} | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment