snippets / yum-check

Language: Shell - First posted by llaumgui on 2007-10-13 13:34 (8 months, 3 weeks)
Link to the snippet: http://www.friendsnippets.org/snippet/92/

yum-check permet l'envoi par mail d'un "yum check-update" mis en forme. A appeler dans une tâche cron

 1 #!/bin/zsh
2 ###############################################################################
3 #
4 # yum-check : Envoi par mail d'un "yum check-update" mis en forme
5 #
6 # by Guillaume Kulakowski a.k.a LLaumgui <guillaume at llaumgui dot com>
7 # Version 1.0
8 #
9 # Require : zsh, yum
10 #
11 ###############################################################################
12 # This program is free software; you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License
14 # as published by the Free Software Foundation; either version 2
15 # of the License, or (at your option) any later version.
16 #
17 # This program is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
21 #
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not,
24 # - write to the Free Software
25 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 # - See http://www.gnu.org/licenses/gpl.html
27 ###############################################################################
28
29
30 # yum check-update
31 LIST=$(/usr/bin/yum check-update -d0)
32 NB_PCK=$(echo $LIST| wc -l)
33 let NB_PCK--
34
35
36 #### [ Paramètres à modifier ] ####
37 MAIL_ENTETE="[spb-box.scenario-paintball.com]"
38 MAIL_BODY_NONEW="Il n'y a pas de packet a mettre à jour."
39 MAIL_BODY_NEW="Il y a $NB_PCK packet(s) a mettre à jour."
40 MAIL_TITLE_NONEW="$MAIL_ENTETE Pas de nouvelle mise a jour"
41 MAIL_TITLE_NEW="$MAIL_ENTETE $NB_PCK mise(s) a jour"
42 #### [ / Paramètres à modifier ] ####
43
44
45 MAIL_TITLE=$MAIL_TITLE_NONEW
46 MAIL_BODY=$MAIL_BODY_NONEW
47 if [ $NB_PCK -gt 0 ]; then
48 MAIL_TITLE=$MAIL_TITLE_NEW
49 MAIL_BODY="$MAIL_BODY_NEW\n\n$LIST"
50 fi
51
52
53 echo -e $MAIL_BODY | /bin/mail -s "$MAIL_TITLE" root
In order to post a comment, you should have a friendsnippet account. Please sign-in.

0 comments

Oct '07
  • yum-check permet l'envoi par mail d'un "yum check-update" mis en forme. A appeler dans une tâche cron

Common Tags



snippet History

Oct '07