Novell Home

Using Linux box with BASH script to Update NetWare Virus Signatures

Novell Cool Solutions: Trench
By Sylvain Lavoie

Digg This - Slashdot This

Posted: 28 Jan 2004
 

I'm using a Linux box that is running a BASH script to update all my NetWare servers' virus signatures. The Bash script unloads and reloads the antivirus using the command

"nwfsctrl -S SERVERIP COMMAND MODULE".

Here's the script. Of course, it will have to be adapted to the environment where it will be used and it's a work in progress so some portions could be a little rough. But it does work well for us! I think what the reader will benefit from the most are the techniques/commands I used to get it to work properly. There is almost no documentation in the script, but I'm willing to answer the questions that some will have.

IMHO, Linux is just the perfect "tool" to manage your network and servers!

Script

#!/bin/sh

# Global Variables:
CkOK="\033[0m[\033[0;1;32mOK\033[0m]"
CkFail="\033[0m[\033[0;1;31mFAILED\033[0m]"
CkNO="\033[0m[\033[0;1;31mNO\033[0m]"
CkYES="\033[0m[\033[0;1;32mYES\033[0m]"
ErrHead="\n\033[0;1;31m- E R R O R ! - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - -\033[0m\a"
ErrTail="\033[0;1;31m- - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - -\033[0m"
SolHead="\n\033[0;1;32m- S O L U T I O N : - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - -\033[0m"
SolTail="\033[0;1;32m- - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - -\033[0m"
WarnHead="\n\033[0;1;33m- W A R N N I N G ! - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - -\033[0m"
WarnTail="\033[0;1;33m- - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - -\033[0m"

# Main Script:
clear
echo "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * *"
echo "* * * * *  McAfee and InocuLAN VIRUS SIGNATURE FILES Update
Script.   * * * * *"
echo "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * *"
echo -e "\nProceeding in 10 seconds...  (Hit CTRL+C to abort)\n\n"
sleep 10
echo -en "Checking for NCP utilities...\t\t\t\t\t"
if [ -e /usr/bin/ncpmount ] && [ -e /usr/bin/ncpumount ] && [ -e
/usr/bin/nwfsctrl ]; then
  if [ -u /usr/bin/ncpmount ] && [ -u /usr/bin/ncpumount ]; then
    echo -e $CkOK;
  else
    echo -e $CkFail
    echo -e $ErrHead
    echo "The /usr/bin/ncpmount OR the /usr/bin/ncpumount file does not
have the"
    echo "'Set User ID On Execution'."
    echo -e $ErrTail
    echo -e $SolHead
    echo "Use the command 'chmod +s /usr/bin/ncpmount' or 'chmod +s
/usr/bin/ncpumount'"
    echo "as root to activate the 'Set User ID On Execution'."
    echo -e $SolTail
    exit;
  fi
else
  echo -e $CkFail
  echo -e $ErrHead
  echo "The NCPFS utilities are either not installed on this system and
have not been"
  echo "found in the /usr/bin directory."
  echo -e $ErrTail
  echo -e $SolHead
  echo "Use the command 'rpm -ivh ncpfs-2.2.x.rpm' as root to install
the RPM package."
  echo -e $SolTail
  exit;
fi
echo -en "Checking for NDS/Bindery login information...\t\t\t"
if [ -e ~/.nwclient ]; then
  echo -e $CkOK
  echo -en "Checking if IPX interface is up...\t\t\t\t"
  if /sbin/ifconfig | grep -i -q ipx; then
    echo -e $CkYES
    IPXUp=1
  else
    echo -e $CkNO
    IPXUp=0
    echo -e $WarnHead
    echo "The IPX protocol has not been configured on this workstation."
    echo "IPX is needed to connect to the NetWare 3.x servers."
    echo "NetWare 3.x servers WON'T be updated with new virus
signatures."
    echo -e $WarnTail
    echo -e $SolHead
    echo "Use the command 'ipx_configure --auto_primary=on
--auto_interface=on' as"
    echo "root to configure IPX."
    echo -e $SolTail
    echo
  fi
  echo -en "Creating ~/Network mounting structure if needed...\t\t"
  if ! [ -d ~/Network ]; then
    mkdir ~/Network
  fi
  if ! [ -d ~/Network/NWSERVER1 ]; then
    mkdir ~/Network/NWSERVER1
  fi
  if ! [ -d ~/Network/NWSERVER2 ]; then
    mkdir ~/Network/NWSERVER2
  fi
  if ! [ -d ~/Network/NWSERVER3 ]; then
    mkdir ~/Network/NWSERVER3
  fi
  if ! [ -d ~/Network/NWSERVER4 ]; then
    mkdir ~/Network/NWSERVER4
  fi
  if ! [ -d ~/Network/NWSERVER5 ]; then
    mkdir ~/Network/NWSERVER5
  fi
  echo -e $CkOK
  echo -en "Mounting NetWare Volumes in ~/Network...\t\t\t"
  if [ -d ~/Network/NWSERVER1/Volume1 ]; then
    UMFlagMain=1
  else
    ncpmount -A 1.2.3.4 -S NWSERVER1 ~/Network/NWSERVER1
    UMFlagMain=0
  fi
  if [ -d ~/Network/NWSERVER2/mail ]; then
    UMFlagMail=1
  else
    ncpmount -A 1.2.3.5 -S NWSERVER2 ~/Network/NWSERVER2
    UMFlagMail=0
  fi
  if [ -d ~/Network/NWSERVER3/Volume2 ]; then
    UMFlagIS=1
  else
    ncpmount -A 1.2.3.6 -S NWSERVER3 ~/Network/NWSERVER3
    UMFlagIS=0
  fi
  if [ -d ~/Network/NWSERVER4/apps ]; then
    UMFlag3M=1
  else
    ncpmount -A 1.2.3.7 -S NWSERVER4 ~/Network/NWSERVER4
    UMFlag3M=0
  fi
  if [ $IPXUp -eq 1 ]; then
    if [ -d ~/Network/NWSERVER5/sys ]; then
      UMFlagMW=1
    else
      ncpmount -S NWSERVER5 ~/Network/NWSERVER5
      UMFlagMW=0
    fi
  fi
  echo -e $CkOK
  echo "VirSIGUp" > ~/MailMessage.txt
  echo -en "Creating the temporary directory VSIGTemp ...\t\t\t"
  mkdir ~/VSIGTemp 2> /dev/null
  if [ -d ~/VSIGTemp ]; then
    echo -e $CkOK
    cd ~/VSIGTemp
    echo -en "Checking if virus signatures needs to be updated...\t\t"
    wget -N -q -t 5 ftp://ftp.nai.com/virusdefs/4.x/*xdat.exe 
    if [ ~/VSIGTemp/????xdat.exe -nt
~/Network/NWSERVER1/Volume1/ZENDistApps/VirusScanSignatureFiles/????xdat.exe
]; then
      echo -e $CkYES
      echo -en "Downloading NEW virus signature files to
VSIGTemp...\t\t"
      wget -N -q -t 5 ftp://ftpav.ca.com/pub/InocuLAN/il0080.zip 
      wget -N -q -t 5 ftp://ftpav.ca.com/pub/InocuLAN/il0082.zip 
      wget -N -q -t 5 ftp://ftp.nai.com/virusdefs/4.x/* 
      echo -e $CkOK
      if [ -e ~/VSIGTemp/il0082.zip ]; then
        echo -en "Updating Cheyenne distribution directories
(Windows)...\t\t"
        rm
~/Network/NWSERVER3/Volume2/Software/Cheyenne/VirusSignatures/*
        unzip -q il0082.zip -d
~/Network/NWSERVER3/Volume2/Software/Cheyenne/VirusSignatures
        echo -e $CkOK
      fi
      if [ -e ~/VSIGTemp/il0080.zip ]; then
        echo -en "Extracting InocuLAN signature files for
NetWare...\t\t"
        mkdir ~/VSIGTemp/CAV
        unzip -q il0080.zip -d ~/VSIGTemp/CAV
        echo -e $CkOK
      fi
      if [ -e ~/VSIGTemp/sdat*.exe ] && [ -e ~/VSIGTemp/*xdat.exe ] && [
-e ~/VSIGTemp/dat-*.zip ]; then
        echo -en "Updating VirusScan distribution directories
(Windows)...\t\t"
        rm
~/Network/NWSERVER3/Volume2/Software/NetworkAssociates/VirusSignatures/*
        cp --preserve=timestamps sdat*.exe
~/Network/NWSERVER3/Volume2/Software/NetworkAssociates/VirusSignatures
        cp --preserve=timestamps *xdat.exe
~/Network/NWSERVER3/Volume2/Software/NetworkAssociates/VirusSignatures
        rm
~/Network/NWSERVER1/Volume1/ZENDistApps/VirusScanSignatureFiles/*
        cp --preserve=timestamps *.upd
~/Network/NWSERVER1/Volume1/ZENDistApps/VirusScanSignatureFiles
        cp --preserve=timestamps *.exe
~/Network/NWSERVER1/Volume1/ZENDistApps/VirusScanSignatureFiles
        cp --preserve=timestamps *.ini
~/Network/NWSERVER1/Volume1/ZENDistApps/VirusScanSignatureFiles
        cp --preserve=timestamps dat-*.zip
~/Network/NWSERVER1/Volume1/ZENDistApps/VirusScanSignatureFiles
        echo -e $CkOK
      fi
      if [ -e ~/VSIGTemp/dat-*.zip ]; then
        echo -en "Extracting NetShield signatures files for
NetWare...\t\t"
        mkdir ~/VSIGTemp/MAV
        unzip -q dat-*.zip -d ~/VSIGTemp/MAV
        echo -e $CkOK
      fi
      echo -en "Unloading Screen Savers on NetWare 5.x servers...\t\t\t"
      nwfsctrl -S 1.2.3.7 unload scrsaver
      nwfsctrl -S 1.2.3.6 unload scrsaver
      nwfsctrl -S 1.2.3.5 unload scrsaver
      nwfsctrl -S 1.2.3.4 unload scrsaver
      echo -e $CkOK
      echo -en "Unloading NetShield on NetWare 5.x servers...\t\t\t"
      nwfsctrl -S 1.2.3.6 unload netshld
      nwfsctrl -S 1.2.3.5 unload netshld
      nwfsctrl -S 1.2.3.7 unload netshld
      nwfsctrl -S 1.2.3.4 unload netshld
      echo -e $CkOK
      if [ -e ~/VSIGTemp/MAV/clean.dat ] && [ -e
~/VSIGTemp/MAV/internet.dat ] && [ -e ~/VSIGTemp/MAV/names.dat ] && [ -e
~/VSIGTemp/MAV/scan.dat ]; then
        echo -en "Updating NetShield DAT files on the NetWare 5.x
servers...\t\t"
        cp --preserve=timestamps ~/VSIGTemp/MAV/*.dat
~/Network/NWSERVER1/Volume1/MCAFEE/NETSHLD
        cp --preserve=timestamps ~/VSIGTemp/MAV/*.dat
~/Network/NWSERVER3/Volume2/MCAFEE/NETSHLD
        cp --preserve=timestamps ~/VSIGTemp/MAV/*.dat
~/Network/NWSERVER2/mail/MCAFEE/NETSHLD
        cp --preserve=timestamps ~/VSIGTemp/MAV/*.dat
~/Network/NWSERVER4/apps/MCAFEE/NETSHLD
        echo -e $CkOK
      fi
      echo -en "Loading NetShield on NetWare 5.x servers...\t\t\t"
      nwfsctrl -S 1.2.3.4 netshld
      nwfsctrl -S 1.2.3.5 netshld
      nwfsctrl -S 1.2.3.6 netshld
      nwfsctrl -S 1.2.3.7 netshld
      echo -e $CkOK
      echo -en "Loading Screen Savers on NetWare 5.x servers...\t\t\t"
      nwfsctrl -S 1.2.3.7 load scrsaver
      nwfsctrl -S 1.2.3.6 load scrsaver
      nwfsctrl -S 1.2.3.5 load scrsaver
      nwfsctrl -S 1.2.3.4 load scrsaver
      echo -e $CkOK
      if [ $IPXUp -eq 1 ]; then
        echo -e "\nUnload Inoculan MANUALLY on all NetWare 3.x
servers...\t\t\033[4C\033[0m[\033[0;1;31mWAITING\033[0m]"
        echo -en "\a\a"
        sleep 1
        echo -en "\a\a"
        sleep 1
        echo -e "Hit ENTER to proceed...  (Hit CTRL+C to abort)"
        sleep 1
        echo -en "\a\a"
        read cont < /dev/tty
#       nwfsctrl -S NWSERVER5 istop4
        if [ -e ~/VSIGTemp/CAV/AVENGINE.NLM ]; then
          echo -en "Updating Inoculan NLM Engine on the NetWare 3.x
servers...\t"
          cp --preserve=timestamps ~/VSIGTemp/CAV/AVENGINE.NLM
~/Network/NWSERVER5/sys/system
          echo -e $CkOK
          echo -en "Updating Inoculan DAT files on the NetWare 3.x
servers...\t"
          cp --preserve=timestamps ~/VSIGTemp/CAV/*.DAT
~/Network/NWSERVER5/sys/inoculan
          echo -e $CkOK
        fi
#       nwfsctrl -S NWSERVER5 istart4
        echo -e "\n\nLoad InocuLAN MANUALLY on NetWare 3.x servers!\n"
      fi
    else
      echo -e $CkNO
      echo -e "\n\nThe virus signatures files are ALREADY up to date!\n"
    fi
    echo -en "UnMounting NetWare volumes not initialy mounted...\t\t"
    if [ $UMFlagMain -eq 0 ]; then
      ncpumount ~/Network/NWSERVER1
    fi
    if [ $UMFlagMail -eq 0 ]; then
      ncpumount ~/Network/NWSERVER2
    fi
    if [ $UMFlagIS -eq 0 ]; then
      ncpumount ~/Network/NWSERVER3
    fi
    if [ $UMFlag3M -eq 0 ]; then
      ncpumount ~/Network/NWSERVER4
    fi
    if [ $IPXUp -eq 1 ]; then
      if [ $UMFlagMW -eq 0 ]; then
        ncpumount ~/Network/NWSERVER5
      fi
    fi
    echo -e $CkOK;
    cd ~
    echo -en "Deleting files and temp directories...\t\t\t\t"
    if [ -d ~/VSIGTemp/MAV ]; then 
      rm ~/VSIGTemp/MAV/*
      rmdir ~/VSIGTemp/MAV
    fi
    if [ -d ~/VSIGTemp/CAV ]; then
      rm ~/VSIGTemp/CAV/*
      rmdir ~/VSIGTemp/CAV
    fi
    if [ -d ~/VSIGTemp ]; then
      rm ~/VSIGTemp/*
      rmdir ~/VSIGTemp
    fi
    echo -e $CkOK
    echo -en "Notifying SysAdmins...\t\t\t\t\t"
    mail -s "Virus Signature Update Successful" admin@someplace.com <
~/MailMessage.txt 
    if [ -e MailMessage.txt ]; then
      rm MailMessage.txt
    fi
    echo -e $CkOK
    echo;
  else
    echo -e $CkFail
    echo -e $ErrHead
    echo "The Temporary Directory (~/VSIGTemp) could not be created! 
ScriptHalted!"
    echo -e $ErrTail
    echo -e $SolHead
    echo "Check the read/write rights in this user's home directory."
    echo "Also make sure enough disk space is available."
    echo -e $SolTail
  fi
else
  echo -e $CkFail
  echo -e $ErrHead
  echo "The file .nwclient must be located in this user's local home
directory to allow"
  echo "this script to mount the NetWare volumes."
  echo -e $ErrTail
  echo -e $SolHead
  echo "The command 'man nwclient' gives information on how to configure
the .nwclient file."
  echo -e $SolTail
fi

If you have any questions you may contact Sylvain at sylvain.lavoie@chr4.health.nb.ca


Novell Cool Solutions (corporate web communities) are produced by WebWise Solutions. www.webwiseone.com

© 2014 Novell