install_amavis.sh: some changes installing 'clamav-unofficial-sigs'.

This commit is contained in:
Christoph 2021-12-22 00:52:13 +01:00
parent 112cde3f7d
commit 39859dcb51

View File

@ -3071,6 +3071,41 @@ if $INSTALL_CLAMAV_UNOFFICIAL_SIGS ; then
[[ $OK = "yes" ]] || fatal "Abbruch durch User"
fi
echononl " Check if working directory for 'urlhaus' will be created if not exists.."
_clamav_script="/usr/local/sbin/clamav-unofficial-sigs.sh"
if ! $(grep -q -E "^\s*xshok_mkdir_ownership\s+\"\\\$work_dir_urlhaus\"" "${_clamav_script}" 2> /dev/null) ; then
if $(grep -q -E "^\s*xshok_mkdir_ownership\s+\"\\\$work_dir\"" "${_clamav_script}" 2> /dev/null) ; then
perl -i -n -p \
-e "s#(\s*xshok_mkdir_ownership\s+)(\"\\\$work_dir\")#\1\2\n\1\"\\\$work_dir_urlhaus\"#" \
"${_clamav_script}" > $tmp_err_msg 2>&1
if [[ $? -eq 0 ]] ; then
echo_ok
else
echo_failed
error "$(cat $tmp_err_msg)"
echononl "continue anyway [yes/no]: "
read OK
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
echononl "Wrong entry! - repeat [yes/nno]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Abbruch durch User"
fi
else
echo_skipped
fi
else
echo_skipped
fi
_create_dirs="/var/log/clamav-unofficial-sigs /etc/clamav-unofficial-sigs"
for _create_dir in $_create_dirs ; do
echononl " Create directory \"${_create_dir}\""
@ -3160,154 +3195,151 @@ if $INSTALL_CLAMAV_UNOFFICIAL_SIGS ; then
if [[ "${os_dist,,}" = "debian" ]] ; then
if [[ "$os_version" = "8" ]] || [[ "$os_version" = "9" ]] || [[ "$os_version" = "10" ]] ; then
## - For Debian Jessie (Debian 8) // Stretch (Debian 9) // Buster (Debian 10)
## -
_failed=false
echononl " At directory /etc/clamav-unofficial-sigs copy os.debian${os_version}.conf to os.conf"
if [[ ! -f /etc/clamav-unofficial-sigs/os.debian${os_version}.conf ]] ; then
_tmp_version=$(expr $os_version - 1)
if [[ -f "/etc/clamav-unofficial-sigs/os.debian${_tmp_version}.conf" ]] ; then
cp "/etc/clamav-unofficial-sigs/os.debian${_tmp_version}.conf" \
## - For Debian Jessie (Debian 8) // Stretch (Debian 9) // Buster (Debian 10) // Bullseye (Debian 11)
## -
_failed=false
echononl " At directory /etc/clamav-unofficial-sigs copy os.debian${os_version}.conf to os.conf"
if [[ ! -f /etc/clamav-unofficial-sigs/os/os.debian${os_version}.conf ]] ; then
_tmp_version=$(expr $os_version - 1)
if [[ -f "/etc/clamav-unofficial-sigs/os/os.debian${_tmp_version}.systemd.conf" ]] ; then
cp "/etc/clamav-unofficial-sigs/os/os.debian${_tmp_version}.systemd.conf" \
"/etc/clamav-unofficial-sigs/os.conf" > $tmp_err_msg 2>&1
if [[ $? -ne 0 ]]; then
echo "Error copying /etc/clamav-unofficial-sigs/os.debian${os_version}.systemd.conf" >> $tmp_err_msg
_failed=true
fi
else
if [[ -f "/etc/clamav-unofficial-sigs/os/os.debian.conf" ]] ; then
cp "/etc/clamav-unofficial-sigs/os/os.debian.conf" \
"/etc/clamav-unofficial-sigs/os.conf" > $tmp_err_msg 2>&1
if [[ $? -ne 0 ]]; then
echo "File not found: /etc/clamav-unofficial-sigs/os.debian${os_version}.conf" > $tmp_err_msg
_failed=true
fi
else
if [[ -f "/etc/clamav-unofficial-sigs/os/os.debian.conf" ]] ; then
cp "/etc/clamav-unofficial-sigs/os/os.debian.conf" \
"/etc/clamav-unofficial-sigs/os.conf" > $tmp_err_msg 2>&1
if [[ $? -ne 0 ]]; then
_failed=true
fi
else
_failed=true
fi
fi
else
cp "/etc/clamav-unofficial-sigs/os.debian${os_version}.conf" \
"/etc/clamav-unofficial-sigs/os.conf" > $tmp_err_msg 2>&1
if [[ $? -ne 0 ]]; then
_failed=true
fi
fi
if ! $_failed ; then
echo_ok
else
echo_failed
error "$(cat $tmp_err_msg)"
echononl "continue anyway [yes/no]: "
read OK
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
echononl "Wrong entry! - repeat [yes/nno]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Abbruch durch User"
fi
## - Edit /etc/clamav-unofficial-sigs/os.conf and make changes if needed
## -
## - Maybe the following changes are needed:
## - clam_user="clamav"
## - clam_group="clamav"
## -
## - clamd_pid="/var/run/clamav/clamd.pid"
## -
## - clamd_restart_opt="systemctl restart clamav-daemon"
## - clamd_reload_opt="systemctl reload clamav-daemon"
## - or if debian 7
## - clamd_restart_opt="service clamav-daemon restart"
## - clamd_reload_opt="service clamav-daemon reload"
## -
## - clamd_socket="/var/run/clamav/clamd.ctl"
## -
echononl " Adjust /etc/clamav-unofficial-sigs/os.conf"
installation_failed=false
perl -i -n -p -e "s#^([ ]*\ *)(clam_user=.*)#\#\#\1\2\nclam_user=\"clamav\"#" \
/etc/clamav-unofficial-sigs/os.conf > $tmp_err_msg 2>&1
if [[ "$?" -ne 0 ]] ; then
installation_failed=true
error "$(cat $tmp_err_msg)"
fi
perl -i -n -p -e "s#^([ ]*\ *)(clam_group=.*)#\#\#\1\2\nclam_group=\"clamav\"#" \
/etc/clamav-unofficial-sigs/os.conf > $tmp_err_msg 2>&1
if [[ "$?" -ne 0 ]] ; then
installation_failed=true
error "$(cat $tmp_err_msg)"
fi
if [[ "${os_dist,,}" = "debian" ]] && [[ "$os_version" -ge 10 ]]; then
perl -i -n -p -e "s#^([ ]*\ *)(clamd_pid=.*)#\#\#\1\2\nclamd_pid=\"/run/clamav/clamd.pid\"#" \
/etc/clamav-unofficial-sigs/os.conf > $tmp_err_msg 2>&1
else
perl -i -n -p -e "s#^([ ]*\ *)(clamd_pid=.*)#\#\#\1\2\nclamd_pid=\"/var/run/clamav/clamd.pid\"#" \
/etc/clamav-unofficial-sigs/os.conf > $tmp_err_msg 2>&1
else
cp "/etc/clamav-unofficial-sigs/os/os.debian${os_version}.conf" \
"/etc/clamav-unofficial-sigs/os.conf" > $tmp_err_msg 2>&1
if [[ $? -ne 0 ]]; then
_failed=true
fi
if [[ "$?" -ne 0 ]] ; then
installation_failed=true
error "$(cat $tmp_err_msg)"
fi
fi
if ! $_failed ; then
echo_ok
else
echo_failed
error "$(cat $tmp_err_msg)"
if $systemd_exists ; then
perl -i -n -p -e "s#^([ ]*\#?\ *)(clamd_restart_opt=.*)#\#\#\1\2\nclamd_restart_opt=\"systemctl restart clamav-daemon\"\nclamd_reload_opt=\"systemctl reload clamav-daemon\"#" \
/etc/clamav-unofficial-sigs/os.conf > $tmp_err_msg 2>&1
if [[ "$?" -ne 0 ]] ; then
installation_failed=true
error "$(cat $tmp_err_msg)"
fi
else
perl -i -n -p -e "s#^([ ]*\#?\ *)(clamd_restart_opt=.*)#\#\#\1\2\nclamd_restart_opt=\"service clamav-daemon restart\"\nclamd_reload_opt=\"service clamav-daemon reload\"#" \
/etc/clamav-unofficial-sigs/os.conf > $tmp_err_msg 2>&1
if [[ "$?" -ne 0 ]] ; then
installation_failed=true
error "$(cat $tmp_err_msg)"
fi
fi
if [[ "${os_dist,,}" = "debian" ]] && [[ "$os_version" -ge 10 ]]; then
perl -i -n -p -e "s#^([ ]*\#?\ *)(clamd_socket=.*)#\#\#\1\2\nclamd_socket=\"/run/clamav/clamd.ctl\"#" \
/etc/clamav-unofficial-sigs/os.conf > $tmp_err_msg 2>&1
else
perl -i -n -p -e "s#^([ ]*\#?\ *)(clamd_socket=.*)#\#\#\1\2\nclamd_socket=\"/var/run/clamav/clamd.ctl\"#" \
/etc/clamav-unofficial-sigs/os.conf > $tmp_err_msg 2>&1
echononl "continue anyway [yes/no]: "
read OK
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
echononl "Wrong entry! - repeat [yes/nno]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Abbruch durch User"
fi
## - Edit /etc/clamav-unofficial-sigs/os.conf and make changes if needed
## -
## - Maybe the following changes are needed:
## - clam_user="clamav"
## - clam_group="clamav"
## -
## - clamd_pid="/var/run/clamav/clamd.pid"
## -
## - clamd_restart_opt="systemctl restart clamav-daemon"
## - clamd_reload_opt="systemctl reload clamav-daemon"
## - or if debian 7
## - clamd_restart_opt="service clamav-daemon restart"
## - clamd_reload_opt="service clamav-daemon reload"
## -
## - clamd_socket="/var/run/clamav/clamd.ctl"
## -
echononl " Adjust /etc/clamav-unofficial-sigs/os.conf"
installation_failed=false
perl -i -n -p -e "s#^([ ]*\ *)(clam_user=.*)#\#\#\1\2\nclam_user=\"clamav\"#" \
/etc/clamav-unofficial-sigs/os.conf > $tmp_err_msg 2>&1
if [[ "$?" -ne 0 ]] ; then
installation_failed=true
error "$(cat $tmp_err_msg)"
fi
perl -i -n -p -e "s#^([ ]*\ *)(clam_group=.*)#\#\#\1\2\nclam_group=\"clamav\"#" \
/etc/clamav-unofficial-sigs/os.conf > $tmp_err_msg 2>&1
if [[ "$?" -ne 0 ]] ; then
installation_failed=true
error "$(cat $tmp_err_msg)"
fi
if [[ "${os_dist,,}" = "debian" ]] && [[ "$os_version" -ge 10 ]]; then
perl -i -n -p -e "s#^([ ]*\ *)(clamd_pid=.*)#\#\#\1\2\nclamd_pid=\"/run/clamav/clamd.pid\"#" \
/etc/clamav-unofficial-sigs/os.conf > $tmp_err_msg 2>&1
else
perl -i -n -p -e "s#^([ ]*\ *)(clamd_pid=.*)#\#\#\1\2\nclamd_pid=\"/var/run/clamav/clamd.pid\"#" \
/etc/clamav-unofficial-sigs/os.conf > $tmp_err_msg 2>&1
fi
if [[ "$?" -ne 0 ]] ; then
installation_failed=true
error "$(cat $tmp_err_msg)"
fi
if $systemd_exists ; then
perl -i -n -p -e "s#^([ ]*\#?\ *)(clamd_restart_opt=.*)#\#\#\1\2\nclamd_restart_opt=\"systemctl restart clamav-daemon\"\nclamd_reload_opt=\"systemctl reload clamav-daemon\"#" \
/etc/clamav-unofficial-sigs/os.conf > $tmp_err_msg 2>&1
if [[ "$?" -ne 0 ]] ; then
installation_failed=true
error "$(cat $tmp_err_msg)"
fi
if [[ "$?" -ne 0 ]] ; then
installation_failed=true
error "$(cat $tmp_err_msg)"
else
perl -i -n -p -e "s#^([ ]*\#?\ *)(clamd_restart_opt=.*)#\#\#\1\2\nclamd_restart_opt=\"service clamav-daemon restart\"\nclamd_reload_opt=\"service clamav-daemon reload\"#" \
/etc/clamav-unofficial-sigs/os.conf > $tmp_err_msg 2>&1
if [[ "$?" -ne 0 ]] ; then
installation_failed=true
error "$(cat $tmp_err_msg)"
fi
fi
if [[ "${os_dist,,}" = "debian" ]] && [[ "$os_version" -ge 10 ]]; then
perl -i -n -p -e "s#^([ ]*\#?\ *)(clamd_socket=.*)#\#\#\1\2\nclamd_socket=\"/run/clamav/clamd.ctl\"#" \
/etc/clamav-unofficial-sigs/os.conf > $tmp_err_msg 2>&1
else
perl -i -n -p -e "s#^([ ]*\#?\ *)(clamd_socket=.*)#\#\#\1\2\nclamd_socket=\"/var/run/clamav/clamd.ctl\"#" \
/etc/clamav-unofficial-sigs/os.conf > $tmp_err_msg 2>&1
fi
if [[ "$?" -ne 0 ]] ; then
installation_failed=true
error "$(cat $tmp_err_msg)"
echononl "continue anyway [yes/no]: "
read OK
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
echononl "Wrong entry! - repeat [yes/nno]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Abbruch durch User"
fi
if ! $installation_failed ; then
echo_ok
fi
else
error "Cannot create file '/etc/clamav-unofficial-sigs/os.conf' (No Debian Version detected).
See file /etc/clamav-unofficial-sigs/INSTALL.md to create it manually"
echononl "continue anyway [yes/no]: "
read OK
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
echononl "Wrong entry! - repeat [yes/nno]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Abbruch durch User"
fi
echononl "continue anyway [yes/no]: "
read OK
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
echononl "Wrong entry! - repeat [yes/nno]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Abbruch durch User"
fi
if ! $installation_failed ; then
echo_ok
fi
else
error "Cannot create file 'os.conf' (No Linux Distribution detected)
See file /etc/clamav-unofficial-sigs/INSTALL to create it manually"
echononl "continue anyway [yes/no]: "
read OK
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
echononl "Wrong entry! - repeat [yes/nno]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Abbruch durch User"
fi
fi # if [[ "${os_dist,,}" = "debian" ]]
echononl " Adjust /etc/clamav-unofficial-sigs/user.conf"