( cd usr/lib64 ; rm -rf libclamav.so )
( cd usr/lib64 ; ln -sf libclamav.so.12 libclamav.so )
( cd usr/lib64 ; rm -rf libclamav.so.12 )
( cd usr/lib64 ; ln -sf libclamav.so.12.0.3 libclamav.so.12 )
( cd usr/lib64 ; rm -rf libclammspack.so )
( cd usr/lib64 ; ln -sf libclammspack.so.0 libclammspack.so )
( cd usr/lib64 ; rm -rf libclammspack.so.0 )
( cd usr/lib64 ; ln -sf libclammspack.so.0.8.0 libclammspack.so.0 )
( cd usr/lib64 ; rm -rf libclamunrar.so )
( cd usr/lib64 ; ln -sf libclamunrar.so.12 libclamunrar.so )
( cd usr/lib64 ; rm -rf libclamunrar.so.12 )
( cd usr/lib64 ; ln -sf libclamunrar.so.12.0.3 libclamunrar.so.12 )
( cd usr/lib64 ; rm -rf libclamunrar_iface.so )
( cd usr/lib64 ; ln -sf libclamunrar_iface.so.12 libclamunrar_iface.so )
( cd usr/lib64 ; rm -rf libclamunrar_iface.so.12 )
( cd usr/lib64 ; ln -sf libclamunrar_iface.so.12.0.3 libclamunrar_iface.so.12 )
( cd usr/lib64 ; rm -rf libfreshclam.so )
( cd usr/lib64 ; ln -sf libfreshclam.so.3 libfreshclam.so )
( cd usr/lib64 ; rm -rf libfreshclam.so.3 )
( cd usr/lib64 ; ln -sf libfreshclam.so.3.0.2 libfreshclam.so.3 )

#
# check clamav accounts
#
if [ -z "`grep ^clamav /etc/group`" ]; then
    groupadd -g 203 clamav
fi
if [ -z "`grep ^clamav /etc/passwd`" ]; then
    useradd -u 203 -g 203 -s /bin/false -c "Clam AntiVirus" clamav
fi
#
# Create pid directory
#
mkdir -p /var/{log,lib}/clamav
chown clamav:clamav /var/{log,lib}/clamav
#
/sbin/ldconfig

# Upgrade to rc.clamd init script.
rm -f /etc/rc.d/rc0.d/K25clamd /etc/rc.d/rc1.d/K25clamd /etc/rc.d/rc3.d/S75clamd /etc/rc.d/rc4.d/S75clamd /etc/rc.d/rc6.d/K25clamd
rm -f /etc/rc.d/init.d/clamd*
rm -f /var/lib/pkgtools/setup/setup.clamd

config() {
  NEW="$1"
  OLD="`dirname $NEW`/`basename $NEW .new`"
  # If there's no config file by that name, mv it over:
  if [ ! -r $OLD ]; then
    mv $NEW $OLD
  elif [ "`cat $OLD | md5sum`" = "`cat $NEW | md5sum`" ]; then # toss the redundant copy
    rm $NEW
  fi
  # Otherwise, we leave the .new copy for the admin to consider...
}

config etc/rc.d/rc.clamd.new


