OwlCyberSecurity - MANAGER
Edit File: cpanel-clamav.postinst
#!/bin/sh set -e if [ ! -z "$PBUILDER_OPERATION" ]; then echo "Skipping post-install for clamav due to PBUILDER_OPERATION environment variable"; exit 0 fi; ## <asset scriplets/post> set -e CLAMDIR=/usr/local/cpanel/3rdparty/share/clamav FIRSTDIR=$CLAMDIR/.first-install USER="clamav" GROUP=$USER if [ -z $RHEL ]; then RHEL=0; fi; PREFIX=/usr/local/cpanel/3rdparty runPost_install() { echo "runPost_install" # Remove previous freshclam pointing to old binary. This removes any crontab line with "freshclam", not path specific ${PREFIX}/bin/clamav_setupcrontab off # Re-enable the freshclam in crontab, using the correct path, /ulc/3rdparty/bin ${PREFIX}/bin/clamav_setupcrontab } runPost_all() { echo "runPost_all" # enforce ownership & perms for clamdir chown ${USER}:${GROUP} ${CLAMDIR} chmod 0755 ${CLAMDIR} # Register the plugin in WHM for installs and upgrades /usr/local/cpanel/bin/register_appconfig /usr/local/cpanel/3rdparty/share/clamav/clamavconnector.conf ||: # Enable clamav icons in cPanel /bin/mkdir -p /var/cpanel/dynamicui ||: chmod 755 /var/cpanel/dynamicui ||: chown root: /var/cpanel/dynamicui ||: /bin/touch /var/cpanel/dynamicui/clamav ||: chmod 644 /var/cpanel/dynamicui/clamav ||: # This will grab the clamav virus definitions from mirrors ${PREFIX}/bin/freshclam ||: # Include clamd entry in "/etc/chkserv.d/chkservd.conf" for clamd monitoring service chkservd_conf="/etc/chkserv.d/chkservd.conf" if [ ! -e $chkservd_conf ]; then echo "Missing '$chkservd_conf' file, running bin/chkservd-install" /usr/local/cpanel/bin/chkservd-install ||: fi if [ -e $chkservd_conf ]; then tmpfile="${chkservd_conf}.tmp" echo "Adding clamd to chkservd" grep -v '^clamd:[0-1]' $chkservd_conf > $tmpfile echo 'clamd:1' >> $tmpfile # preserve permissions and ownership cat $tmpfile > $chkservd_conf rm -f $tmpfile else echo "Warning: 'clamd' could not be added for chkservd monitoring -- expected config file '$chkservd_conf' does not exist." fi /usr/local/cpanel/scripts/restartsrv_clamd --no-verbose --stop ||: # If exim is installed and not disabled then update its configuration to use clamd if [ -e '/usr/sbin/exim' -a ! -e '/etc/eximdisable' ]; then /usr/local/cpanel/scripts/buildeximconf ||: /usr/local/cpanel/scripts/restartsrv_exim --no-verbose ||: fi # systemd needs to reload the service file # /usr/bin/systemctl daemon-reload # enable the service ( only c7 use a service ) /usr/bin/systemctl enable clamd.service # Debian will setup the service for us. # restart the clamd service echo "scripts/restartsrv_clamd" /usr/local/cpanel/scripts/restartsrv_clamd --no-verbose ||: # resume the monitoring /usr/local/cpanel/3rdparty/bin/perl -MCpanel::Chkservd::Tiny -e'Cpanel::Chkservd::Tiny::resume_service("clamd")' ||: } ## </asset> case "$1" in configure) if [ "x$2" = 'x' ]; then runPost_install; fi runPost_all; ;; esac exit 0