| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- #!@l_prefix@/lib/openpkg/bash @l_prefix@/etc/rc
- ##
- ## rc.uvscan -- Run-Commands
- ##
- %config
- uvscan_enable="$openpkg_rc_def"
- uvscan_dat="ftp://ftp.nai.com/pub/antivirus/datfiles/4.x/"
- uvscan_update="daily"
- %common
- uvscan_update () {
- # determine information
- uvscan_datadir="@l_prefix@/var/uvscan/data"
- uvscan_datfile=`@l_prefix@/bin/curl -s "$uvscan_dat" 2>/dev/null |\
- grep 'dat-[0-9][0-9]*\.tar' | sort | tail -1 |\
- sed -e 's;^.*\(dat-[0-9][0-9]*\.tar\).*$;\1;'`
- uvscan_tmpdir=`echo "${uvscan_datfile}" | sed -e 's;\.tar$;;'`
- # determine old (installed) and new (available) versions
- uvscan_version_new=`echo "${uvscan_datfile}" | sed -e 's;^dat-;;' -e 's;\.tar$;;'`
- uvscan_version_old=`(cat "${uvscan_datadir}/VERSION") 2>/dev/null`
- if [ ".${uvscan_version_new}" = ".${uvscan_version_old}" ]; then
- # still no need for updating
- return 0
- fi
- # download and unpack latest DATs
- umask 077
- cd ${uvscan_datadir} || return 1
- rm -f ${uvscan_datfile} >/dev/null 2>&1 || true
- @l_prefix@/bin/curl -s -o ${uvscan_datfile} \
- ${uvscan_dat}/${uvscan_datfile} || return 1
- rm -rf ${uvscan_tmpdir} >/dev/null 2>&1 || true
- mkdir ${uvscan_tmpdir}
- ( cd ${uvscan_tmpdir} && \
- @l_prefix@/bin/tar -xf ../${uvscan_datfile}
- ) || return 1
- # update DAT repository by installing updated DAT files
- @l_prefix@/lib/openpkg/shtool install -m 644 -o @l_musr@ -g @l_mgrp@ \
- ${uvscan_tmpdir}/*.dat .
- echo "${uvscan_version_new}" >VERSION
- # cleanup
- rm -f ${uvscan_datfile} >/dev/null 2>&1 || true
- rm -rf ${uvscan_tmpdir} >/dev/null 2>&1 || true
- }
- %quarterly -u @l_musr@
- rcService uvscan enable yes || exit 0
- if [ ".$uvscan_update" = .quarterly ]; then
- uvscan_update || exit $?
- fi
- %hourly -u @l_musr@
- rcService uvscan enable yes || exit 0
- if [ ".$uvscan_update" = .hourly ]; then
- uvscan_update || exit $?
- fi
- %daily -u @l_musr@
- rcService uvscan enable yes || exit 0
- if [ ".$uvscan_update" = .daily ]; then
- uvscan_update || exit $?
- fi
- %weekly -u @l_musr@
- rcService uvscan enable yes || exit 0
- if [ ".$uvscan_update" = .weekly ]; then
- uvscan_update || exit $?
- fi
|