#!/bin/bash

set -e

####
## Functions
####

function initial_conf() {
    # This function runs the initial configuration the module needs once it is installed

    # Workaround to fix the following message:
    # Standard output type syslog is obsolete, automatically updating to journal. Please update your unit file, and consider removing the setting altogether
    for daemon in clamav-daemon.service clamav-freshclam.service; do
        if grep -q 'StandardOutput=syslog' /lib/systemd/system/$daemon; then
            sed -i 's#StandardOutput=syslog#StandardOutput=file:/var/log/syslog#' /lib/systemd/system/$daemon
            systemctl daemon-reload
        fi
    done
}


function mod_disabled() {
    # This function stops and disables the services that uses the module
    systemctl disable --now clamav-daemon clamav-freshclam zentyal.antivirus-clamonacc
}


####
## Calls
####

initial_conf
mod_disabled

exit 0
