56 lines
2.4 KiB
Bash
Executable file
56 lines
2.4 KiB
Bash
Executable file
print_config_title 'CHECK MAIL ALIAS CONFIG'
|
|
|
|
# This does not check if send mail works and if alias have been reloaded
|
|
# Check /etc/mail/aliases config file, checked param : root/operator
|
|
|
|
conf_file_to_test="/etc/mail/aliases"
|
|
|
|
# Check if conf file exist
|
|
if [[ ! -f "${conf_file_to_test}" ]]
|
|
then
|
|
echo -e "${RED}ERROR : file ${conf_file_to_test} NOT FOUND.${NC}\n"
|
|
MAIL_ALIAS_CONFIG_CHECK_FAILED=${MAIL_ALIAS_CONFIG_CHECK_FAILED}" Error, file ${conf_file_to_test} not found;"
|
|
else
|
|
|
|
# root
|
|
check_value_in_conf_file "ALIAS" "${conf_file_to_test}" "root" "${MAIL_ALIAS_ROOT}"
|
|
|
|
case ${?} in
|
|
0) # OK, nothing to do
|
|
;;
|
|
1) # Error (wrong number of param or other)
|
|
MAIL_ALIAS_CONFIG_CHECK_FAILED=${MAIL_ALIAS_CONFIG_CHECK_FAILED}" Error during root alias check with function check_value_in_conf_file, maybe incorrect number of parameter or file not found;"
|
|
;;
|
|
2) # Unexpected value is set
|
|
MAIL_ALIAS_CONFIG_CHECK_FAILED=${MAIL_ALIAS_CONFIG_CHECK_FAILED}" root alias is not well configured or has other value, set root: ${MAIL_ALIAS_ROOT};"
|
|
;;
|
|
3) # All expected values are NOT configured
|
|
MAIL_ALIAS_CONFIG_CHECK_FAILED=${MAIL_ALIAS_CONFIG_CHECK_FAILED}" root alias is not well configured, set root: ${MAIL_ALIAS_ROOT};"
|
|
;;
|
|
*) # Unknown return code...
|
|
MAIL_ALIAS_CONFIG_CHECK_FAILED=${MAIL_ALIAS_CONFIG_CHECK_FAILED}" Error, unknown return code when calling check_value_in_conf_file to check root alias;"
|
|
;;
|
|
esac
|
|
|
|
|
|
# root
|
|
check_value_in_conf_file "ALIAS" "${conf_file_to_test}" "operator" "${MAIL_ALIAS_ROOT}"
|
|
|
|
case ${?} in
|
|
0) # OK, nothing to do
|
|
;;
|
|
1) # Error (wrong number of param or other)
|
|
MAIL_ALIAS_CONFIG_CHECK_FAILED=${MAIL_ALIAS_CONFIG_CHECK_FAILED}" Error during operator alias check with function check_value_in_conf_file, maybe incorrect number of parameter or file not found;"
|
|
;;
|
|
2) # Unexpected value is set
|
|
MAIL_ALIAS_CONFIG_CHECK_FAILED=${MAIL_ALIAS_CONFIG_CHECK_FAILED}" operator alias is not well configured or has other value, set operator: ${MAIL_ALIAS_ROOT};"
|
|
;;
|
|
3) # All expected values are NOT configured
|
|
MAIL_ALIAS_CONFIG_CHECK_FAILED=${MAIL_ALIAS_CONFIG_CHECK_FAILED}" operator alias is not well configured, set operator: ${MAIL_ALIAS_ROOT};"
|
|
;;
|
|
*) # Unknown return code...
|
|
MAIL_ALIAS_CONFIG_CHECK_FAILED=${MAIL_ALIAS_CONFIG_CHECK_FAILED}" Error, unknown return code when calling check_value_in_conf_file to check operator alias;"
|
|
;;
|
|
esac
|
|
fi
|