Skip to content

Instantly share code, notes, and snippets.

@llaumgui
Last active August 18, 2016 14:32
Show Gist options
  • Save llaumgui/8136913 to your computer and use it in GitHub Desktop.
Save llaumgui/8136913 to your computer and use it in GitHub Desktop.
To check yum and send me a mail.
#!/bin/zsh
#
# yum-check : Send by mail a "yum check-update"
#
# by Guillaume Kulakowski <guillaume@kulakowski.fr>
# Licensed under GPLv2 <https://www.gnu.org/licenses/old-licenses/gpl-2.0.html>
# Version 1.0.1
#
# Require : zsh, yum
# yum check-update
LIST=$(/usr/bin/yum check-update -d0)
NB_PCK=$(echo ${LIST}| wc -l)
let NB_PCK--
#### [ Settings to edit ] ####
MAIL_HEADER="[server.domain.ltd]"
MAIL_BODY_NONEW="Il n'y a pas de packet à mettre à jour."
MAIL_BODY_NEW="Il y a ${NB_PCK} packet(s) à mettre à jour."
MAIL_TITLE_NONEW="${MAIL_HEADER} Pas de nouvelle mise à jour"
MAIL_TITLE_NEW="${MAIL_HEADER} ${NB_PCK} mise(s) à jour"
#### [ / Settings to edit ] ####
MAIL_TITLE=${MAIL_TITLE_NONEW}
MAIL_BODY=${MAIL_BODY_NONEW}
if [ ${NB_PCK} -gt 0 ]; then
MAIL_TITLE=${MAIL_TITLE_NEW}
MAIL_BODY="${MAIL_BODY_NEW}\n\n${LIST}"
fi
echo -e ${MAIL_BODY} | /bin/mail -s "${MAIL_TITLE}" root
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment