#!/bin/bash #################################################################################################### #### author: SlickStack ############################################################################ #### link: https://slickstack.io ################################################################### #### mirror: https://mirrors.slickstack.io/bash/ss-install-clamav.txt ############################## #### path: /var/www/ss-install-clamav ############################################################## #### destination: n/a (not a boilerplate) ########################################################## #### purpose: Reinstalls the entire ClamAV module for SlickStack servers (idempotent) ############## #### module version: ClamAV 0.102.x ################################################################ #### sourced by: ss-install ######################################################################## #### bash aliases: ss install clamav ############################################################### #################################################################################################### ## SS-CONFIG MUST BE PROPERLY CONFIGURED AND ON CURRENT BUILD BEFORE RUNNING SS-INSTALL ## ## ENSURE YOUR SS-CONFIG BUILD REMAINS CURRENT BY RUNNING SS-UPDATE OCCASIONALLY ## ## source ss-config ## source /var/www/ss-config ## source ss-functions ## source /var/www/ss-functions ## BELOW THIS RELIES ON SS-CONFIG AND SS-FUNCTIONS #################################################################################################### #### TABLE OF CONTENTS (SS-Install-ClamAV) ######################################################### #################################################################################################### ## this is a brief summary of the different code snippets you will find in this script ## ## each section should be commented so you understand what is being accomplished ## ## A. Touch Timestamp File ## B. Message (Begin Script) #################################################################################################### #### A. SS-Install-ClamAV: Touch Timestamp File #################################################### #################################################################################################### ## this is a dummy timestamp file that will remember the last time this script was run ## ## it can be useful for developer reference and is sometimes used by SlickStack ## ## script timestamp ## ss_touch "${TIMESTAMP_SS_INSTALL_CLAMAV}" #################################################################################################### #### B. SS-Install-ClamAV: Message (Begin Script) ################################################## #################################################################################################### ## this is a simple message that announces to the shell the purpose of this bash script ## ## it will only be noticed by sudo users who manually call ss core bash scripts ## ## echo message ## ss_echo "${COLOR_INFO}Running ss-install-clamav... ${COLOR_RESET}" #################################################################################################### #### SS-Install-ClamAV: Cleanup Temporary Files #################################################### #################################################################################################### ## delete tmp files ## # n/a #################################################################################################### #### SS-Install-ClamAV: Update Existing Packages ################################################### #################################################################################################### ## SNIPPET: ss-install-*-packages bash scripts ## UPDATED: 30MAR2022 ## we must include the standard apt update/upgrade in case script is called directly ## ## this helps to avoid conflicts and outdated packages during installation ## ## update apt cache ## ss_apt_update ## upgrade packages ## ss_apt_upgrade #################################################################################################### #### SS-Install-ClamAV: Install ClamAV (Ubuntu Packages) ########################################### #################################################################################################### ## this will install ClamAV for occassional malware logging: /var/www/logs/clamav.log ## ## keep in mind that infected files are not automatically cleaned or deleted ## ## ubuntu 22.04 ## if [[ "${UBUNTU_VERSION}" = "22.04" ]]; then apt install clamav > /dev/null 2>&1 fi ## ubuntu 20.04 ## if [[ "${UBUNTU_VERSION}" = "20.04" ]]; then apt install clamav > /dev/null 2>&1 fi ## ubuntu 18.04 ## if [[ "${UBUNTU_VERSION}" = "18.04" ]]; then apt install clamav > /dev/null 2>&1 freshclam ## updates malware cache (required in 18.04 and earlier) fi ## ubuntu 16.04 ## if [[ "${UBUNTU_VERSION}" = "16.04" ]]; then apt install clamav clamav-daemon > /dev/null 2>&1 # incomplete... research fi ## NEED TO EXPAND AND IMPROVE ## # sed -i '/UpdateLogFile/c\UpdateLogFile /var/www/logs/clamav.log' /etc/clamav/freshclam.conf sed -i '/LogRotate/c\LogRotate true' /etc/clamav/freshclam.conf sed -i '/Checks/c\Checks 2' /etc/clamav/freshclam.conf sed -i '/MaxAttempts/c\MaxAttempts 3' /etc/clamav/freshclam.conf #################################################################################################### #### SS-Install-ClamAV: Reset Permissions (ClamAV) ################################################# #################################################################################################### ## run ss-perms-clamav ## source "$PATH_SS_PERMS_CLAMAV" #################################################################################################### #### SS-Install-ClamAV: Cleanup Temporary Files #################################################### #################################################################################################### ## delete tmp files ## # n/a #################################################################################################### #### PLACEHOLDER: Reset Permissions (SlickStack Scripts) ########################################### #################################################################################################### ## we include this permissions reset in all cron jobs and bash scripts for redundancy ## ## chmod 0700 means only the root/sudo users can execute any SlickStack scripts ## ## THIS SNIPPET DOES NOT RELY ON SS-CONFIG OR SS-FUNCTIONS ## SNIPPET: ss bash scripts, ss cron jobs ## UPDATED: 02JUL2022 chown root:root /var/www/ss* ## must be root:root chown root:root /var/www/crons/*cron* ## must be root:root chown root:root /var/www/crons/custom/*cron* ## must be root:root chmod 0700 /var/www/ss* ## 0700 means only root/sudo can execute chmod 0700 /var/www/crons/*cron* ## 0700 means only root/sudo can execute chmod 0700 /var/www/crons/custom/*cron* ## 0700 means only root/sudo can execute #################################################################################################### #### SlickStack: External References Used To Improve This Script (Thanks, Interwebz) ############### #################################################################################################### ## Ref: https://askubuntu.com/questions/1214151/ubuntu-clamav-freshclam-cant-download-main-cvd ## Ref: https://medium.com/@kainikhil/installing-clamav-and-clam-f4d26d8150c4 ## SS_EOF