#!/bin/ash
#
#
#
 export LD_LIBRARY_PATH=/var/clamav/libs
 if [ ! -e /usr/bin/clamscan ]; then
   if [ -e /tmp/clamav-update.tmp ]; then
     rm /tmp/clamav-update.tmp
     ANSWER=y
     else
     read -p "Do you wish to download and install Clam AntiVirus (y/n)?: " ANSWER
   fi
   ANSWER=Y$ANSWER
   if [ $ANSWER = Yy ]; then
     URL=https://www.dropbox.com/s/r4q9lnck1j6ddd0/
     FILE=clamav64.tar.xz
     rm -f /tmp/$FILE 2>/dev/null
     echo "Downloading Clam AntiVirus:"
     curl --connect-timeout 5 -#Lk $URL$FILE > /tmp/$FILE
     file /tmp/$FILE | grep XZ > /tmp/$FILE.tmp
     if [ ! -s /tmp/$FILE.tmp ]; then
       rm /tmp/$FILE
       rm /tmp/$FILE.tmp
       URL=http://dl.4mlinux.com/
       FILE=clamav64.tar.xz
       /usr/share/busybox/wget -c $URL$FILE -P /tmp
     fi
     if [ ! -e /tmp/$FILE ]; then
       echo "Error in downloading. Check your internet connection."
       if [ -e /tmp/.X0-lock ]; then
         echo "You can close this window now."
       fi
       else
       rm /tmp/$FILE.tmp 2>/dev/null
       mv /tmp/$FILE /tmp/addon_clamav.tar.xz
       zk.sh /tmp/addon_clamav.tar.xz
       rm -f /tmp/addon_clamav.tar.xz
       exec antivir
     fi
     else
     echo "Bye!"
   fi
   else
   ln -sf /var/clamav/freshclam.conf /etc/freshclam.conf
   if [ ! -s /var/clamav/main.cvd ]; then
     if [ ! -s /var/clamav/main.cld ]; then
       rm -f main.cvd
       echo "Downloading main.cvd"
       curl --connect-timeout 5 -#Lk https://www.dropbox.com/s/j2nuq2c28ywbr2r/main.cvd > main.cvd
       mv main.cvd /var/clamav
     fi
   fi
   if [ ! -s /var/clamav/daily.cvd ]; then
     if [ ! -s /var/clamav/daily.cld ]; then
       rm -f daily.cvd
       echo "Downloading daily.cvd"
       curl --connect-timeout 5 -#Lk https://www.dropbox.com/s/jk2mecfpe4b0fgc/daily.cvd > daily.cvd
       mv daily.cvd /var/clamav
     fi
   fi
   if [ ! -s /var/clamav/bytecode.cvd ]; then
     if [ ! -s /var/clamav/bytecode.cld ]; then
       rm -f bytecode.cvd
       echo "Downloading bytecode.cvd"
       curl --connect-timeout 5 -#Lk https://www.dropbox.com/s/05wf5dk5yxko44r/bytecode.cvd > bytecode.cvd
       mv bytecode.cvd /var/clamav
     fi
   fi
   sleep 1
   clear
   echo "What would you like to do now?"
   echo "1) Scan your computer against viruses."
   echo "2) Update virus signature databases."
   echo "3) Update your ClamAV software."
   echo "4) Quit."
   read -p "Your choice (1,2,3,4)?: " CHOICE
   CHOICE=x$CHOICE
   if [ $CHOICE = x4 ]; then
     echo Bye!
     exit
   fi
   if [ $CHOICE = x3 ]; then
     rm /usr/bin/clamscan
     touch /tmp/clamav-update.tmp
     exec antivir
   fi
   if [ $CHOICE = x2 ]; then
     freshclam --user=$USER
     sleep 2
     exec antivir
   fi
   clear
   echo "What should I do with suspicious files?"
   echo "1) Nothing. Just show a summary screen."
   echo "2) Nothing. Just create a log file."
   echo "3) Move them to quaratine."
   echo "4) Permanently delete them."
   read -p "Your choice (1,2,3,4)?: " CHOICE
   echo ""
   CHOICE=x$CHOICE
   if [ $CHOICE = x4 ]; then
     OPT="-r --remove=yes"
     MESSAGE="Suspicious files will be permanently removed."
     else
     if [ $CHOICE = x3 ]; then
       OPT="-r --move=/var/clamav/quarantine"
       MESSAGE="Suspicious files will be moved to /var/clamav/quarantine."
       else
       if [ $CHOICE = x2 ]; then
         OPT="-r --log=/var/log/clamav.log"
         MESSAGE="Log file: /var/log/clamav.log."
         else
         OPT="-r"
         MESSAGE=""
       fi
     fi
   fi
   clear
   echo $MESSAGE
   echo "Preparing to scan all files, please wait..."
   sleep 2
   clamscan $OPT /
 fi
