Check if files exists before other tests

This commit is contained in:
nemo 2019-06-29 11:26:10 +02:00
parent fa9c7fbb7f
commit 9f0538841d
9 changed files with 705 additions and 635 deletions

View file

@ -5,10 +5,6 @@ echo "Check if auto-update script is present"
if [[ -f "${BACKUP_SCRIPT}" ]] if [[ -f "${BACKUP_SCRIPT}" ]]
then then
echo -e "${GREEN}The auto-backup script is present : check OK${NC}\n" echo -e "${GREEN}The auto-backup script is present : check OK${NC}\n"
else
AUTOBACKUP_CONFIG_CHECK_FAILED=${AUTOBACKUP_CONFIG_CHECK_FAILED}" The auto-backup script is NOT on the system;"
echo -e "${RED}The auto-backup is NOT on the system : check KO${NC}\n"
fi
# Check the script (content) # Check the script (content)
echo "Check the script (content)" echo "Check the script (content)"
@ -88,3 +84,8 @@ then
else else
echo -e "${GREEN}Cron entry for auto-backup exist: check OK${NC}\n" echo -e "${GREEN}Cron entry for auto-backup exist: check OK${NC}\n"
fi fi
else
AUTOBACKUP_CONFIG_CHECK_FAILED=${AUTOBACKUP_CONFIG_CHECK_FAILED}" The auto-backup script is NOT on the system;"
echo -e "${RED}The auto-backup is NOT on the system : check KO${NC}\n"
fi

View file

@ -5,10 +5,6 @@ echo "Check if auto-update script is present"
if [[ -f "${AUTOUPDATE_SCRIPT}" ]] if [[ -f "${AUTOUPDATE_SCRIPT}" ]]
then then
echo -e "${GREEN}The auto-update script is present : check OK${NC}\n" echo -e "${GREEN}The auto-update script is present : check OK${NC}\n"
else
AUTOUPDATE_CONFIG_CHECK_FAILED=${AUTOUPDATE_CONFIG_CHECK_FAILED}" The auto-update script is NOT on the system;"
echo -e "${RED}The auto-update is NOT on the system : check KO${NC}\n"
fi
# Check if the auto-update script is executable # Check if the auto-update script is executable
echo "Check if the auto-update script is executable" echo "Check if the auto-update script is executable"
@ -36,3 +32,11 @@ then
else else
echo -e "${GREEN}Cron entry for auto-update exist: check OK${NC}\n" echo -e "${GREEN}Cron entry for auto-update exist: check OK${NC}\n"
fi fi
else
AUTOUPDATE_CONFIG_CHECK_FAILED=${AUTOUPDATE_CONFIG_CHECK_FAILED}" The auto-update script is NOT on the system;"
echo -e "${RED}The auto-update is NOT on the system : check KO${NC}\n"
fi

View file

@ -3,43 +3,53 @@ print_config_title 'CHECK MAIL ALIAS CONFIG'
# This does not check if send mail works and if alias have been reloaded # This does not check if send mail works and if alias have been reloaded
# Check /etc/mail/aliases config file, checked param : root/operator # 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 # root
check_value_in_conf_file "MUNIN" "/etc/mail/aliases" "root" "${MAIL_ALIAS_ROOT}" check_value_in_conf_file "ALIAS" "${conf_file_to_test}" "root" "${MAIL_ALIAS_ROOT}"
case ${?} in case ${?} in
0) # OK, nothing to do 0) # OK, nothing to do
;; ;;
1) # Error (wrong number of param or other) 1) # Error (wrong number of param or other)
MUNIN_CONFIG_CHECK_FAILED=${MUNIN_CONFIG_CHECK_FAILED}" Error during root alias check with function check_value_in_conf_file, maybe incorrect number of parameter;" 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 2) # Unexpected value is set
MUNIN_CONFIG_CHECK_FAILED=${MUNIN_CONFIG_CHECK_FAILED}" root alias is not well configured or has other value, set root: ${MAIL_ALIAS_ROOT};" 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 3) # All expected values are NOT configured
MUNIN_CONFIG_CHECK_FAILED=${MUNIN_CONFIG_CHECK_FAILED}" root alias is not well configured, set root: ${MAIL_ALIAS_ROOT};" MAIL_ALIAS_CONFIG_CHECK_FAILED=${MAIL_ALIAS_CONFIG_CHECK_FAILED}" root alias is not well configured, set root: ${MAIL_ALIAS_ROOT};"
;; ;;
*) # Unknown return code... *) # Unknown return code...
MUNIN_CONFIG_CHECK_FAILED=${MUNIN_CONFIG_CHECK_FAILED}" Error, unknown return code when calling check_value_in_conf_file to check root alias;" 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 esac
# root # root
check_value_in_conf_file "MUNIN" "/etc/mail/aliases" "operator" "${MAIL_ALIAS_ROOT}" check_value_in_conf_file "ALIAS" "${conf_file_to_test}" "operator" "${MAIL_ALIAS_ROOT}"
case ${?} in case ${?} in
0) # OK, nothing to do 0) # OK, nothing to do
;; ;;
1) # Error (wrong number of param or other) 1) # Error (wrong number of param or other)
MUNIN_CONFIG_CHECK_FAILED=${MUNIN_CONFIG_CHECK_FAILED}" Error during operator alias check with function check_value_in_conf_file, maybe incorrect number of parameter;" 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 2) # Unexpected value is set
MUNIN_CONFIG_CHECK_FAILED=${MUNIN_CONFIG_CHECK_FAILED}" operator alias is not well configured or has other value, set operator: ${MAIL_ALIAS_ROOT};" 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 3) # All expected values are NOT configured
MUNIN_CONFIG_CHECK_FAILED=${MUNIN_CONFIG_CHECK_FAILED}" operator alias is not well configured, set operator: ${MAIL_ALIAS_ROOT};" MAIL_ALIAS_CONFIG_CHECK_FAILED=${MAIL_ALIAS_CONFIG_CHECK_FAILED}" operator alias is not well configured, set operator: ${MAIL_ALIAS_ROOT};"
;; ;;
*) # Unknown return code... *) # Unknown return code...
MUNIN_CONFIG_CHECK_FAILED=${MUNIN_CONFIG_CHECK_FAILED}" Error, unknown return code when calling check_value_in_conf_file to check operator alias;" 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 esac
fi

View file

@ -4,15 +4,23 @@ print_config_title 'CHECK MUNIN BASIC CONFIG'
# This does not check if MUNIN 'monitoring server' has configured this machine # This does not check if MUNIN 'monitoring server' has configured this machine
# Check /etc/munin/munin-node.conf config file, checked parameters : allow/port # Check /etc/munin/munin-node.conf config file, checked parameters : allow/port
conf_file_to_test="/etc/munin/munin-node.conf"
# 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"
MUNIN_CONFIG_CHECK_FAILED=${MUNIN_CONFIG_CHECK_FAILED}" Error, file ${conf_file_to_test} not found;"
else
# allow # allow
check_value_in_conf_file "MUNIN" "/etc/munin/munin-node.conf" "allow" '\^127\\\.0\\\.0\\\.1\$ \^::1\$'" ${IPV4_MASTER_MUNIN} ${IPV6_MASTER_MUNIN}" check_value_in_conf_file "MUNIN" "${conf_file_to_test}" "allow" '\^127\\\.0\\\.0\\\.1\$ \^::1\$'" ${IPV4_MASTER_MUNIN} ${IPV6_MASTER_MUNIN}"
case ${?} in case ${?} in
0) # OK, nothing to do 0) # OK, nothing to do
;; ;;
1) # Error (wrong number of param or other) 1) # Error (wrong number of param or other)
MUNIN_CONFIG_CHECK_FAILED=${MUNIN_CONFIG_CHECK_FAILED}" Error during allow check with function check_value_in_conf_file, maybe incorrect number of parameter;" MUNIN_CONFIG_CHECK_FAILED=${MUNIN_CONFIG_CHECK_FAILED}" Error during allow check with function check_value_in_conf_file, maybe incorrect number of parameter or file not found;"
;; ;;
2) # Unexpected value is set 2) # Unexpected value is set
MUNIN_CONFIG_CHECK_FAILED=${MUNIN_CONFIG_CHECK_FAILED}" allow param is not well configured or has other value, set allow param (IPv6+IPv4) for localhost and Munin server;" MUNIN_CONFIG_CHECK_FAILED=${MUNIN_CONFIG_CHECK_FAILED}" allow param is not well configured or has other value, set allow param (IPv6+IPv4) for localhost and Munin server;"
@ -27,13 +35,13 @@ esac
# port # port
check_value_in_conf_file "MUNIN" "/etc/munin/munin-node.conf" "port" "4949" check_value_in_conf_file "MUNIN" "${conf_file_to_test}" "port" "4949"
case ${?} in case ${?} in
0) # OK, nothing to do 0) # OK, nothing to do
;; ;;
1) # Error (wrong number of param or other) 1) # Error (wrong number of param or other)
MUNIN_CONFIG_CHECK_FAILED=${MUNIN_CONFIG_CHECK_FAILED}" Error during port check with function check_value_in_conf_file, maybe incorrect number of parameter;" MUNIN_CONFIG_CHECK_FAILED=${MUNIN_CONFIG_CHECK_FAILED}" Error during port check with function check_value_in_conf_file, maybe incorrect number of parameter or file not found;"
;; ;;
2) # Unexpected value is set 2) # Unexpected value is set
MUNIN_CONFIG_CHECK_FAILED=${MUNIN_CONFIG_CHECK_FAILED}" port is not well configured or has other value, set 'port 4949';" MUNIN_CONFIG_CHECK_FAILED=${MUNIN_CONFIG_CHECK_FAILED}" port is not well configured or has other value, set 'port 4949';"
@ -46,4 +54,4 @@ case ${?} in
;; ;;
esac esac
fi

View file

@ -3,14 +3,23 @@ print_config_title 'CHECK NRPE BASIC CONFIG'
# Check /etc/nagios/nrpe.cfg config file, checked parameters : allowed_hosts/nrpe_user/nrpe_group # Check /etc/nagios/nrpe.cfg config file, checked parameters : allowed_hosts/nrpe_user/nrpe_group
# This does not check if NRPE 'monitoring server' has configured this machine # This does not check if NRPE 'monitoring server' has configured this machine
conf_file_to_test="/etc/nagios/nrpe.cfg"
# 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"
NRPE_CONFIG_CHECK_FAILED=${NRPE_CONFIG_CHECK_FAILED}" Error, file ${conf_file_to_test} not found;"
else
# allowed_hosts # allowed_hosts
check_value_in_conf_file "NRPE" "/etc/nagios/nrpe.cfg" "allowed_hosts" "127.0.0.1,[[:space:]]*${IPV4_ADMIN_NETWORK}0/24,[[:space:]]*${IPV6_ADMIN_NETWORK}:/64" check_value_in_conf_file "NRPE" "${conf_file_to_test}" "allowed_hosts" "127.0.0.1,[[:space:]]*${IPV4_ADMIN_NETWORK}0/24,[[:space:]]*${IPV6_ADMIN_NETWORK}:/64"
case ${?} in case ${?} in
0) # OK, nothing to do 0) # OK, nothing to do
;; ;;
1) # Error (wrong number of param or other) 1) # Error (wrong number of param or other)
NRPE_CONFIG_CHECK_FAILED=${NRPE_CONFIG_CHECK_FAILED}" Error during allowed_hosts check with function check_value_in_conf_file, maybe incorrect number of parameter;" NRPE_CONFIG_CHECK_FAILED=${NRPE_CONFIG_CHECK_FAILED}" Error during allowed_hosts check with function check_value_in_conf_file, maybe incorrect number of parameter or file not found;"
;; ;;
2) # Unexpected value is set 2) # Unexpected value is set
NRPE_CONFIG_CHECK_FAILED=${NRPE_CONFIG_CHECK_FAILED}" allowed_hosts are not well configured or has other value, set 'allowed_hosts=127.0.0.1, ${IPV4_ADMIN_NETWORK}0/24, ${IPV6_ADMIN_NETWORK}:/64';" NRPE_CONFIG_CHECK_FAILED=${NRPE_CONFIG_CHECK_FAILED}" allowed_hosts are not well configured or has other value, set 'allowed_hosts=127.0.0.1, ${IPV4_ADMIN_NETWORK}0/24, ${IPV6_ADMIN_NETWORK}:/64';"
@ -25,13 +34,13 @@ esac
# nrpe_user # nrpe_user
check_value_in_conf_file "NRPE" "/etc/nagios/nrpe.cfg" "nrpe_user" "nagios" check_value_in_conf_file "NRPE" "${conf_file_to_test}" "nrpe_user" "nagios"
case ${?} in case ${?} in
0) # OK, nothing to do 0) # OK, nothing to do
;; ;;
1) # Error (wrong number of param or other) 1) # Error (wrong number of param or other)
NRPE_CONFIG_CHECK_FAILED=${NRPE_CONFIG_CHECK_FAILED}" Error during nrpe_user check with function check_value_in_conf_file, maybe incorrect number of parameter;" NRPE_CONFIG_CHECK_FAILED=${NRPE_CONFIG_CHECK_FAILED}" Error during nrpe_user check with function check_value_in_conf_file, maybe incorrect number of parameter or file not found;"
;; ;;
2) # Unexpected value is set 2) # Unexpected value is set
NRPE_CONFIG_CHECK_FAILED=${NRPE_CONFIG_CHECK_FAILED}" nrpe_user is not well configured or has other value, set 'nrpe_user=nagios';" NRPE_CONFIG_CHECK_FAILED=${NRPE_CONFIG_CHECK_FAILED}" nrpe_user is not well configured or has other value, set 'nrpe_user=nagios';"
@ -46,13 +55,13 @@ esac
# nrpe_group # nrpe_group
check_value_in_conf_file "NRPE" "/etc/nagios/nrpe.cfg" "nrpe_group" "nagios" check_value_in_conf_file "NRPE" "${conf_file_to_test}" "nrpe_group" "nagios"
case ${?} in case ${?} in
0) # OK, nothing to do 0) # OK, nothing to do
;; ;;
1) # Error (wrong number of param or other) 1) # Error (wrong number of param or other)
NRPE_CONFIG_CHECK_FAILED=${NRPE_CONFIG_CHECK_FAILED}" Error during nrpe_group check with function check_value_in_conf_file, maybe incorrect number of parameter;" NRPE_CONFIG_CHECK_FAILED=${NRPE_CONFIG_CHECK_FAILED}" Error during nrpe_group check with function check_value_in_conf_file, maybe incorrect number of parameter or file not found;"
;; ;;
2) # Unexpected value is set 2) # Unexpected value is set
NRPE_CONFIG_CHECK_FAILED=${NRPE_CONFIG_CHECK_FAILED}" nrpe_group is not well configured or has other value, set 'nrpe_group=nagios';" NRPE_CONFIG_CHECK_FAILED=${NRPE_CONFIG_CHECK_FAILED}" nrpe_group is not well configured or has other value, set 'nrpe_group=nagios';"
@ -64,4 +73,4 @@ case ${?} in
NRPE_CONFIG_CHECK_FAILED=${NRPE_CONFIG_CHECK_FAILED}" Error, unknown return code when calling check_value_in_conf_file to check nrpe_group;" NRPE_CONFIG_CHECK_FAILED=${NRPE_CONFIG_CHECK_FAILED}" Error, unknown return code when calling check_value_in_conf_file to check nrpe_group;"
;; ;;
esac esac
fi

View file

@ -1,8 +1,18 @@
print_config_title 'CHECK PORTAGE CONFIG' print_config_title 'CHECK PORTAGE CONFIG'
conf_file_to_test="/etc/portage/make.conf"
# 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"
PORTAGE_CONFIG_CHECK_FAILED=${PORTAGE_CONFIG_CHECK_FAILED}" Error, file ${conf_file_to_test} not found;"
else
# Check if make.conf includes FEATURES="getbinpkg" # Check if make.conf includes FEATURES="getbinpkg"
echo "Check if /etc/portage/make.conf includes FEATURES=\"getbinpkg\"" echo "Check if ${conf_file_to_test} includes FEATURES=\"getbinpkg\""
grep -q "^[[:space:]]*FEATURES=\"getbinpkg\"[[:space:]]*$" /etc/portage/make.conf grep -q "^[[:space:]]*FEATURES=\"getbinpkg\"[[:space:]]*$" ${conf_file_to_test}
# Return Code # Return Code
RC=$? RC=$?
@ -10,26 +20,26 @@ RC=$?
# Portage conf does NOT include getbinpkg FEATURE # Portage conf does NOT include getbinpkg FEATURE
if [ $RC -ne 0 ] if [ $RC -ne 0 ]
then then
PORTAGE_CONFIG_CHECK_FAILED="${PORTAGE_CONFIG_CHECK_FAILED} Portage binpkg feature not configured, add FEATURES=\"getbinpkg\" in /etc/portage/make.conf ;" PORTAGE_CONFIG_CHECK_FAILED="${PORTAGE_CONFIG_CHECK_FAILED} Portage binpkg feature not configured, add FEATURES=\"getbinpkg\" in ${conf_file_to_test} ;"
echo -e "${RED}Portage getbinpkg feature is NOT CONFIGURED in /etc/portage/make.conf : check KO${NC}\n" echo -e "${RED}Portage getbinpkg feature is NOT CONFIGURED in ${conf_file_to_test} : check KO${NC}\n"
# Portage conf includes getbinpkg FEATURE # Portage conf includes getbinpkg FEATURE
else else
# If there are multiple definitions of FEATURE variable, KO # If there are multiple definitions of FEATURE variable, KO
FEATURE_DEFINITION_NUMBER="$(grep \"^[[:space:]]*FEATURES\" /etc/portage/make.conf | wc -l)" FEATURE_DEFINITION_NUMBER="$(grep \"^[[:space:]]*FEATURES\" ${conf_file_to_test} | wc -l)"
if [ "${FEATURE_DEFINITION_NUMBER}" -gt "1" ] if [ "${FEATURE_DEFINITION_NUMBER}" -gt "1" ]
then then
PORTAGE_CONFIG_CHECK_FAILED="${PORTAGE_CONFIG_CHECK_FAILED} Multiple definitions of FEATURE variable in /etc/portage/make.conf, define the variable FEATURE only once in /etc/portage/make.conf ;" PORTAGE_CONFIG_CHECK_FAILED="${PORTAGE_CONFIG_CHECK_FAILED} Multiple definitions of FEATURE variable in ${conf_file_to_test}, define the variable FEATURE only once in ${conf_file_to_test} ;"
echo -e "${RED}Multiple definitions of FEATURE variable in /etc/portage/make.conf : check KO${NC}\n" echo -e "${RED}Multiple definitions of FEATURE variable in ${conf_file_to_test} : check KO${NC}\n"
# Else it's OK # Else it's OK
else else
echo -e "${GREEN}Portage getbinpkg feature CONFIGURED in /etc/portage/make.conf : check OK${NC}\n" echo -e "${GREEN}Portage getbinpkg feature CONFIGURED in ${conf_file_to_test} : check OK${NC}\n"
fi fi
fi fi
# Check if make.conf includes well configured PORTAGE_BINHOST # Check if make.conf includes well configured PORTAGE_BINHOST
echo "Check if /etc/portage/make.conf includes well configured PORTAGE_BINHOST" echo "Check if ${conf_file_to_test} includes well configured PORTAGE_BINHOST"
grep -q "^[[:space:]]*PORTAGE_BINHOST=\"${BINPKGREPO}\"[[:space:]]*$" /etc/portage/make.conf grep -q "^[[:space:]]*PORTAGE_BINHOST=\"${BINPKGREPO}\"[[:space:]]*$" ${conf_file_to_test}
# Return Code # Return Code
RC=$? RC=$?
@ -37,26 +47,26 @@ RC=$?
# Portage PORTAGE_BINHOST NOT well CONFIGURED # Portage PORTAGE_BINHOST NOT well CONFIGURED
if [ $RC -ne 0 ] if [ $RC -ne 0 ]
then then
PORTAGE_CONFIG_CHECK_FAILED="${PORTAGE_CONFIG_CHECK_FAILED} Portage PORTAGE_BINHOST not configured, add PORTAGE_BINHOST=\"${BINPKGREPO}\" in /etc/portage/make.conf ;" PORTAGE_CONFIG_CHECK_FAILED="${PORTAGE_CONFIG_CHECK_FAILED} Portage PORTAGE_BINHOST not configured, add PORTAGE_BINHOST=\"${BINPKGREPO}\" in ${conf_file_to_test} ;"
echo -e "${RED}Portage PORTAGE_BINHOST is NOT well CONFIGURED in /etc/portage/make.conf : check KO${NC}\n" echo -e "${RED}Portage PORTAGE_BINHOST is NOT well CONFIGURED in ${conf_file_to_test} : check KO${NC}\n"
# Portage PORTAGE_BINHOST well CONFIGURED # Portage PORTAGE_BINHOST well CONFIGURED
else else
# If there are multiple definitions of PORTAGE_BINHOST variable, KO # If there are multiple definitions of PORTAGE_BINHOST variable, KO
PORTAGE_BINHOST_DEFINITION_NUMBER="$(grep "^[[:space:]]*PORTAGE_BINHOST" /etc/portage/make.conf | wc -l)" PORTAGE_BINHOST_DEFINITION_NUMBER="$(grep "^[[:space:]]*PORTAGE_BINHOST" ${conf_file_to_test} | wc -l)"
if [ "${PORTAGE_BINHOST_DEFINITION_NUMBER}" -gt "1" ] if [ "${PORTAGE_BINHOST_DEFINITION_NUMBER}" -gt "1" ]
then then
PORTAGE_CONFIG_CHECK_FAILED="${PORTAGE_CONFIG_CHECK_FAILED} Multiple definitions of PORTAGE_BINHOST variable in /etc/portage/make.conf, define the variable PORTAGE_BINHOST only once in /etc/portage/make.conf ;" PORTAGE_CONFIG_CHECK_FAILED="${PORTAGE_CONFIG_CHECK_FAILED} Multiple definitions of PORTAGE_BINHOST variable in ${conf_file_to_test}, define the variable PORTAGE_BINHOST only once in ${conf_file_to_test} ;"
echo -e "${RED}Multiple definitions of PORTAGE_BINHOST variable in /etc/portage/make.conf : check KO${NC}\n" echo -e "${RED}Multiple definitions of PORTAGE_BINHOST variable in ${conf_file_to_test} : check KO${NC}\n"
# Else it's OK # Else it's OK
else else
echo -e "${GREEN}Portage PORTAGE_BINHOST variable well CONFIGURED in /etc/portage/make.conf : check OK${NC}\n" echo -e "${GREEN}Portage PORTAGE_BINHOST variable well CONFIGURED in ${conf_file_to_test} : check OK${NC}\n"
fi fi
fi fi
# Check if make.conf includes well configured ACCEPT_LICENSE # Check if make.conf includes well configured ACCEPT_LICENSE
echo "Check if /etc/portage/make.conf includes well configured ACCEPT_LICENSE" echo "Check if ${conf_file_to_test} includes well configured ACCEPT_LICENSE"
grep -q "^[[:space:]]*ACCEPT_LICENSE=\"${PORTAGE_ACCEPTLICENSE}\"[[:space:]]*$" /etc/portage/make.conf grep -q "^[[:space:]]*ACCEPT_LICENSE=\"${PORTAGE_ACCEPTLICENSE}\"[[:space:]]*$" ${conf_file_to_test}
# Return Code # Return Code
RC=$? RC=$?
@ -64,54 +74,54 @@ RC=$?
# Portage ACCEPT_LICENSE NOT well CONFIGURED # Portage ACCEPT_LICENSE NOT well CONFIGURED
if [ $RC -ne 0 ] if [ $RC -ne 0 ]
then then
PORTAGE_CONFIG_CHECK_FAILED="${PORTAGE_CONFIG_CHECK_FAILED} Portage ACCEPT_LICENSE not configured, add ACCEPT_LICENSE=\"$(echo ${PORTAGE_ACCEPTLICENSE} | tr -d '\\')\" in /etc/portage/make.conf ;" PORTAGE_CONFIG_CHECK_FAILED="${PORTAGE_CONFIG_CHECK_FAILED} Portage ACCEPT_LICENSE not configured, add ACCEPT_LICENSE=\"$(echo ${PORTAGE_ACCEPTLICENSE} | tr -d '\\')\" in ${conf_file_to_test} ;"
echo -e "${RED}Portage ACCEPT_LICENSE feature is NOT well CONFIGURED in /etc/portage/make.conf : check KO${NC}\n" echo -e "${RED}Portage ACCEPT_LICENSE feature is NOT well CONFIGURED in ${conf_file_to_test} : check KO${NC}\n"
# Portage ACCEPT_LICENSE well CONFIGURED # Portage ACCEPT_LICENSE well CONFIGURED
else else
# If there are multiple definitions of ACCEPT_LICENSE variable, KO # If there are multiple definitions of ACCEPT_LICENSE variable, KO
ACCEPT_LICENSE_DEFINITION_NUMBER="$(grep "^[[:space:]]*ACCEPT_LICENSE" /etc/portage/make.conf | wc -l)" ACCEPT_LICENSE_DEFINITION_NUMBER="$(grep "^[[:space:]]*ACCEPT_LICENSE" ${conf_file_to_test} | wc -l)"
if [ "${ACCEPT_LICENSE_DEFINITION_NUMBER}" -gt "1" ] if [ "${ACCEPT_LICENSE_DEFINITION_NUMBER}" -gt "1" ]
then then
PORTAGE_CONFIG_CHECK_FAILED="${PORTAGE_CONFIG_CHECK_FAILED} Multiple definitions of ACCEPT_LICENSE variable in /etc/portage/make.conf, define the variable ACCEPT_LICENSE only once in /etc/portage/make.conf ;" PORTAGE_CONFIG_CHECK_FAILED="${PORTAGE_CONFIG_CHECK_FAILED} Multiple definitions of ACCEPT_LICENSE variable in ${conf_file_to_test}, define the variable ACCEPT_LICENSE only once in ${conf_file_to_test} ;"
echo -e "${RED}Multiple definitions of ACCEPT_LICENSE variable in /etc/portage/make.conf : check KO${NC}\n" echo -e "${RED}Multiple definitions of ACCEPT_LICENSE variable in ${conf_file_to_test} : check KO${NC}\n"
# Else it's OK # Else it's OK
else else
echo -e "${GREEN}Portage ACCEPT_LICENSE variable well CONFIGURED in /etc/portage/make.conf : check OK${NC}\n" echo -e "${GREEN}Portage ACCEPT_LICENSE variable well CONFIGURED in ${conf_file_to_test} : check OK${NC}\n"
fi fi
fi fi
# Check if global USE flags is well configured in /etc/portage/make.conf # Check if global USE flags is well configured in ${conf_file_to_test}
echo "Check if global USE flags is well configured in /etc/portage/make.conf" echo "Check if global USE flags is well configured in ${conf_file_to_test}"
# Check if USE variable has multiple definiton # Check if USE variable has multiple definiton
USE_DEFINITION_NUMBER="$(grep "^[[:space:]]*USE" /etc/portage/make.conf | wc -l)" USE_DEFINITION_NUMBER="$(grep "^[[:space:]]*USE" ${conf_file_to_test} | wc -l)"
# If there is only one definition, it's OK # If there is only one definition, it's OK
if [ "${USE_DEFINITION_NUMBER}" -eq "1" ] if [ "${USE_DEFINITION_NUMBER}" -eq "1" ]
then then
# Get actual global USE flags in /etc/portage/make.conf and format to compare # Get actual global USE flags in ${conf_file_to_test} and format to compare
ACTUAL_PORTAGE_USE="$(sed -n '/^[[:space:]]*USE=\"/,/\"/p' /etc/portage/make.conf | tr -d '\n' | cut -d'"' -f2 | sed 's/ /\n/g' | sort | tr '\n' ' ' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" ACTUAL_PORTAGE_USE="$(sed -n '/^[[:space:]]*USE=\"/,/\"/p' ${conf_file_to_test} | tr -d '\n' | cut -d'"' -f2 | sed 's/ /\n/g' | sort | tr '\n' ' ' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
PORTAGE_USE_SORTED="$(echo ${PORTAGE_USE} | sed 's/ /\n/g' | sort | tr '\n' ' ' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" PORTAGE_USE_SORTED="$(echo ${PORTAGE_USE} | sed 's/ /\n/g' | sort | tr '\n' ' ' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
# Global USE flags in /etc/portage/make.conf is well configured # Global USE flags in ${conf_file_to_test} is well configured
if [ "$ACTUAL_PORTAGE_USE" == "$PORTAGE_USE_SORTED" ] if [ "$ACTUAL_PORTAGE_USE" == "$PORTAGE_USE_SORTED" ]
then then
echo -e "${GREEN}Global USE flags in /etc/portage/make.conf is well configured : check OK${NC}\n" echo -e "${GREEN}Global USE flags in ${conf_file_to_test} is well configured : check OK${NC}\n"
# Global USE flags in /etc/portage/make.conf is NOT well configured # Global USE flags in ${conf_file_to_test} is NOT well configured
else else
PORTAGE_CONFIG_CHECK_FAILED="${PORTAGE_CONFIG_CHECK_FAILED} Global USE flags in /etc/portage/make.conf is NOT well CONFIGURED, set USE=\"${PORTAGE_USE_SORTED}\" in /etc/portage/make.conf ;" PORTAGE_CONFIG_CHECK_FAILED="${PORTAGE_CONFIG_CHECK_FAILED} Global USE flags in ${conf_file_to_test} is NOT well CONFIGURED, set USE=\"${PORTAGE_USE_SORTED}\" in ${conf_file_to_test} ;"
echo -e "${RED}Global USE flags in /etc/portage/make.conf is NOT well CONFIGURED : check KO${NC}\n" echo -e "${RED}Global USE flags in ${conf_file_to_test} is NOT well CONFIGURED : check KO${NC}\n"
fi fi
else else
PORTAGE_CONFIG_CHECK_FAILED="${PORTAGE_CONFIG_CHECK_FAILED} Global USE flags in /etc/portage/make.conf has multiple definitions OR there is NO USE variable, define USE variable and only once in /etc/portage/make.conf ;" PORTAGE_CONFIG_CHECK_FAILED="${PORTAGE_CONFIG_CHECK_FAILED} Global USE flags in ${conf_file_to_test} has multiple definitions OR there is NO USE variable, define USE variable and only once in ${conf_file_to_test} ;"
echo -e "${RED}Global USE flags in /etc/portage/make.conf has multiple definitions OR USE variable is not defined : check KO${NC}\n" echo -e "${RED}Global USE flags in ${conf_file_to_test} has multiple definitions OR USE variable is not defined : check KO${NC}\n"
fi fi
# Check if make.conf includes well configured CHOST # Check if make.conf includes well configured CHOST
echo "Check if /etc/portage/make.conf includes well configured CHOST" echo "Check if ${conf_file_to_test} includes well configured CHOST"
grep -q "^[[:space:]]*CHOST=\"${PORTAGE_CHOST}\"[[:space:]]*$" /etc/portage/make.conf grep -q "^[[:space:]]*CHOST=\"${PORTAGE_CHOST}\"[[:space:]]*$" ${conf_file_to_test}
# Return Code # Return Code
RC=$? RC=$?
@ -119,26 +129,26 @@ RC=$?
# Portage CHOST NOT well CONFIGURED # Portage CHOST NOT well CONFIGURED
if [ $RC -ne 0 ] if [ $RC -ne 0 ]
then then
PORTAGE_CONFIG_CHECK_FAILED="${PORTAGE_CONFIG_CHECK_FAILED} Portage CHOST not configured, add CHOST=\"${PORTAGE_CHOST}\" in /etc/portage/make.conf ;" PORTAGE_CONFIG_CHECK_FAILED="${PORTAGE_CONFIG_CHECK_FAILED} Portage CHOST not configured, add CHOST=\"${PORTAGE_CHOST}\" in ${conf_file_to_test} ;"
echo -e "${RED}Portage CHOST feature is NOT well CONFIGURED in /etc/portage/make.conf : check KO${NC}\n" echo -e "${RED}Portage CHOST feature is NOT well CONFIGURED in ${conf_file_to_test} : check KO${NC}\n"
# Portage CHOST well CONFIGURED # Portage CHOST well CONFIGURED
else else
# If there are multiple definitions of CHOST variable, KO # If there are multiple definitions of CHOST variable, KO
CHOST_DEFINITION_NUMBER="$(grep "^[[:space:]]*CHOST" /etc/portage/make.conf | wc -l)" CHOST_DEFINITION_NUMBER="$(grep "^[[:space:]]*CHOST" ${conf_file_to_test} | wc -l)"
if [ "${CHOST_DEFINITION_NUMBER}" -gt "1" ] if [ "${CHOST_DEFINITION_NUMBER}" -gt "1" ]
then then
PORTAGE_CONFIG_CHECK_FAILED="${PORTAGE_CONFIG_CHECK_FAILED} Multiple definitions of CHOST variable in /etc/portage/make.conf, define the variable CHOST only once in /etc/portage/make.conf ;" PORTAGE_CONFIG_CHECK_FAILED="${PORTAGE_CONFIG_CHECK_FAILED} Multiple definitions of CHOST variable in ${conf_file_to_test}, define the variable CHOST only once in ${conf_file_to_test} ;"
echo -e "${RED}Multiple definitions of CHOST variable in /etc/portage/make.conf : check KO${NC}\n" echo -e "${RED}Multiple definitions of CHOST variable in ${conf_file_to_test} : check KO${NC}\n"
# Else it's OK # Else it's OK
else else
echo -e "${GREEN}Portage CHOST variable well CONFIGURED in /etc/portage/make.conf : check OK${NC}\n" echo -e "${GREEN}Portage CHOST variable well CONFIGURED in ${conf_file_to_test} : check OK${NC}\n"
fi fi
fi fi
# Check if make.conf includes well configured GRUB_PLATFORMS # Check if make.conf includes well configured GRUB_PLATFORMS
echo "Check if /etc/portage/make.conf includes well configured GRUB_PLATFORMS" echo "Check if ${conf_file_to_test} includes well configured GRUB_PLATFORMS"
grep -q "^[[:space:]]*GRUB_PLATFORMS=\"${PORTAGE_GRUB_PLATFORMS}\"[[:space:]]*$" /etc/portage/make.conf grep -q "^[[:space:]]*GRUB_PLATFORMS=\"${PORTAGE_GRUB_PLATFORMS}\"[[:space:]]*$" ${conf_file_to_test}
# Return Code # Return Code
RC=$? RC=$?
@ -146,77 +156,78 @@ RC=$?
# Portage GRUB_PLATFORMS NOT well CONFIGURED # Portage GRUB_PLATFORMS NOT well CONFIGURED
if [ $RC -ne 0 ] if [ $RC -ne 0 ]
then then
PORTAGE_CONFIG_CHECK_FAILED="${PORTAGE_CONFIG_CHECK_FAILED} Portage CHOST not configured, add GRUB_PLATFORMS=\"${PORTAGE_GRUB_PLATFORMS}\" in /etc/portage/make.conf ;" PORTAGE_CONFIG_CHECK_FAILED="${PORTAGE_CONFIG_CHECK_FAILED} Portage CHOST not configured, add GRUB_PLATFORMS=\"${PORTAGE_GRUB_PLATFORMS}\" in ${conf_file_to_test} ;"
echo -e "${RED}Portage GRUB_PLATFORMS feature is NOT well CONFIGURED in /etc/portage/make.conf : check KO${NC}\n" echo -e "${RED}Portage GRUB_PLATFORMS feature is NOT well CONFIGURED in ${conf_file_to_test} : check KO${NC}\n"
# Portage GRUB_PLATFORMS well CONFIGURED # Portage GRUB_PLATFORMS well CONFIGURED
else else
# If there are multiple definitions of CHOST variable, KO # If there are multiple definitions of CHOST variable, KO
GRUB_PLATFORMS_DEFINITION_NUMBER="$(grep "^[[:space:]]*GRUB_PLATFORMS" /etc/portage/make.conf | wc -l)" GRUB_PLATFORMS_DEFINITION_NUMBER="$(grep "^[[:space:]]*GRUB_PLATFORMS" ${conf_file_to_test} | wc -l)"
if [ "${GRUB_PLATFORMS_DEFINITION_NUMBER}" -gt "1" ] if [ "${GRUB_PLATFORMS_DEFINITION_NUMBER}" -gt "1" ]
then then
PORTAGE_CONFIG_CHECK_FAILED="${PORTAGE_CONFIG_CHECK_FAILED} Multiple definitions of GRUB_PLATFORMS variable in /etc/portage/make.conf, define the variable GRUB_PLATFORMS only once in /etc/portage/make.conf ;" PORTAGE_CONFIG_CHECK_FAILED="${PORTAGE_CONFIG_CHECK_FAILED} Multiple definitions of GRUB_PLATFORMS variable in ${conf_file_to_test}, define the variable GRUB_PLATFORMS only once in ${conf_file_to_test} ;"
echo -e "${RED}Multiple definitions of GRUB_PLATFORMS variable in /etc/portage/make.conf : check KO${NC}\n" echo -e "${RED}Multiple definitions of GRUB_PLATFORMS variable in ${conf_file_to_test} : check KO${NC}\n"
# Else it's OK # Else it's OK
else else
echo -e "${GREEN}Portage GRUB_PLATFORMS variable well CONFIGURED in /etc/portage/make.conf : check OK${NC}\n" echo -e "${GREEN}Portage GRUB_PLATFORMS variable well CONFIGURED in ${conf_file_to_test} : check OK${NC}\n"
fi fi
fi fi
# Check if portage organization mirror is configured in /etc/portage/make.conf # Check if portage organization mirror is configured in ${conf_file_to_test}
echo "Check if portage oragnization mirror is configured in /etc/portage/make.conf" echo "Check if portage oragnization mirror is configured in ${conf_file_to_test}"
# Check if GENTOO_MIRRORS variable has multiple definiton # Check if GENTOO_MIRRORS variable has multiple definiton
GENTOO_MIRRORS_DEFINITION_NUMBER="$(grep "^[[:space:]]*GENTOO_MIRRORS" /etc/portage/make.conf | wc -l)" GENTOO_MIRRORS_DEFINITION_NUMBER="$(grep "^[[:space:]]*GENTOO_MIRRORS" ${conf_file_to_test} | wc -l)"
# If there is only one definition, it's OK # If there is only one definition, it's OK
if [ "${GENTOO_MIRRORS_DEFINITION_NUMBER}" -eq "1" ] if [ "${GENTOO_MIRRORS_DEFINITION_NUMBER}" -eq "1" ]
then then
# Check if GENTOO_MIRRORS value in /etc/portage/make.conf includes organization mirror # Check if GENTOO_MIRRORS value in ${conf_file_to_test} includes organization mirror
sed -n '/^[[:space:]]*GENTOO_MIRRORS=\"/,/\"/p' /etc/portage/make.conf | grep -q "${PORTAGE_ORGANIZATION_MIRROR}" sed -n '/^[[:space:]]*GENTOO_MIRRORS=\"/,/\"/p' ${conf_file_to_test} | grep -q "${PORTAGE_ORGANIZATION_MIRROR}"
# Return Code # Return Code
RC=$? RC=$?
# GENTOO_MIRRORS in /etc/portage/make.conf includes organization mirror # GENTOO_MIRRORS in ${conf_file_to_test} includes organization mirror
if [ $RC -eq 0 ] if [ $RC -eq 0 ]
then then
echo -e "${GREEN}GENTOO_MIRRORS in /etc/portage/make.conf includes organization mirror : check OK${NC}\n" echo -e "${GREEN}GENTOO_MIRRORS in ${conf_file_to_test} includes organization mirror : check OK${NC}\n"
# GENTOO_MIRRORS in /etc/portage/make.conf does NOT includes organization mirror # GENTOO_MIRRORS in ${conf_file_to_test} does NOT includes organization mirror
else else
PORTAGE_CONFIG_CHECK_FAILED="${PORTAGE_CONFIG_CHECK_FAILED} GENTOO_MIRRORS in /etc/portage/make.conf does NOT includes organization mirror, add ${PORTAGE_ORGANIZATION_MIRROR} mirror in GENTOO_MIRRORS variable in /etc/portage/make.conf ;" PORTAGE_CONFIG_CHECK_FAILED="${PORTAGE_CONFIG_CHECK_FAILED} GENTOO_MIRRORS in ${conf_file_to_test} does NOT includes organization mirror, add ${PORTAGE_ORGANIZATION_MIRROR} mirror in GENTOO_MIRRORS variable in ${conf_file_to_test} ;"
echo -e "${RED}GENTOO_MIRRORS in /etc/portage/make.conf does NOT includes organization mirror : check KO${NC}\n" echo -e "${RED}GENTOO_MIRRORS in ${conf_file_to_test} does NOT includes organization mirror : check KO${NC}\n"
fi fi
else else
PORTAGE_CONFIG_CHECK_FAILED="${PORTAGE_CONFIG_CHECK_FAILED} GENTOO_MIRRORS in /etc/portage/make.conf has multiple definitions OR there is NO GENTOO_MIRRORS variable, define GENTOO_MIRRORS variable and only once in /etc/portage/make.conf ;" PORTAGE_CONFIG_CHECK_FAILED="${PORTAGE_CONFIG_CHECK_FAILED} GENTOO_MIRRORS in ${conf_file_to_test} has multiple definitions OR there is NO GENTOO_MIRRORS variable, define GENTOO_MIRRORS variable and only once in ${conf_file_to_test} ;"
echo -e "${RED}GENTOO_MIRRORS in /etc/portage/make.conf has multiple definitions OR GENTOO_MIRRORS variable is not defined : check KO${NC}\n" echo -e "${RED}GENTOO_MIRRORS in ${conf_file_to_test} has multiple definitions OR GENTOO_MIRRORS variable is not defined : check KO${NC}\n"
fi fi
# Check if global CPU_FLAGS_X86 flags is well configured in /etc/portage/make.conf # Check if global CPU_FLAGS_X86 flags is well configured in ${conf_file_to_test}
echo "Check if global CPU_FLAGS_X86 flags is well configured in /etc/portage/make.conf" echo "Check if global CPU_FLAGS_X86 flags is well configured in ${conf_file_to_test}"
# Check if CPU_FLAGS_X86 variable has multiple definiton # Check if CPU_FLAGS_X86 variable has multiple definiton
CPU_FLAGS_X86_DEFINITION_NUMBER="$(grep "^[[:space:]]*CPU_FLAGS_X86" /etc/portage/make.conf | wc -l)" CPU_FLAGS_X86_DEFINITION_NUMBER="$(grep "^[[:space:]]*CPU_FLAGS_X86" ${conf_file_to_test} | wc -l)"
# If there is only one definition, it's OK # If there is only one definition, it's OK
if [ "${CPU_FLAGS_X86_DEFINITION_NUMBER}" -eq "1" ] if [ "${CPU_FLAGS_X86_DEFINITION_NUMBER}" -eq "1" ]
then then
# Get actual global CPU_FLAGS_X86 flags in /etc/portage/make.conf and format to compare # Get actual global CPU_FLAGS_X86 flags in ${conf_file_to_test} and format to compare
ACTUAL_PORTAGE_CPU_FLAGS_X86="$(sed -n '/^[[:space:]]*CPU_FLAGS_X86=\"/,/\"/p' /etc/portage/make.conf | tr -d '\n' | cut -d'"' -f2 | sed 's/ /\n/g' | sort | tr '\n' ' ' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" ACTUAL_PORTAGE_CPU_FLAGS_X86="$(sed -n '/^[[:space:]]*CPU_FLAGS_X86=\"/,/\"/p' ${conf_file_to_test} | tr -d '\n' | cut -d'"' -f2 | sed 's/ /\n/g' | sort | tr '\n' ' ' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
PORTAGE_CPU_FLAGS_X86_SORTED="$(echo ${PORTAGE_CPU_FLAGS_X86} | sed 's/ /\n/g' | sort | tr '\n' ' ' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" PORTAGE_CPU_FLAGS_X86_SORTED="$(echo ${PORTAGE_CPU_FLAGS_X86} | sed 's/ /\n/g' | sort | tr '\n' ' ' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
# Global CPU_FLAGS_X86 flags in /etc/portage/make.conf is well configured # Global CPU_FLAGS_X86 flags in ${conf_file_to_test} is well configured
if [ "$ACTUAL_PORTAGE_CPU_FLAGS_X86" == "$PORTAGE_CPU_FLAGS_X86_SORTED" ] if [ "$ACTUAL_PORTAGE_CPU_FLAGS_X86" == "$PORTAGE_CPU_FLAGS_X86_SORTED" ]
then then
echo -e "${GREEN}Global CPU_FLAGS_X86 flags in /etc/portage/make.conf is well configured : check OK${NC}\n" echo -e "${GREEN}Global CPU_FLAGS_X86 flags in ${conf_file_to_test} is well configured : check OK${NC}\n"
# Global CPU_FLAGS_X86 flags in /etc/portage/make.conf is NOT well configured # Global CPU_FLAGS_X86 flags in ${conf_file_to_test} is NOT well configured
else else
PORTAGE_CONFIG_CHECK_FAILED="${PORTAGE_CONFIG_CHECK_FAILED} Global CPU_FLAGS_X86 flags in /etc/portage/make.conf is NOT well CONFIGURED, set CPU_FLAGS_X86=\"${PORTAGE_CPU_FLAGS_X86_SORTED}\" in /etc/portage/make.conf ;" PORTAGE_CONFIG_CHECK_FAILED="${PORTAGE_CONFIG_CHECK_FAILED} Global CPU_FLAGS_X86 flags in ${conf_file_to_test} is NOT well CONFIGURED, set CPU_FLAGS_X86=\"${PORTAGE_CPU_FLAGS_X86_SORTED}\" in ${conf_file_to_test} ;"
echo -e "${RED}Global CPU_FLAGS_X86 flags in /etc/portage/make.conf is NOT well CONFIGURED : check KO${NC}\n" echo -e "${RED}Global CPU_FLAGS_X86 flags in ${conf_file_to_test} is NOT well CONFIGURED : check KO${NC}\n"
fi fi
else else
PORTAGE_CONFIG_CHECK_FAILED="${PORTAGE_CONFIG_CHECK_FAILED} Global CPU_FLAGS_X86 flags in /etc/portage/make.conf has multiple definitions OR there is NO CPU_FLAGS_X86 variable, define CPU_FLAGS_X86 variable and only once in /etc/portage/make.conf ;" PORTAGE_CONFIG_CHECK_FAILED="${PORTAGE_CONFIG_CHECK_FAILED} Global CPU_FLAGS_X86 flags in ${conf_file_to_test} has multiple definitions OR there is NO CPU_FLAGS_X86 variable, define CPU_FLAGS_X86 variable and only once in ${conf_file_to_test} ;"
echo -e "${RED}Global CPU_FLAGS_X86 flags in /etc/portage/make.conf has multiple definitions OR CPU_FLAGS_X86 variable is not defined : check KO${NC}\n" echo -e "${RED}Global CPU_FLAGS_X86 flags in ${conf_file_to_test} has multiple definitions OR CPU_FLAGS_X86 variable is not defined : check KO${NC}\n"
fi
fi fi

View file

@ -2,14 +2,25 @@ print_config_title 'CHECK POSTFIX BASIC CONFIG'
# Check /etc/postfix/main.cf config file mail_owner/inet_protocols parameters # Check /etc/postfix/main.cf config file mail_owner/inet_protocols parameters
conf_file_to_test="/etc/postfix/main.cf"
# 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"
POSTFIX_CONFIG_CHECK_FAILED=${POSTFIX_CONFIG_CHECK_FAILED}" Error, file ${conf_file_to_test} not found;"
else
# mail_owner # mail_owner
check_value_in_conf_file "POSTFIX" "/etc/postfix/main.cf" "mail_owner" "postfix" check_value_in_conf_file "POSTFIX" "${conf_file_to_test}" "mail_owner" "postfix"
case ${?} in case ${?} in
0) # OK, nothing to do 0) # OK, nothing to do
;; ;;
1) # Error (wrong number of param or other) 1) # Error (wrong number of param or other)
POSTFIX_CONFIG_CHECK_FAILED=${POSTFIX_CONFIG_CHECK_FAILED}" Error during mail_owner check with function check_value_in_conf_file, maybe incorrect number of parameter;" POSTFIX_CONFIG_CHECK_FAILED=${POSTFIX_CONFIG_CHECK_FAILED}" Error during mail_owner check with function check_value_in_conf_file, maybe incorrect number of parameter or file not found;"
;; ;;
2) # Unexpected value is set 2) # Unexpected value is set
POSTFIX_CONFIG_CHECK_FAILED=${POSTFIX_CONFIG_CHECK_FAILED}" mail_owner is not well configured or has other value, set 'mail_owner = postfix';" POSTFIX_CONFIG_CHECK_FAILED=${POSTFIX_CONFIG_CHECK_FAILED}" mail_owner is not well configured or has other value, set 'mail_owner = postfix';"
@ -24,13 +35,13 @@ esac
# inet_protocols # inet_protocols
check_value_in_conf_file "POSTFIX" "/etc/postfix/main.cf" "inet_protocols" "all" check_value_in_conf_file "POSTFIX" "${conf_file_to_test}" "inet_protocols" "all"
case ${?} in case ${?} in
0) # OK, nothing to do 0) # OK, nothing to do
;; ;;
1) # Error (wrong number of param or other) 1) # Error (wrong number of param or other)
POSTFIX_CONFIG_CHECK_FAILED=${POSTFIX_CONFIG_CHECK_FAILED}" Error during inet_protocols check with function check_value_in_conf_file, maybe incorrect number of parameter;" POSTFIX_CONFIG_CHECK_FAILED=${POSTFIX_CONFIG_CHECK_FAILED}" Error during inet_protocols check with function check_value_in_conf_file, maybe incorrect number of parameter or file not found;"
;; ;;
2) # Unexpected value is set 2) # Unexpected value is set
POSTFIX_CONFIG_CHECK_FAILED=${POSTFIX_CONFIG_CHECK_FAILED}" inet_protocols are not well configured or has other value, set 'inet_protocols = all';" POSTFIX_CONFIG_CHECK_FAILED=${POSTFIX_CONFIG_CHECK_FAILED}" inet_protocols are not well configured or has other value, set 'inet_protocols = all';"
@ -42,4 +53,4 @@ case ${?} in
POSTFIX_CONFIG_CHECK_FAILED=${POSTFIX_CONFIG_CHECK_FAILED}" Error, unknown return code when calling check_value_in_conf_file to check inet_protocols;" POSTFIX_CONFIG_CHECK_FAILED=${POSTFIX_CONFIG_CHECK_FAILED}" Error, unknown return code when calling check_value_in_conf_file to check inet_protocols;"
;; ;;
esac esac
fi

View file

@ -3,14 +3,23 @@ print_config_title 'CHECK SNMP BASIC CONFIG'
# This does NOT check if SNMP 'monitoring server' has configured this machine # This does NOT check if SNMP 'monitoring server' has configured this machine
# Check /etc/snmp/snmpd.conf config file rocommunity/agentAddress/trap2sink/informsink/sysLocation/sysContact parameters # Check /etc/snmp/snmpd.conf config file rocommunity/agentAddress/trap2sink/informsink/sysLocation/sysContact parameters
conf_file_to_test="/etc/snmp/snmpd.conf"
# 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"
SNMP_CONFIG_CHECK_FAILED=${SNMP_CONFIG_CHECK_FAILED}" Error, file ${conf_file_to_test} not found;"
else
#agentAddress #agentAddress
check_value_in_conf_file "SNMP" "/etc/snmp/snmpd.conf" "agentAddress" "udp:127.0.0.1:161 udp:${IPV4_ADMIN_LAN_IP}:161 udp6:\[::1\]:161 udp6:\[${IPV6_ADMIN_LAN_IP}\]:161" check_value_in_conf_file "SNMP" "${conf_file_to_test}" "agentAddress" "udp:127.0.0.1:161 udp:${IPV4_ADMIN_LAN_IP}:161 udp6:\[::1\]:161 udp6:\[${IPV6_ADMIN_LAN_IP}\]:161"
case ${?} in case ${?} in
0) # OK, nothing to do 0) # OK, nothing to do
;; ;;
1) # Error (wrong number of param or other) 1) # Error (wrong number of param or other)
SNMP_CONFIG_CHECK_FAILED=${SNMP_CONFIG_CHECK_FAILED}" Error during agentAddress check with function check_value_in_conf_file, maybe incorrect number of parameter;" SNMP_CONFIG_CHECK_FAILED=${SNMP_CONFIG_CHECK_FAILED}" Error during agentAddress check with function check_value_in_conf_file, maybe incorrect number of parameter or file not found;"
;; ;;
2) # Unexpected value is set 2) # Unexpected value is set
SNMP_CONFIG_CHECK_FAILED=${SNMP_CONFIG_CHECK_FAILED}" agentAddress are not well configured or has other value, set agentAddress for IPv4 and IPv6 in Admin LAN and localhost;" SNMP_CONFIG_CHECK_FAILED=${SNMP_CONFIG_CHECK_FAILED}" agentAddress are not well configured or has other value, set agentAddress for IPv4 and IPv6 in Admin LAN and localhost;"
@ -26,13 +35,13 @@ esac
#rocommunity #rocommunity
# No IPv6 here.... # No IPv6 here....
check_value_in_conf_file "SNMP" "/etc/snmp/snmpd.conf" "rocommunity" "public[[:space:]]*127.0.0.1 public[[:space:]]*${IPV4_ADMIN_NETWORK}0/24" check_value_in_conf_file "SNMP" "${conf_file_to_test}" "rocommunity" "public[[:space:]]*127.0.0.1 public[[:space:]]*${IPV4_ADMIN_NETWORK}0/24"
case ${?} in case ${?} in
0) # OK, nothing to do 0) # OK, nothing to do
;; ;;
1) # Error (wrong number of param or other) 1) # Error (wrong number of param or other)
SNMP_CONFIG_CHECK_FAILED=${SNMP_CONFIG_CHECK_FAILED}" Error during rocommunity check with function check_value_in_conf_file, maybe incorrect number of parameter;" SNMP_CONFIG_CHECK_FAILED=${SNMP_CONFIG_CHECK_FAILED}" Error during rocommunity check with function check_value_in_conf_file, maybe incorrect number of parameter or file not found;"
;; ;;
2) # Unexpected value is set 2) # Unexpected value is set
SNMP_CONFIG_CHECK_FAILED=${SNMP_CONFIG_CHECK_FAILED}" rocommunity are not well configured or has other value, set 'rocommunity public 127.0.0.1' and 'rocommunity public ${IPV4_ADMIN_NETWORK}0/24';" SNMP_CONFIG_CHECK_FAILED=${SNMP_CONFIG_CHECK_FAILED}" rocommunity are not well configured or has other value, set 'rocommunity public 127.0.0.1' and 'rocommunity public ${IPV4_ADMIN_NETWORK}0/24';"
@ -47,13 +56,13 @@ esac
# trap2sink # trap2sink
check_value_in_conf_file "SNMP" "/etc/snmp/snmpd.conf" "trap2sink" "${NAME_MASTER_MONITORING}[[:space:]]*public" check_value_in_conf_file "SNMP" "${conf_file_to_test}" "trap2sink" "${NAME_MASTER_MONITORING}[[:space:]]*public"
case ${?} in case ${?} in
0) # OK, nothing to do 0) # OK, nothing to do
;; ;;
1) # Error (wrong number of param or other) 1) # Error (wrong number of param or other)
SNMP_CONFIG_CHECK_FAILED=${SNMP_CONFIG_CHECK_FAILED}" Error during trap2sink check with function check_value_in_conf_file, maybe incorrect number of parameter;" SNMP_CONFIG_CHECK_FAILED=${SNMP_CONFIG_CHECK_FAILED}" Error during trap2sink check with function check_value_in_conf_file, maybe incorrect number of parameter or file not found;"
;; ;;
2) # Unexpected value is set 2) # Unexpected value is set
SNMP_CONFIG_CHECK_FAILED=${SNMP_CONFIG_CHECK_FAILED}" trap2sink is not well configured or has other value, set 'trap2sink ${NAME_MASTER_MONITORING} public;" SNMP_CONFIG_CHECK_FAILED=${SNMP_CONFIG_CHECK_FAILED}" trap2sink is not well configured or has other value, set 'trap2sink ${NAME_MASTER_MONITORING} public;"
@ -68,13 +77,13 @@ esac
# informsink # informsink
check_value_in_conf_file "SNMP" "/etc/snmp/snmpd.conf" "informsink" "${NAME_MASTER_MONITORING}[[:space:]]*public" check_value_in_conf_file "SNMP" "${conf_file_to_test}" "informsink" "${NAME_MASTER_MONITORING}[[:space:]]*public"
case ${?} in case ${?} in
0) # OK, nothing to do 0) # OK, nothing to do
;; ;;
1) # Error (wrong number of param or other) 1) # Error (wrong number of param or other)
SNMP_CONFIG_CHECK_FAILED=${SNMP_CONFIG_CHECK_FAILED}" Error during informsink check with function check_value_in_conf_file, maybe incorrect number of parameter;" SNMP_CONFIG_CHECK_FAILED=${SNMP_CONFIG_CHECK_FAILED}" Error during informsink check with function check_value_in_conf_file, maybe incorrect number of parameter or file not found;"
;; ;;
2) # Unexpected value is set 2) # Unexpected value is set
SNMP_CONFIG_CHECK_FAILED=${SNMP_CONFIG_CHECK_FAILED}" informsink is not well configured or has other value, set 'informsink ${NAME_MASTER_MONITORING} public;" SNMP_CONFIG_CHECK_FAILED=${SNMP_CONFIG_CHECK_FAILED}" informsink is not well configured or has other value, set 'informsink ${NAME_MASTER_MONITORING} public;"
@ -89,13 +98,13 @@ esac
# sysLocation # sysLocation
check_value_in_conf_file "SNMP" "/etc/snmp/snmpd.conf" "sysLocation" "${DC_for_function_check_value_in_conf_file}" check_value_in_conf_file "SNMP" "${conf_file_to_test}" "sysLocation" "${DC_for_function_check_value_in_conf_file}"
case ${?} in case ${?} in
0) # OK, nothing to do 0) # OK, nothing to do
;; ;;
1) # Error (wrong number of param or other) 1) # Error (wrong number of param or other)
SNMP_CONFIG_CHECK_FAILED=${SNMP_CONFIG_CHECK_FAILED}" Error during sysLocation check with function check_value_in_conf_file, maybe incorrect number of parameter;" SNMP_CONFIG_CHECK_FAILED=${SNMP_CONFIG_CHECK_FAILED}" Error during sysLocation check with function check_value_in_conf_file, maybe incorrect number of parameter or file not found;"
;; ;;
2) # Unexpected value is set 2) # Unexpected value is set
SNMP_CONFIG_CHECK_FAILED=${SNMP_CONFIG_CHECK_FAILED}" sysLocation is not well configured or has other value, set 'sysLocation ${DC}';" SNMP_CONFIG_CHECK_FAILED=${SNMP_CONFIG_CHECK_FAILED}" sysLocation is not well configured or has other value, set 'sysLocation ${DC}';"
@ -110,13 +119,13 @@ esac
# sysContact # sysContact
check_value_in_conf_file "SNMP" "/etc/snmp/snmpd.conf" "sysContact" "${ENTITY_for_function_check_value_in_conf_file}[[:space:]]*<${MAIL_ALIAS_ROOT}>" check_value_in_conf_file "SNMP" "${conf_file_to_test}" "sysContact" "${ENTITY_for_function_check_value_in_conf_file}[[:space:]]*<${MAIL_ALIAS_ROOT}>"
case ${?} in case ${?} in
0) # OK, nothing to do 0) # OK, nothing to do
;; ;;
1) # Error (wrong number of param or other) 1) # Error (wrong number of param or other)
SNMP_CONFIG_CHECK_FAILED=${SNMP_CONFIG_CHECK_FAILED}" Error during sysContact check with function check_value_in_conf_file, maybe incorrect number of parameter;" SNMP_CONFIG_CHECK_FAILED=${SNMP_CONFIG_CHECK_FAILED}" Error during sysContact check with function check_value_in_conf_file, maybe incorrect number of parameter or file not found;"
;; ;;
2) # Unexpected value is set 2) # Unexpected value is set
SNMP_CONFIG_CHECK_FAILED=${SNMP_CONFIG_CHECK_FAILED}" sysContact is not well configured or has other value, set 'sysContact ${ENTITY} <${MAIL_ALIAS_ROOT}>';" SNMP_CONFIG_CHECK_FAILED=${SNMP_CONFIG_CHECK_FAILED}" sysContact is not well configured or has other value, set 'sysContact ${ENTITY} <${MAIL_ALIAS_ROOT}>';"
@ -128,7 +137,4 @@ case ${?} in
SNMP_CONFIG_CHECK_FAILED=${SNMP_CONFIG_CHECK_FAILED}" Error, unknown return code when calling check_value_in_conf_file to check sysContact;" SNMP_CONFIG_CHECK_FAILED=${SNMP_CONFIG_CHECK_FAILED}" Error, unknown return code when calling check_value_in_conf_file to check sysContact;"
;; ;;
esac esac
fi

View file

@ -1,14 +1,23 @@
print_config_title 'CHECK SSH CONFIG' print_config_title 'CHECK SSH CONFIG'
conf_file_to_test="/etc/snmp/snmpd.conf"
# 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"
SSH_CONFIG_CHECK_FAILED=${SSH_CONFIG_CHECK_FAILED}" Error, file ${conf_file_to_test} not found;"
else
# PasswordAuthentication # PasswordAuthentication
check_value_in_conf_file "SSH" "/etc/ssh/sshd_config" "PasswordAuthentication" "no" check_value_in_conf_file "SSH" "${conf_file_to_test}" "PasswordAuthentication" "no"
case ${?} in case ${?} in
0) # OK, nothing to do 0) # OK, nothing to do
;; ;;
1) # Error (wrong number of param or other) 1) # Error (wrong number of param or other)
SSH_CONFIG_CHECK_FAILED=${SSH_CONFIG_CHECK_FAILED}" Error during PasswordAuthentication with function check_value_in_conf_file, maybe incorrect number of parameter;" SSH_CONFIG_CHECK_FAILED=${SSH_CONFIG_CHECK_FAILED}" Error during PasswordAuthentication with function check_value_in_conf_file, maybe incorrect number of parameter or file not found;"
;; ;;
2) # Unexpected value is set 2) # Unexpected value is set
SSH_CONFIG_CHECK_FAILED=${SSH_CONFIG_CHECK_FAILED}" PasswordAuthentication is not set to 'no' or has other value, set 'PasswordAuthentication no' ;" SSH_CONFIG_CHECK_FAILED=${SSH_CONFIG_CHECK_FAILED}" PasswordAuthentication is not set to 'no' or has other value, set 'PasswordAuthentication no' ;"
@ -23,13 +32,13 @@ esac
# PermitRootLogin # PermitRootLogin
check_value_in_conf_file "SSH" "/etc/ssh/sshd_config" "PermitRootLogin" "no" check_value_in_conf_file "SSH" "${conf_file_to_test}" "PermitRootLogin" "no"
case ${?} in case ${?} in
0) # OK, nothing to do 0) # OK, nothing to do
;; ;;
1) # Error (wrong number of param or other) 1) # Error (wrong number of param or other)
SSH_CONFIG_CHECK_FAILED=${SSH_CONFIG_CHECK_FAILED}" Error during PermitRootLogin with function check_value_in_conf_file, maybe incorrect number of parameter or incorrect parameter;" SSH_CONFIG_CHECK_FAILED=${SSH_CONFIG_CHECK_FAILED}" Error during PermitRootLogin with function check_value_in_conf_file, maybe incorrect number of parameter or incorrect parameter or file not found;"
;; ;;
2) # Unexpected value is set 2) # Unexpected value is set
SSH_CONFIG_CHECK_FAILED=${SSH_CONFIG_CHECK_FAILED}" PermitRootLogin is not set to 'no' or has other value, set 'PermitRootLogin no' ;" SSH_CONFIG_CHECK_FAILED=${SSH_CONFIG_CHECK_FAILED}" PermitRootLogin is not set to 'no' or has other value, set 'PermitRootLogin no' ;"
@ -44,13 +53,13 @@ esac
# ListenAddress # ListenAddress
check_value_in_conf_file "SSH" "/etc/ssh/sshd_config" "ListenAddress" "${IPV4_ADMIN_LAN_IP} ${IPV6_ADMIN_LAN_IP}" check_value_in_conf_file "SSH" "${conf_file_to_test}" "ListenAddress" "${IPV4_ADMIN_LAN_IP} ${IPV6_ADMIN_LAN_IP}"
case ${?} in case ${?} in
0) # OK, nothing to do 0) # OK, nothing to do
;; ;;
1) # Error (wrong number of param or other) 1) # Error (wrong number of param or other)
SSH_CONFIG_CHECK_FAILED=${SSH_CONFIG_CHECK_FAILED}" Error during ListenAddress check with function check_value_in_conf_file, maybe incorrect number of parameter;" SSH_CONFIG_CHECK_FAILED=${SSH_CONFIG_CHECK_FAILED}" Error during ListenAddress check with function check_value_in_conf_file, maybe incorrect number of parameter or file not found;"
;; ;;
2) # Unexpected value is set 2) # Unexpected value is set
SSH_CONFIG_CHECK_FAILED=${SSH_CONFIG_CHECK_FAILED}" ListenAddress are not well configured or has other value, set ListenAddress for IPv4 and IPv6;" SSH_CONFIG_CHECK_FAILED=${SSH_CONFIG_CHECK_FAILED}" ListenAddress are not well configured or has other value, set ListenAddress for IPv4 and IPv6;"
@ -62,3 +71,4 @@ case ${?} in
SSH_CONFIG_CHECK_FAILED=${SSH_CONFIG_CHECK_FAILED}" Error, unknown return code when calling check_value_in_conf_file to check ListenAddress;" SSH_CONFIG_CHECK_FAILED=${SSH_CONFIG_CHECK_FAILED}" Error, unknown return code when calling check_value_in_conf_file to check ListenAddress;"
;; ;;
esac esac
fi