Good to Know Database

Shell Skript: AVG Update Script


Mit dem folgenden Shell Skript können Sie ein lokales Update-Verzeichnis für AVG Anti-Virus Free 9.0 erstellen und regelmäßig aktualisieren. Damit die Updates regelmäßig aktualisiert werden, sollten Sie einen entsprechenden Cronjob einrichten.

###########################################################################
##                                                                       ##
##                           AVG Update Script                           ##
##                                                                       ##
## Creation:    20.04.2010                                               ##
## Last Update: 20.10.2013                                               ##
##                                                                       ##
## Copyright (c) 2010-2013 by Georg Kainzbauer <http://www.gtkdb.de>     ##
##                                                                       ##
## This program is free software; you can redistribute it and/or modify  ##
## it under the terms of the GNU General Public License as published by  ##
## the Free Software Foundation; either version 2 of the License, or     ##
## (at your option) any later version.                                   ##
##                                                                       ##
###########################################################################
#!/bin/bash

# Update URL for AVG Anti-Virus Free 9.0
UPDATEURL=http://guru.avg.com/softw/90free/update/

# Names of the Update Control Files (CTF)
CTFFILES="avg9infowin.ctf avg9infoavi.ctf"

# Path of local update directory
DOWNLOADDIR=/data/public/AVG/update/

# File name for the download list
DOWNLOADLIST=download.txt

# Log file
LOGFILE=/var/log/avg_update.log

# Lock file
LOCK=/var/tmp/avg_update.lock

###################################################################
# NORMALLY THERE IS NO NEED TO CHANGE ANYTHING BELOW THIS COMMENT #
###################################################################

function log()
  {
    echo `date +%d.%m.%Y%t%H:%M:%S` "    LOG:" $1 >>${LOGFILE}
  }

function error()
  {
    echo `date +%d.%m.%Y%t%H:%M:%S` "    ERROR:" $1 >>${LOGFILE}
    exit 1
  }

if [ -f ${LOCK} ] ; then
  error "Lockfile ${LOCK} exists."
fi

touch ${LOCK}

log "Starting AVG update process"

# Create update directory if not exists
if [ ! -d ${DOWNLOADDIR} ] ; then
  mkdir -p ${DOWNLOADDIR}
fi

# Remove old CTF files if exists
for i in ${CTFFILES} ; do
  if [ -f ${DOWNLOADDIR}${i} ] ; then
    rm -f ${DOWNLOADDIR}${i}
  fi
done

# Download current CTF files
log "Downloading current CTF files"
for i in ${CTFFILES} ; do
  wget -q ${UPDATEURL}${i} -P ${DOWNLOADDIR}
done

# Remove old download list if exists
if [ -f ${DOWNLOADDIR}${DOWNLOADLIST} ] ; then
  rm -f ${DOWNLOADDIR}${DOWNLOADLIST}
fi

# Create download list from CTF files
log "Creating download list"
for i in ${CTFFILES} ; do
  grep ".bin" ${DOWNLOADDIR}${i} | cut -f 1 -d ' ' | cut -b 5- | cut -f 1 -d ')' >> ${DOWNLOADDIR}${DOWNLOADLIST}
done

# Download new BIN files
for i in `cat ${DOWNLOADDIR}${DOWNLOADLIST}` ; do
  if [ ! -f ${DOWNLOADDIR}${i} ] ; then
    log "Downloading ${i}"
    wget -q -c ${UPDATEURL}${i} -P ${DOWNLOADDIR}
  fi
done

# Remove old BIN files
for i in $(find ${DOWNLOADDIR} -name *.bin -exec basename {} \;) ; do
  if [ $(grep ${i} ${DOWNLOADDIR}${DOWNLOADLIST} | wc -l) -eq 0 ] ; then
    log "Removing ${i}"
    rm -f ${DOWNLOADDIR}${i}
  fi
done

# Remove download list
log "Removing download list"
rm -f ${DOWNLOADDIR}${DOWNLOADLIST}

log "AVG update process finished"

rm -f ${LOCK}

exit 0


Dieser Eintrag wurde am 21.04.2010 erstellt und zuletzt am 05.04.2015 bearbeitet.

Direkter Link zu dieser Seite: http://www.gtkdb.de/index_33_938.html

[ Zur Startseite ]   [ Zur Kategorie ]


Valid XHTML 1.0 Transitional Valid CSS Valid Atom 1.0

© 2004-2017 by Georg Kainzbauer