<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.alpinelinux.org/w/index.php?action=history&amp;feed=atom&amp;title=Up_clam_ex.sh</id>
	<title>Up clam ex.sh - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.alpinelinux.org/w/index.php?action=history&amp;feed=atom&amp;title=Up_clam_ex.sh"/>
	<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Up_clam_ex.sh&amp;action=history"/>
	<updated>2026-05-11T02:13:36Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.40.0</generator>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Up_clam_ex.sh&amp;diff=6932&amp;oldid=prev</id>
		<title>Dubiousjim: Category:Mail</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Up_clam_ex.sh&amp;diff=6932&amp;oldid=prev"/>
		<updated>2012-03-12T09:42:42Z</updated>

		<summary type="html">&lt;p&gt;Category:Mail&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 09:42, 12 March 2012&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l418&quot;&gt;Line 418:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 418:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;exit $?&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;exit $?&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Category:Mail]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Dubiousjim</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Up_clam_ex.sh&amp;diff=2787&amp;oldid=prev</id>
		<title>Ncopa: reformat</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Up_clam_ex.sh&amp;diff=2787&amp;oldid=prev"/>
		<updated>2009-05-21T08:48:20Z</updated>

		<summary type="html">&lt;p&gt;reformat&lt;/p&gt;
&lt;a href=&quot;https://wiki.alpinelinux.org/w/index.php?title=Up_clam_ex.sh&amp;amp;diff=2787&amp;amp;oldid=2309&quot;&gt;Show changes&lt;/a&gt;</summary>
		<author><name>Ncopa</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Up_clam_ex.sh&amp;diff=2309&amp;oldid=prev</id>
		<title>Clandmeter: New page:  #!/bin/sh   # update_clamd_extra_sigs.sh v0.2 by Dan Larsson &lt;dl|at|tyfon|dot|net&gt;  # ==============================================================================  # LICENSE  # ========...</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Up_clam_ex.sh&amp;diff=2309&amp;oldid=prev"/>
		<updated>2008-06-06T13:19:25Z</updated>

		<summary type="html">&lt;p&gt;New page:  #!/bin/sh   # update_clamd_extra_sigs.sh v0.2 by Dan Larsson &amp;lt;dl|at|tyfon|dot|net&amp;gt;  # ==============================================================================  # LICENSE  # ========...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt; #!/bin/sh&lt;br /&gt;
&lt;br /&gt;
 # update_clamd_extra_sigs.sh v0.2 by Dan Larsson &amp;lt;dl|at|tyfon|dot|net&amp;gt;&lt;br /&gt;
 # ==============================================================================&lt;br /&gt;
 # LICENSE&lt;br /&gt;
 # ==============================================================================&lt;br /&gt;
 # &amp;quot;THE BEER-WARE LICENSE&amp;quot; (Revision 42):&lt;br /&gt;
 # &amp;lt;dl|at|tyfon|dot|net&amp;gt; wrote this file. As long as you retain this&lt;br /&gt;
 # notice you can do whatever you want with this stuff. If we meet&lt;br /&gt;
 # some day, and you think this stuff is worth it, you can buy me a&lt;br /&gt;
 # beer in return. Dan Larsson&lt;br /&gt;
 #&lt;br /&gt;
 # ==============================================================================&lt;br /&gt;
 # VERSION INFO&lt;br /&gt;
 # ==============================================================================&lt;br /&gt;
 # v0.2 - 2008-08-23&lt;br /&gt;
 #   * Don&amp;#039;t use non-word chars in function names&lt;br /&gt;
 #   * Changed the SecuriteInfo signature source url&lt;br /&gt;
 #     (Thank&amp;#039;s to Bill Landry for pointing out the above two)&lt;br /&gt;
 #   * Cleaned up and added comments&lt;br /&gt;
 #   * Misc cosmetic changes&lt;br /&gt;
 #&lt;br /&gt;
 # v0.1 - 2008-08-22&lt;br /&gt;
 #   * Initial release, branched from v1.4 of Bill Landry&amp;#039;s&lt;br /&gt;
 #     ss-msrbl.sh script&lt;br /&gt;
 #&lt;br /&gt;
 # ==============================================================================&lt;br /&gt;
 # README&lt;br /&gt;
 # ==============================================================================&lt;br /&gt;
 # In order to run this script you need to have curl, rsync and clamd installed&lt;br /&gt;
 # on your machine aswell as the basic set of unix-like tools (i.e. awk, sed,&lt;br /&gt;
 # cat, cp, gunzip etc...).&lt;br /&gt;
 #&lt;br /&gt;
 # If this script fails to run on your system or you have made improvements that&lt;br /&gt;
 # you wish to share, you&amp;#039;re welcome to drop me a line.&lt;br /&gt;
 #&lt;br /&gt;
 # ==============================================================================&lt;br /&gt;
 # USAGE&lt;br /&gt;
 # ==============================================================================&lt;br /&gt;
 # Using this script is easy, just configure the parameters, save the changes&lt;br /&gt;
 # and execute from the prompt (or via cron). Should you want to add additional&lt;br /&gt;
 # signature databases simply add their download urls to the appropriate&lt;br /&gt;
 # section(s) here below and you&amp;#039;re done! Naturally, it&amp;#039;s just as easy to remove&lt;br /&gt;
 # and edit :-) No script coding necessary!&lt;br /&gt;
 #&lt;br /&gt;
 # ==============================================================================&lt;br /&gt;
 # SIGNATURE SOURCES&lt;br /&gt;
 # ==============================================================================&lt;br /&gt;
 # SaneSecurity (phish.ndb, scam.ndb)&lt;br /&gt;
 # http://www.sanesecurity.com/clamav/usage.htm&lt;br /&gt;
 #&lt;br /&gt;
 # SecuriteInfo (vx.hdb)&lt;br /&gt;
 # http://www.securiteinfo.com/services/clamav_unofficial_malwares_signatures.shtml&lt;br /&gt;
 #&lt;br /&gt;
 # MalwareBlockList (mbl.db)&lt;br /&gt;
 # http://www.malware.com.br/clamav.txt&lt;br /&gt;
 #&lt;br /&gt;
 # MSRBL (MSRBL-Images.hdb, MSRBL-SPAM.ndb)&lt;br /&gt;
 # http://www.msrbl.com/site/msrblimagesdownload&lt;br /&gt;
 # http://www.msrbl.com/site/msrblspamdownload&lt;br /&gt;
 #&lt;br /&gt;
 # ==============================================================================&lt;br /&gt;
 # SOURCE ARGUMENTS ( see below for more info in source arguments )&lt;br /&gt;
 # ==============================================================================&lt;br /&gt;
 # Name                Value        Comment&lt;br /&gt;
 # ------------------- --------- ------------------------------------------------&lt;br /&gt;
 # fetch_interval      integer   Forced delay in seconds between download&lt;br /&gt;
 #                               attempts&lt;br /&gt;
 # target_file         string    Use this name for the signature database&lt;br /&gt;
 #                               (instead of extracting it from the source file)&lt;br /&gt;
&lt;br /&gt;
 ################################################################################&lt;br /&gt;
 #       SCRIPT USER EDIT SECTION - SET PROGRAM PATHS AND OTHER VARIABLES       #&lt;br /&gt;
 ################################################################################&lt;br /&gt;
&lt;br /&gt;
 # *** COMMENT OUT THE BELOW LINE WHEN YOU HAVE CONFIGURED THIS SCRIPT ***&lt;br /&gt;
 #script_not_configured=1&lt;br /&gt;
&lt;br /&gt;
 # Set and export the command searchpaths&lt;br /&gt;
 PATH=/root/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin&lt;br /&gt;
 export PATH&lt;br /&gt;
&lt;br /&gt;
 # Set path to ClamAV database dir location as well as&lt;br /&gt;
 # the clamd user and group account&lt;br /&gt;
 clamd_dbdir=/var/lib/clamav&lt;br /&gt;
 clamd_user=clamav&lt;br /&gt;
 clamd_group=clamav&lt;br /&gt;
&lt;br /&gt;
 # Set path to the clamd pidfile&lt;br /&gt;
 # (comment out to disable forced database reload)&lt;br /&gt;
 clamd_pidfile=/var/run/clamav/clamd.pid&lt;br /&gt;
&lt;br /&gt;
 # Set backup and temp working directory paths&lt;br /&gt;
 # (edit to meet your own needs)&lt;br /&gt;
 backup_dir=/var/backups/clamav&lt;br /&gt;
 tmp_dir=/var/tmp/clamdb&lt;br /&gt;
 rsync_dir=/var/tmp/rsync&lt;br /&gt;
&lt;br /&gt;
 # HTTP source urls - *MUST* be HTTP urls, one url per line&lt;br /&gt;
 # (add/remove/modify urls as per preference and/or need,&lt;br /&gt;
 # to disable, comment out the below six lines)&lt;br /&gt;
 http_source_urls=&amp;quot;&lt;br /&gt;
    http://www.sanesecurity.com/clamav/phishsigs/phish.ndb.gz&lt;br /&gt;
    http://www.sanesecurity.com/clamav/scamsigs/scam.ndb.gz&lt;br /&gt;
    http://clamav.securiteinfo.com/vx.hdb.gz&lt;br /&gt;
    http://www.malware.com.br/cgi/submit?action=list_clamav,fetch_interval=86400,target_file=mbl.db&lt;br /&gt;
 &amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # RSYNC source urls - *MUST* be RSYNC urls, one url per line&lt;br /&gt;
 # (add/remove/modify urls as per preference and/or need,&lt;br /&gt;
 # to disable, comment out the below four lines)&lt;br /&gt;
 rsync_source_urls=&amp;quot;&lt;br /&gt;
    rsync://rsync.mirror.msrbl.com/msrbl/MSRBL-Images.hdb&lt;br /&gt;
    rsync://rsync.mirror.msrbl.com/msrbl/MSRBL-SPAM.ndb&lt;br /&gt;
 &amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Arguments can be appended to the source_url, if you do so&lt;br /&gt;
 # seperate them from the source url and eachother with commas&lt;br /&gt;
 # ( e.g. scheme://hostname/path,arg1=123,arg2=abc )&lt;br /&gt;
 # Please note that it&amp;#039;s very important you null their value when&lt;br /&gt;
 # they&amp;#039;ve served their purpose, not doing so will lead to weird&lt;br /&gt;
 # results&lt;br /&gt;
&lt;br /&gt;
 # Enable random sleeping before processing&lt;br /&gt;
 # - recommeded when running via cron!&lt;br /&gt;
 # (to disable this comment out the below line)&lt;br /&gt;
 #sleep_enabled=1&lt;br /&gt;
&lt;br /&gt;
 # Show each slept second visually&lt;br /&gt;
 # - disabled when running via cron.&lt;br /&gt;
 # (to disable this comment out the below line)&lt;br /&gt;
 sleep_visual=1&lt;br /&gt;
&lt;br /&gt;
 # Compress all downloaded *source files* with gzip&lt;br /&gt;
 # (to disable this comment out the below line)&lt;br /&gt;
 keep_sources_gzipped=1&lt;br /&gt;
&lt;br /&gt;
 ################################################################################&lt;br /&gt;
 # END OF SCRIPT USER EDIT SECTION - YOU SHOULD NOT NEED TO EDIT ANYTHING BELOW #&lt;br /&gt;
 ################################################################################&lt;br /&gt;
&lt;br /&gt;
 # Initializes the source arguments&lt;br /&gt;
 sarg_init() {&lt;br /&gt;
    sarg_init_success=&lt;br /&gt;
    if [ -n &amp;quot;$source_args&amp;quot; ] ; then&lt;br /&gt;
       for arg in `echo $source_args | sed &amp;#039;s/,/ /g&amp;#039;` ; do&lt;br /&gt;
          eval $arg&lt;br /&gt;
          sarg_init_success=1&lt;br /&gt;
       done&lt;br /&gt;
       source_url=`echo $source_url | awk -F, &amp;#039;{print $1}&amp;#039;`&lt;br /&gt;
    fi&lt;br /&gt;
    source_args=&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 # Runs all source argument subroutines. If you add your own&lt;br /&gt;
 # checks/processing add them to this function.&lt;br /&gt;
 sarg_process() {&lt;br /&gt;
    # Check for fetch interval restriction&lt;br /&gt;
    if [ -n &amp;quot;$fetch_interval&amp;quot; ] &amp;amp;&amp;amp; ! sarg_check_fetch_interval ; then&lt;br /&gt;
       echo&lt;br /&gt;
       echo Skipped due to interval restriction in effect&lt;br /&gt;
       continue&lt;br /&gt;
    fi&lt;br /&gt;
    # Insert your own argument processing here&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 # Handles processing of the &amp;quot;$fetch_interval&amp;quot; source argument&lt;br /&gt;
 # Returns 0 when fetching is permitted ( i.e. elapsed seconds&lt;br /&gt;
 # since last fetch is equal or greater than $fetch_interval )&lt;br /&gt;
 # respectively returns 1 when fetching is not permitted.&lt;br /&gt;
 sarg_check_fetch_interval() {&lt;br /&gt;
    local fetch_lastrun fetch_rundiff fetch_stampfile fetch_thisrun&lt;br /&gt;
    fetch_stampfile=$backup_dir/FETCHSTAMP.$source_file&lt;br /&gt;
    fetch_thisrun=`date +%s`&lt;br /&gt;
&lt;br /&gt;
    fetch_stampfile_old=$backup_dir/LASTRUN.$source_file&lt;br /&gt;
    if [ -f $fetch_stampfile_old ] ; then&lt;br /&gt;
       mv $fetch_stampfile_old $fetch_stampfile&lt;br /&gt;
    fi&lt;br /&gt;
&lt;br /&gt;
    if [ -f $fetch_stampfile ] ; then&lt;br /&gt;
       fetch_lastrun=`cat $fetch_stampfile`&lt;br /&gt;
       fetch_rundiff=$(($fetch_thisrun - $fetch_lastrun))&lt;br /&gt;
       if [ $fetch_rundiff -lt $fetch_interval ] ; then&lt;br /&gt;
          fetch_interval=&lt;br /&gt;
          return 1&lt;br /&gt;
       fi&lt;br /&gt;
    fi&lt;br /&gt;
    echo $fetch_thisrun &amp;gt; $fetch_stampfile&lt;br /&gt;
    fetch_interval=&lt;br /&gt;
    return 0&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 # Shows the source header&lt;br /&gt;
 # (the below function also calls the source argument&lt;br /&gt;
 # init and processing functions)&lt;br /&gt;
 show_source_header() {&lt;br /&gt;
    sarg_init&lt;br /&gt;
    echo&lt;br /&gt;
    echo ====================================================&lt;br /&gt;
    echo Processing signature database: $target_file&lt;br /&gt;
    echo ====================================================&lt;br /&gt;
    # Process arguments if any are set for this source&lt;br /&gt;
    [ -n &amp;quot;$sarg_init_success&amp;quot; ] &amp;amp;&amp;amp; sarg_process&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 #### actual script execution begins here ####&lt;br /&gt;
 if [ -n &amp;quot;$script_not_configured&amp;quot; ] ; then&lt;br /&gt;
    echo &amp;#039;*** SCRIPT NOT CONFIGURED ***&amp;#039;&lt;br /&gt;
    echo Please take the time to configure this script before running it.&lt;br /&gt;
    echo When you have, comment out the \&amp;#039;script_not_configured=1\&amp;#039; line at&lt;br /&gt;
    echo the top in the user editables section and execute the script again&lt;br /&gt;
    exit 1&lt;br /&gt;
 fi&lt;br /&gt;
 echo &amp;quot;Script started: &amp;quot;`date`&lt;br /&gt;
&lt;br /&gt;
 # Check to see if the working directories exist.&lt;br /&gt;
 # If not, create them. Otherwise, ignore and proceed with script&lt;br /&gt;
 mkdir -p $tmp_dir $rsync_dir $backup_dir&lt;br /&gt;
&lt;br /&gt;
 # Change working directory to ClamAV database directory&lt;br /&gt;
 cd $clamd_dbdir&lt;br /&gt;
&lt;br /&gt;
 # Get the timestamp from the previous run if it exists and&lt;br /&gt;
 # update it.&lt;br /&gt;
 stamp_lastrun=0&lt;br /&gt;
 stamp_thisrun=`date +%s`&lt;br /&gt;
 if [ -f $backup_dir/LASTRUN ] ; then&lt;br /&gt;
    stamp_lastrun=`cat $backup_dir/LASTRUN`&lt;br /&gt;
 fi&lt;br /&gt;
 echo $stamp_thisrun &amp;gt; $backup_dir/LASTRUN&lt;br /&gt;
&lt;br /&gt;
 # To &amp;quot;play nice&amp;quot; with the source servers don&amp;#039;t run more frequently&lt;br /&gt;
 # than once every hour. Also, attempt to keep off any peak crontimes&lt;br /&gt;
 # by adding a randomized (between 30 seconds and 10 minutes) sleep period.&lt;br /&gt;
 #  --- Idea inspired by Rick Cooper&amp;#039;s &amp;quot;UpdateSaneSecurity&amp;quot; script.&lt;br /&gt;
 # ( You can ofcourse disable the sleep-feature by commenting out the&lt;br /&gt;
 # &amp;#039;sleep_enabled=1&amp;#039; line in the user editables section here above )&lt;br /&gt;
 if [ -n &amp;quot;$sleep_enabled&amp;quot; ] ; then&lt;br /&gt;
    # Calculate if we have run in the last hour. If we have add the&lt;br /&gt;
    # remainder to the sleep time&lt;br /&gt;
    sleep_forced=0&lt;br /&gt;
    if [ $stamp_lastrun -gt 0 ] ; then&lt;br /&gt;
       stamp_rundiff=$(($stamp_thisrun - $stamp_lastrun))&lt;br /&gt;
       if [ $stamp_rundiff -lt 3600 ] ; then&lt;br /&gt;
          sleep_forced=$((3600 - $stamp_rundiff))&lt;br /&gt;
       fi&lt;br /&gt;
    fi&lt;br /&gt;
&lt;br /&gt;
    # NOTE:&lt;br /&gt;
    # Please note that I&amp;#039;m very well aware of the $RANDOM variable, however&lt;br /&gt;
    # since it is not a FreeBSD sh(1) native variable (which is the O/S and&lt;br /&gt;
    # shell I&amp;#039;m running this script under) I&amp;#039;m staying off that path. Feel&lt;br /&gt;
    # free to implement and use the $RANDOM method, if you want to :-)&lt;br /&gt;
&lt;br /&gt;
    # Get a random number between 30 and 600. First attempt this by using&lt;br /&gt;
    # the jot(1) utility (installed by default on *BSD systems)...&lt;br /&gt;
    sleep_random=`jot -r 1 30 600 2&amp;gt;/dev/null`&lt;br /&gt;
&lt;br /&gt;
    # ...if jot(1) failed attempt another (more portable?) method&lt;br /&gt;
    if [ -z &amp;quot;$sleep_random&amp;quot; ] ; then&lt;br /&gt;
       sleep_random=0&lt;br /&gt;
       while [ $sleep_random -lt 30 ] || [ $sleep_random -gt 600 ] ; do&lt;br /&gt;
          sleep_random=`head -1 /dev/urandom | od -N 1 | awk &amp;#039;$2~/^0/{ print $2 / 1 }&amp;#039;`&lt;br /&gt;
       done&lt;br /&gt;
    fi&lt;br /&gt;
&lt;br /&gt;
    # Add the two values together and sleep for that amount of seconds.&lt;br /&gt;
    # If the $TERM variable isn&amp;#039;t set we&amp;#039;re probably running from cron so&lt;br /&gt;
    # disable visual sleeping in that case&lt;br /&gt;
    sleep_forced=$(($sleep_forced + $sleep_random))&lt;br /&gt;
    echo ====================================================&lt;br /&gt;
    echo Sleeping $sleep_forced seconds before proceeding...&lt;br /&gt;
    echo ====================================================&lt;br /&gt;
    if [ -n &amp;quot;$TERM&amp;quot; -a -n &amp;quot;$sleep_visual&amp;quot; ] ; then&lt;br /&gt;
       while [ $sleep_forced -gt 0 ] ; do&lt;br /&gt;
          sleep_forced=$(($sleep_forced - 1))&lt;br /&gt;
          echo -n .&lt;br /&gt;
          sleep 1&lt;br /&gt;
       done&lt;br /&gt;
       echo&lt;br /&gt;
    else&lt;br /&gt;
       sleep $sleep_forced&lt;br /&gt;
    fi&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
 # Process http://urls&lt;br /&gt;
 for source_url in $http_source_urls ; do&lt;br /&gt;
    source_file=`basename $source_url | awk -F, &amp;#039;{print $1}&amp;#039;`&lt;br /&gt;
    source_args=`basename $source_url | sed &amp;quot;s/^\$source_file//;s/^,//&amp;quot;`&lt;br /&gt;
    target_file=`echo $source_file | sed &amp;#039;s/\.gz$//&amp;#039;`&lt;br /&gt;
&lt;br /&gt;
    # If the source and target filenames are equal the source is not gzipped&lt;br /&gt;
    # (this will have to be expanded upon if/when additional forms of source&lt;br /&gt;
    # compression are to be supported).&lt;br /&gt;
    source_not_gzipped=&lt;br /&gt;
    if [ $source_file = $target_file ] ; then&lt;br /&gt;
       source_not_gzipped=1&lt;br /&gt;
    fi&lt;br /&gt;
&lt;br /&gt;
    # Remove any non-word characters from the source filename.&lt;br /&gt;
    # We need this since it&amp;#039;s used in various file operations&lt;br /&gt;
    source_file=`echo $source_file | sed &amp;#039;s/[^[:alnum:]\.-]/_/g&amp;#039;`&lt;br /&gt;
&lt;br /&gt;
    # Produce the source header&lt;br /&gt;
    show_source_header&lt;br /&gt;
&lt;br /&gt;
    # Check for an existing database file. If it exists then run an&lt;br /&gt;
    # update check. Otherwise, just download and extract the database file.&lt;br /&gt;
    if [ ! -s $target_file ] ; then&lt;br /&gt;
       # Redirect stderr to stdout while downloading the file.&lt;br /&gt;
       ( curl -L -R -o $tmp_dir/$source_file $source_url 2&amp;gt;&amp;amp;1 )&lt;br /&gt;
&lt;br /&gt;
       # If the source isn&amp;#039;t gzipped, compress it if $keep_sources_gzipped&lt;br /&gt;
       # is non-empty&lt;br /&gt;
       if [ -n &amp;quot;$keep_sources_gzipped&amp;quot; -a -n &amp;quot;$source_not_gzipped&amp;quot; ] ; then&lt;br /&gt;
          test -s $tmp_dir/$source_file &amp;amp;&amp;amp; \&lt;br /&gt;
             gzip -9f $tmp_dir/$source_file &amp;amp;&amp;amp; \&lt;br /&gt;
             source_file=${source_file}.gz&lt;br /&gt;
       fi&lt;br /&gt;
&lt;br /&gt;
       # Validate the source file through a series of tests.&lt;br /&gt;
       # If all tests succeed install the source and database files&lt;br /&gt;
       # in the ClamAV database directory ($clamd_dbdir).&lt;br /&gt;
       test -s $tmp_dir/$source_file &amp;amp;&amp;amp; \&lt;br /&gt;
          gunzip -cdf $tmp_dir/$source_file &amp;gt; $tmp_dir/$target_file &amp;amp;&amp;amp; \&lt;br /&gt;
          clamscan --quiet -d $tmp_dir/$target_file - &amp;lt; /dev/null &amp;amp;&amp;amp; \&lt;br /&gt;
          mv -f $tmp_dir/$target_file $tmp_dir/$source_file . &amp;amp;&amp;amp; \&lt;br /&gt;
          do_clamd_reload=$(($do_clamd_reload + 1))&lt;br /&gt;
    else&lt;br /&gt;
       # Select which file to use as a timestamp reference.&lt;br /&gt;
       source_timeref=$source_file&lt;br /&gt;
       if [ -n &amp;quot;$keep_sources_gzipped&amp;quot; -a -f ${source_file}.gz ] || \&lt;br /&gt;
          [ ! -f $source_file -a -f ${source_file}.gz ] ; then&lt;br /&gt;
          source_timeref=${source_file}.gz&lt;br /&gt;
       fi&lt;br /&gt;
&lt;br /&gt;
       # Redirect stderr to stdout while downloading the source file, tell curl&lt;br /&gt;
       # to use $source_timeref as a timestamp reference&lt;br /&gt;
       ( curl -L -R -z $source_timeref -o $tmp_dir/$source_file $source_url 2&amp;gt;&amp;amp;1 )&lt;br /&gt;
&lt;br /&gt;
       # If the source isn&amp;#039;t gzipped...&lt;br /&gt;
       if [ -n &amp;quot;$keep_sources_gzipped&amp;quot; -a -n &amp;quot;$source_not_gzipped&amp;quot; ] ; then&lt;br /&gt;
          test -s $tmp_dir/$source_file &amp;amp;&amp;amp; \&lt;br /&gt;
             gzip -9f $tmp_dir/$source_file &amp;amp;&amp;amp; \&lt;br /&gt;
             source_file=${source_file}.gz&lt;br /&gt;
       fi&lt;br /&gt;
&lt;br /&gt;
       # Validate the source file...&lt;br /&gt;
       test -s $tmp_dir/$source_file &amp;amp;&amp;amp; \&lt;br /&gt;
          gunzip -cdf $tmp_dir/$source_file &amp;gt; $tmp_dir/$target_file &amp;amp;&amp;amp; \&lt;br /&gt;
          clamscan --quiet -d $tmp_dir/$target_file - &amp;lt; /dev/null &amp;amp;&amp;amp; \&lt;br /&gt;
          cp -f -p $target_file $backup_dir &amp;amp;&amp;amp; \&lt;br /&gt;
          mv -f $tmp_dir/$target_file $tmp_dir/$source_file . &amp;amp;&amp;amp; \&lt;br /&gt;
          do_clamd_reload=$(($do_clamd_reload + 1))&lt;br /&gt;
    fi&lt;br /&gt;
 done&lt;br /&gt;
&lt;br /&gt;
 # Process rsync://urls&lt;br /&gt;
 for source_url in $rsync_source_urls ; do&lt;br /&gt;
    source_file=`basename $source_url | awk -F, &amp;#039;{print $1}&amp;#039;`&lt;br /&gt;
    source_args=`basename $source_url | sed &amp;quot;s/^\$source_file//;s/^,//&amp;quot;`&lt;br /&gt;
    target_file=$source_file&lt;br /&gt;
&lt;br /&gt;
    # Produce the source header&lt;br /&gt;
    show_source_header&lt;br /&gt;
&lt;br /&gt;
    # Check for an existing database file. If it exists then run an&lt;br /&gt;
    # update check. Otherwise, just download and extract the database file.&lt;br /&gt;
    if [ ! -s $target_file ] ; then&lt;br /&gt;
       # Redirect stderr to stdout while downloading the file.&lt;br /&gt;
       ( rsync -t --stats $source_url $rsync_dir/$target_file 2&amp;gt;&amp;amp;1 )&lt;br /&gt;
&lt;br /&gt;
       # Validate the source file through a series of tests.&lt;br /&gt;
       # If all tests succeed install the source and database files&lt;br /&gt;
       # in the ClamAV database directory ($clamd_dbdir).&lt;br /&gt;
       cp -p $rsync_dir/$target_file $tmp_dir &amp;amp;&amp;amp; \&lt;br /&gt;
       test -s $tmp_dir/$target_file &amp;amp;&amp;amp; \&lt;br /&gt;
          clamscan --quiet -d $tmp_dir/$target_file - &amp;lt; /dev/null &amp;amp;&amp;amp; \&lt;br /&gt;
          mv -f $tmp_dir/$target_file . &amp;amp;&amp;amp; \&lt;br /&gt;
          do_clamd_reload=$(($do_clamd_reload + 1))&lt;br /&gt;
    else&lt;br /&gt;
       # Download the source file...&lt;br /&gt;
       ( rsync -tu --stats $source_url $rsync_dir/$target_file 2&amp;gt;&amp;amp;1 )&lt;br /&gt;
&lt;br /&gt;
       # Validate the source file...&lt;br /&gt;
       test $rsync_dir/$target_file -nt $target_file &amp;amp;&amp;amp; \&lt;br /&gt;
          cp -p $rsync_dir/$target_file $tmp_dir &amp;amp;&amp;amp; \&lt;br /&gt;
          test -s $tmp_dir/$target_file &amp;amp;&amp;amp; \&lt;br /&gt;
             clamscan --quiet -d $tmp_dir/$target_file - &amp;lt; /dev/null &amp;amp;&amp;amp; \&lt;br /&gt;
             cp -f -p $target_file $backup_dir &amp;amp;&amp;amp; \&lt;br /&gt;
             mv -f $tmp_dir/$target_file . &amp;amp;&amp;amp; \&lt;br /&gt;
             do_clamd_reload=$(($do_clamd_reload + 1))&lt;br /&gt;
    fi&lt;br /&gt;
 done&lt;br /&gt;
&lt;br /&gt;
 # Set appropriate file access permissions&lt;br /&gt;
 chown -R $clamd_user:$clamd_group $clamd_dbdir&lt;br /&gt;
&lt;br /&gt;
 # Remove any leftover files in the $tmp_dir working directory&lt;br /&gt;
 # (should only happen when a corrupted database is detected)&lt;br /&gt;
 rm -f $tmp_dir/*&lt;br /&gt;
&lt;br /&gt;
 # Reload the clamd database if $clamd_pidfile and $do_clamd_reload&lt;br /&gt;
 # are both non-empty&lt;br /&gt;
 if [ -n &amp;quot;$clamd_pidfile&amp;quot; -a -n &amp;quot;$do_clamd_reload&amp;quot; ] ; then&lt;br /&gt;
    echo&lt;br /&gt;
    echo ====================================================&lt;br /&gt;
    echo Reloading the ClamAV databases \($do_clamd_reload updated\)&lt;br /&gt;
    echo ====================================================&lt;br /&gt;
    kill -USR2 `cat $clamd_pidfile`&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
 echo&lt;br /&gt;
 echo &amp;quot;Script ended: &amp;quot;`date`&lt;br /&gt;
&lt;br /&gt;
 exit $?&lt;/div&gt;</summary>
		<author><name>Clandmeter</name></author>
	</entry>
</feed>