#!/bin/bash gitRepo="https://github.com/Cisco-Talos/clamav" function who { if [ "$(whoami)" != "root" ]; then echo "[+] Checking root user" echo -e "\e[31m\e[1m[NOT OK]\e[0m Run it with root please" && exit fi } function installDependenciesDebian11 { apt-get update -y && apt-get install -y gcc make pkg-config python3 python3-pip python3-pytest valgrind check libbz2-dev libcurl4-openssl-dev libjson-c-dev libmilter-dev libncurses5-dev libpcre2-dev libssl-dev libxml2-dev zlib1g-dev cargo rustc git cmake librust-flate2* curl } function installDependenciesUbuntu22044LTS { apt-get update -y && apt-get install -y gcc make pkg-config python3 python3-pip python3-pytest valgrind check libbz2-dev libcurl4-openssl-dev libjson-c-dev libmilter-dev libncurses5-dev libpcre2-dev libssl-dev libxml2-dev zlib1g-dev cargo rustc git cmake librust-flate2* curl } function getLastVersion() { git clone "$gitRepo" /var/tmp/clamav cd /var/tmp/clamav git fetch --all --tags lastClamavVersion=$(git describe | cut -d "-" -f 2) rm -rf /var/tmp/clamav cd /var/tmp/ wget -q "https://www.clamav.net/downloads/production/clamav-$lastClamavVersion.tar.gz" -O /var/tmp/clamav-$lastClamavVersion.tar.gz tar xfvz /var/tmp/clamav-$lastClamavVersion.tar.gz cd /var/tmp/clamav-$lastClamavVersion } function compileLastVersion() { mkdir -p build cd build cmake .. -D CMAKE_INSTALL_PREFIX=/usr -D CMAKE_INSTALL_LIBDIR=lib -D APP_CONFIG_DIRECTORY=/etc/clamav -D DATABASE_DIRECTORY=/var/lib/clamav -D ENABLE_JSON_SHARED=OFF cmake --build . ctest cmake --build . --target install } function main() { # Debian 11 cat /etc/issue | grep "Debian GNU/Linux 11" 1>/dev/null ; if [ "$?" -ne 1 ]; then who ; installDependenciesDebian11 ; getLastVersion ; compileLastVersion fi # Ubuntu 22.04.4 LTS cat /etc/issue | grep "Ubuntu 22.04.4 LTS" 1>/dev/null ; if [ "$?" -ne 1 ]; then who ; installDependenciesUbuntu22044LTS ; getLastVersion ; compileLastVersion fi } main