I had run into issues getting consistency installing Symantec AV on all of the Linux servers. Because all of ours are SuSE, I wrote this specifically for SuSE, but it should be easy to modify for redhat or other distributions (ex. instead of using yast, use yum).
This script is designed to make antivirus install, removal and kernel module updates quick and easy, while keeping your install on a central server that is easy to get to.
If you use it, let me know if it works well, or you run into issues…
—- here it is—-
#!/bin/bash
#Version *** update if you make a change!!
VER=1.3
#install locations (this uses wget and must have http:// or ftp://)
#RPM PATH
RPMPATH=”ftp://server.fqdn.or.ip/symantec/rpm/*”
#Kernel Mod source Path
KMPATH=”ftp://server.fqdn.or.ip/symantec/ap-kernelmodule-1.0.10-26.tar.gz”
# ******************** verify we are using a root account
if [ $UID != 0 ]
then
echo “You need to run this as root! exiting…”
exit 1;
fi
# ******************* check if this is a 32-bit or 64-bit system
ARCH=`uname -m`
# ****************** Generate a random key
# generate a random key
RANDOM=`date ‘+%s’`
RAND1=$[($RANDOM % 999) + 1]
# **–**–: End of startup variables / starting menus :–**–**
_info () {
dialog –title “Installer $VER Info” –msgbox “Contact <your name here> for updates or questions \n your conatct info here ” 6 50
_main
}
_rmav () {
exec 3>&1
# Stop all AV services
/etc/init.d/autoprotect stop 2>$1 ; dialog –infobox “Stopping autoprotect” 3 45
/etc/init.d/symcfgd stop 2>$1 ; dialog –infobox “Stopping symcfgd” 3 45
/etc/init.d/rtvscand stop 2>$1 ; dialog –infobox “Stopping rtvscand” 3 45
# Remove RPM’s
rpm -ev savui ; dialog –infobox “removing RPMs [savui]” 3 45
rpm -ev savjlu ; dialog –infobox “removing RPMs [savjlu]” 3 45
rpm -ev savap ; dialog –infobox “removing RPMs [savap]” 3 45
rpm -ev sav ; dialog –infobox “removing RPMs [sav]” 3 45
# remove symantec av files
rm -f /etc/init.d/autoprotect ; dialog –infobox “removing files .” 3 45
rm -f /etc/init.d/symcfgd ; dialog –infobox “removing files ..” 3 45
rm -f /etc/init.d/rtvscand ; dialog –infobox “removing files …” 3 45
rm -f /etc/symantec/VPREG*.* ; dialog –infobox “removing files ….” 3 45
rm -f /etc/ld.so.conf.d/symav.conf ; dialog –infobox “removing files …..” 3 45
rm -rf /etc/symantec/NLS ; dialog –infobox “removing files ……” 3 45
rm -rf /opt/Symantec/symantec_antivirus ; dialog –infobox “removing files …….” 3 45
rm -rf /opt/Symantec/autoprotect ; dialog –infobox “removing files ……” 3 45
rm -rf /root/sav*install.log* ; dialog –infobox “removing files . …..” 3 45
rm -f /var/lock/subsys/symcfgd ; dialog –infobox “removing files .. ….” 3 45
rm -f /var/lock/subsys/rtvscand ; dialog –infobox “removing files … …” 3 45
rm -rf /var/symantec/Quarantine ; dialog –infobox “removing files …. ..” 3 45
rm -rf /var/symantec/Logs ; dialog –infobox “removing files ….. .” 3 45
rm -rf /var/tmp/I2_LDVP.TMP ; dialog –infobox “removing files …… ” 3 45
rm -rf /var/symantec ; dialog –infobox “removing files ……” 3 45
rm -f /etc/Symantec.conf ; dialog –infobox “removing files . …..” 3 45
rm -rf /etc/symantec ; dialog –infobox “removing files .. ….” 3 45
rm -rf /opt/Symantec ; dialog –infobox “removing files … …” 3 45
dialog –title “Uninstall Complete” –msgbox “AV removal has completed” 6 50
_main
}
_instav () {
#Get credentials to login and get the files needed
exec 3>&1
UNAME=$(dialog –title “AD Account credentials” –inputbox “Username:” 10 40 2>&1 1>&3)
PASS=$(dialog –title “AD Account Credentials” –insecure –passwordbox “Password:” 10 40 2>&1 1>&3)
# Download the files we need
wget -q -P /tmp/$RAND1 –ftp-user=$UNAME –ftp-password=”$PASS” $RPMPATH ; dialog –infobox “Downloading RPMs” 3 34
wget -q -P /tmp/$RAND1 –ftp-user=$UNAME –ftp-password=”$PASS” $KMPATH ; dialog –infobox “Downloading Kernel patch” 3 34
if [ -d /opt/Symantec/autoprotect ]
then
dialog –infobox “Detected AV a reboot will be needed to apply kernel modules” 3 45
else
mkdir /opt/Symantec
mkdir /opt/Symantec/autoprotect
fi
cd /tmp/$RAND1
tar -zxf ap-kernelmodule-1.0.10-26.tar.gz
cd ap-kernelmodule-1.0.10-26
./build.sh –kernel-dir /lib/modules/$(uname -r)/build > /tmp/$RAND1/mod.log 2>&1 ; dialog –infobox “Building Kernel Modules” 3 34
cd bin.ira
mv ./* /opt/Symantec/autoprotect
#Install the AV RPMs
if [ $ARCH = x86_64 ]; then
cd /tmp/$RAND1
rpm -i sav-*.i386.rpm savap-x64-*.x86_64.rpm savjlu-*.i386.rpm savui-*.i386.rpm ; dialog –infobox “intalling Symantec AV” 3 34
echo “$ARCH”
else
cd /tmp/$RAND1
rpm -i sav-*.i386.rpm savap-*.i386.rpm savjlu-*.i386.rpm savui-*.i386.rpm ; dialog –infobox “intalling Symantec AV” 3 34
echo “$ARCH”
fi
dialog –title “Install Complete” –msgbox “AV and Kernel Modules have been installed” 6 50
rm -R /tmp/$RAND1
_main
}
_upmods () {
#Get credentials to login and get the files needed
exec 3>&1
UNAME=$(dialog –title “AD Account credentials” –inputbox “Username:” 10 40 2>&1 1>&3)
PASS=$(dialog –title “AD Account Credentials” –insecure –passwordbox “Password:” 10 40 2>&1 1>&3)
# Download the files we need
wget -q -P /tmp/$RAND1 –ftp-user=$UNAME –ftp-password=”$PASS” $KMPATH ; dialog –infobox “Downloading Kernel patch” 3 34
if [ -d /opt/Symantec/autoprotect ]
then
dialog –infobox “Detected AV a reboot will be needed to apply kernel modules” 3 45
else
mkdir /opt/Symantec
mkdir /opt/Symantec/autoprotect
fi
cd /tmp/$RAND1
tar -zxf ap-kernelmodule-1.0.10-26.tar.gz
cd ap-kernelmodule-1.0.10-26
./build.sh –kernel-dir /lib/modules/$(uname -r)/build > /tmp/$RAND1/mod.log 2>&1 ; dialog –infobox “Building Kernel Modules” 3 34
cd bin.ira
mv ./* /opt/Symantec/autoprotect
dialog –title “Install Complete” –msgbox “Kernel Modules have been installed \n You will need to reboot for them to ” 6 50
rm -R /tmp/$RAND1
_main
}
_main () {
exec 3>&1
M1=$(dialog –title “Symantec AV installer $VER” \
–menu “Choose from one of the following options:” 15 55 5 \
1 “Install Symantec AV” \
2 “Update Kernel Modules” \
3 “Remove Symantec AV” \
4 “Info” 2>&1 1>&3)
#retv=$?
#[ $retv -eq 1 -o $retv -eq 255 ] && exit
case $M1 in
1) _instav ;;
2) _upmods ;;
3) _rmav ;;
4) _info ;;
esac
}
_gcc () {
GCC=`rpm -qa |grep ^gcc-[0-9] |awk -F “-[0-9]” ‘{print $1}’` ; dialog –infobox “Checking gcc and installing if needed” 3 45
if [ “$GCC” != “gcc” ] ; then
#echo “gcc is not installed”
yast -i gcc
fi
_pkg-test
}
_kernel () {
KSOURCE=`rpm -qa |grep kernel-source |awk -F “-[0-9]” ‘{print $1}’` ; dialog –infobox “Checking kernel source and installing if needed” 3 45
if [ “$KSOURCE” != “kernel-source” ] ; then
# echo “kernel-source is not installed”
yast -i kernel-source
fi
_pkg-test
}
_pkg-test () {
GCC=`rpm -qa |grep ^gcc-[0-9] |awk -F “-[0-9]” ‘{print $1}’` ; dialog –infobox “Checking if gcc is installed” 3 45
if [ “$GCC” != “gcc” ] ; then
_gcc
fi
KSOURCE=`rpm -qa |grep kernel-source |awk -F “-[0-9]” ‘{print $1}’` ; dialog –infobox “Checking if kernel source is installed” 3 45
if [ “$KSOURCE” != “kernel-source” ] ; then
_kernel
fi
_main
}
_pkg-test
exit
—–end —
Leave a Reply