Diff for /badi/public_scripts/awstats_update_all/awstats_update_all between versions 1.3 and 1.4

version 1.3, 2010/08/01 19:33:20 version 1.4, 2010/08/31 01:55:03
Line 6 Line 6
 # for several sites at once. Give the command line argument "-q" to suppress  # for several sites at once. Give the command line argument "-q" to suppress
 # all but error output.  # all but error output.
   
 # (c) 2010 under GPL v2 by Adrian Zaugg.  # (c)2010 under GPL v2 by Adrian Zaugg.
   
   
   # awstats main script
 AWSTATS_BIN="/usr/lib/cgi-bin/awstats.pl"  AWSTATS_BIN="/usr/lib/cgi-bin/awstats.pl"
 CONF_DIR="/etc/awstats"  
   
 # file to exclude  # awstats configuration directory
 CONF_TEMPLATE="awstats.default"  CONF_DIR="/etc/awstats"
   
 # normal awstats config files have this extension  # normal awstats config files have this extension
 CONF_EXT="conf"  CONF_EXT="conf"
   
 # Run with this priority  # File to exclude
   # Exclude this file, which isn't a config file for awstats, but
   # also resides in the config directory. Note: Only
   # files with an extension $CONF_EXT are considered anyway. 
   CONF_TEMPLATE="awstats.default"
   
   # Run with this priority (0: normal - 19: friendly)
 NICENESS=16  NICENESS=16
   
 # maximum awstats update processes to run at once  # Maximum awstats update processes to run at once
 MAX_PROCESSES=8  MAX_PROCESSES=8
   
 # Wait that many seconds when MAX_PROCESSES are COUNT_PROC   # Wait that many seconds when MAX_PROCESSES are running 
 # to retry starting new update processes  # to retry starting new update processes
 RETRY=2  RETRY=2
   
   
   
 # ----don't edit below this line-----  # ----don't edit below this line-----
   
 # default to babbly, -q suppress output  # default to babbly, -q suppress output
Line 38  if [ "$1" = "-q" ]; then Line 45  if [ "$1" = "-q" ]; then
 fi  fi
   
 function count_proc() {  function count_proc() {
         # count how many instances are already COUNT_PROC          # count how many instances are already running
         COUNT_PROC=$(ps -o command -u "$(id -u)" | egrep -cwe '^(/bin/sh|/usr/bin/perl)* *'"$AWSTATS_BIN")          COUNT_PROC=$(ps -o command -u "$(id -u)" | egrep -cwe '^(/bin/sh|/usr/bin/perl)* *'"$AWSTATS_BIN")
 }  }
   
Line 59  CURRENT_DIR="$(pwd)" Line 66  CURRENT_DIR="$(pwd)"
 cd "$CONF_DIR"  cd "$CONF_DIR"
 for conf in *.$CONF_EXT; do  for conf in *.$CONF_EXT; do
   
         notstarted=true          notstarted=true
                   
         # control number uf update processes          # control number uf update processes
         while [ $notstarted = true ]; do          while [ $notstarted = true ]; do
                 count_proc                  count_proc
                 if [ $COUNT_PROC -lt $MAX_PROCESSES ]; then                  if [ $COUNT_PROC -lt $MAX_PROCESSES ]; then
                         # exclude the template file                          # exclude the template file
                         if [ "$conf" != "$CONF_TEMPLATE" ]; then                          if [ "$conf" != "$CONF_TEMPLATE" ]; then
                                 site="$(echo "$conf" | sed -e "s/^awstats\.\(.*\)\.conf$/\1/")"                                  site="$(echo "$conf" | sed -e "s/^awstats\.\(.*\)\.conf$/\1/")"
                                 $SPEAK && echo "`date "+%Y-%m-%d %H:%M:%S"`: Starting update for $site (already running: $COUNT_PROC)."                                  $SPEAK && echo "`date "+%Y-%m-%d %H:%M:%S"`: Starting update for $site (already running: $COUNT_PROC)."
                                 do_update                                  do_update
                         fi                          fi
                         notstarted=false                          notstarted=false
                         let "site_count += 1"                          let "site_count += 1"
                         break;                          break;
                 fi                  fi
   
                 sleep "$RETRY"                  sleep "$RETRY"
         done          done
   
 done  done
 cd "$CURRENT_DIR"  cd "$CURRENT_DIR"
   
   
 # wait for all processes to finish  # wait for all processes to finish
 count_proc  count_proc
 if [ $COUNT_PROC -gt 0 ]; then  if [ $COUNT_PROC -gt 0 ]; then
         $SPEAK && echo "`date "+%Y-%m-%d %H:%M:%S"`: All jobs started - $COUNT_PROC process(es) still runnning. Waiting..."           $SPEAK && echo "`date "+%Y-%m-%d %H:%M:%S"`: All jobs started - $COUNT_PROC process(es) still runnning. Waiting..." 
                   
         # wait for processes to finish          # wait for processes to finish
         while [ $COUNT_PROC -gt 0 ]; do          while [ $COUNT_PROC -gt 0 ]; do
                 sleep "$RETRY"                  sleep "$RETRY"
                 count_proc                  count_proc
         done          done
 fi  fi
   
 $SPEAK && echo "`date "+%Y-%m-%d %H:%M:%S"`: Finished. Statistics for $site_count sites updated."  $SPEAK && echo "`date "+%Y-%m-%d %H:%M:%S"`: Finished. Statistics for $site_count sites updated."

Removed from v.1.3  
changed lines
  Added in v.1.4


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>