diff --git a/unattended_installer/cert_tool/certMain.sh b/unattended_installer/cert_tool/certMain.sh index 7d4cfc0d7f..64ba28573a 100644 --- a/unattended_installer/cert_tool/certMain.sh +++ b/unattended_installer/cert_tool/certMain.sh @@ -158,6 +158,8 @@ function main() { esac done + common_logger "Verbose logging redirected to ${logfile}" + if [[ -d "${base_path}"/wazuh-certificates ]]; then if [ -n "$(ls -A "${base_path}"/wazuh-certificates)" ]; then common_logger -e "Directory wazuh-certificates already exists in the same path as the script. Please, remove the certs directory to create new certificates." diff --git a/unattended_installer/cert_tool/certVariables.sh b/unattended_installer/cert_tool/certVariables.sh index a40717b4f3..7d86d37592 100644 --- a/unattended_installer/cert_tool/certVariables.sh +++ b/unattended_installer/cert_tool/certVariables.sh @@ -6,9 +6,9 @@ # License (version 2) as published by the FSF - Free Software # Foundation. -base_path="$(dirname "$(readlink -f "$0")")" -readonly base_path +readonly base_path="$(dirname "$(readlink -f "$0")")" readonly config_file="${base_path}/config.yml" -readonly logfile="" +readonly logfile="${base_path}/wazuh-certificates-tool.log" cert_tmp_path="/tmp/wazuh-certificates" -debug=">> /dev/null 2>&1" \ No newline at end of file +debug=">> ${logfile} 2>&1" +readonly cert_tool_script_name=".*certs.*\.sh" \ No newline at end of file diff --git a/unattended_installer/common_functions/common.sh b/unattended_installer/common_functions/common.sh index 0f393b24b2..096625421e 100644 --- a/unattended_installer/common_functions/common.sh +++ b/unattended_installer/common_functions/common.sh @@ -56,7 +56,7 @@ function common_logger() { fi if [ -z "${debugLogger}" ] || { [ -n "${debugLogger}" ] && [ -n "${debugEnabled}" ]; }; then - if [ "$EUID" -eq 0 ] && [ -z "${nolog}" ]; then + if [ -z "${nolog}" ] && { [ "$EUID" -eq 0 ] || [[ "$(basename "$0")" =~ $cert_tool_script_name ]]; }; then printf "%s\n" "${now} ${mtype} ${message}" | tee -a ${logfile} else printf "%b\n" "${now} ${mtype} ${message}"