92-update-freshclam: do not error out on exit code 124 by freshclam.
[grml-live.git] / etc / grml / fai / config / scripts / GRMLBASE / 92-update-freshclam
1 #!/bin/bash
2 # Filename:      ${GRML_FAI_CONFIG}/config/scripts/GRMLBASE/92-update-freshclam
3 # Purpose:       update freshclam database
4 # Authors:       (c) Michael Prokop <mika@grml.org>
5 # Bug-Reports:   see http://grml.org/bugs/
6 # License:       This file is licensed under the GPL v2.
7 ################################################################################
8
9 if ifclass NO_ONLINE ; then
10   echo "Ignoring script 91-update-pciids as NO_ONLINE is set."
11   exit 0
12 fi
13
14 set -u
15
16 bailout() {
17   if [ "${1:-}" = "124" ] ; then
18     echo "Warning: freshclam returned with exit code 124." >&2
19
20     # be verbose in logs
21     echo "Warning: freshclam returned with exit code 124."
22     echo "-> This might happen when the incremental daily update failed to run, and"
23     echo "   retrieving the full daily.cvd failed as well."
24     echo "   This is known to be a problem in automated builds causing build errors."
25     echo "   Therefore we are ignoring this issue."
26     echo "   If a fresh clamav database is important for you, execute freshclam in the chroot."
27
28     exit 0
29   fi
30
31   exit "${1:-0}"
32 }
33
34 [ -x $target/usr/bin/timeout ] && TIMEOUT="10" || TIMEOUT=""
35
36 if ! [ -x $target/usr/bin/freshclam ] ; then
37   echo "freshclam not installed"
38   exit 0
39 fi
40
41 echo "Updating clamav database via running freshclam"
42 if [ -n "$TIMEOUT" ] ; then
43    $ROOTCMD timeout $TIMEOUT /usr/bin/freshclam
44    bailout $?
45 else
46    $ROOTCMD /usr/bin/freshclam
47    bailout $?
48 fi
49
50 ## END OF FILE #################################################################
51 # vim:ft=sh expandtab ai tw=80 tabstop=4 shiftwidth=2