parent
fa9c7fbb7f
commit
9f0538841d
@ -1,222 +1,233 @@
|
||||
print_config_title 'CHECK PORTAGE CONFIG'
|
||||
|
||||
# Check if make.conf includes FEATURES="getbinpkg"
|
||||
echo "Check if /etc/portage/make.conf includes FEATURES=\"getbinpkg\""
|
||||
grep -q "^[[:space:]]*FEATURES=\"getbinpkg\"[[:space:]]*$" /etc/portage/make.conf
|
||||
conf_file_to_test="/etc/portage/make.conf"
|
||||
|
||||
# Return Code
|
||||
RC=$?
|
||||
|
||||
# Portage conf does NOT include getbinpkg FEATURE
|
||||
if [ $RC -ne 0 ]
|
||||
# Check if conf file exist
|
||||
if [[ ! -f "${conf_file_to_test}" ]]
|
||||
then
|
||||
PORTAGE_CONFIG_CHECK_FAILED="${PORTAGE_CONFIG_CHECK_FAILED} Portage binpkg feature not configured, add FEATURES=\"getbinpkg\" in /etc/portage/make.conf ;"
|
||||
echo -e "${RED}Portage getbinpkg feature is NOT CONFIGURED in /etc/portage/make.conf : check KO${NC}\n"
|
||||
# Portage conf includes getbinpkg FEATURE
|
||||
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
|
||||
# If there are multiple definitions of FEATURE variable, KO
|
||||
FEATURE_DEFINITION_NUMBER="$(grep \"^[[:space:]]*FEATURES\" /etc/portage/make.conf | wc -l)"
|
||||
if [ "${FEATURE_DEFINITION_NUMBER}" -gt "1" ]
|
||||
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 ;"
|
||||
echo -e "${RED}Multiple definitions of FEATURE variable in /etc/portage/make.conf : check KO${NC}\n"
|
||||
# Else it's OK
|
||||
else
|
||||
echo -e "${GREEN}Portage getbinpkg feature CONFIGURED in /etc/portage/make.conf : check OK${NC}\n"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# Check if make.conf includes well configured PORTAGE_BINHOST
|
||||
echo "Check if /etc/portage/make.conf includes well configured PORTAGE_BINHOST"
|
||||
grep -q "^[[:space:]]*PORTAGE_BINHOST=\"${BINPKGREPO}\"[[:space:]]*$" /etc/portage/make.conf
|
||||
# Check if make.conf includes FEATURES="getbinpkg"
|
||||
echo "Check if ${conf_file_to_test} includes FEATURES=\"getbinpkg\""
|
||||
grep -q "^[[:space:]]*FEATURES=\"getbinpkg\"[[:space:]]*$" ${conf_file_to_test}
|
||||
|
||||
# Return Code
|
||||
RC=$?
|
||||
# Return Code
|
||||
RC=$?
|
||||
|
||||
# Portage PORTAGE_BINHOST NOT well CONFIGURED
|
||||
if [ $RC -ne 0 ]
|
||||
then
|
||||
PORTAGE_CONFIG_CHECK_FAILED="${PORTAGE_CONFIG_CHECK_FAILED} Portage PORTAGE_BINHOST not configured, add PORTAGE_BINHOST=\"${BINPKGREPO}\" in /etc/portage/make.conf ;"
|
||||
echo -e "${RED}Portage PORTAGE_BINHOST is NOT well CONFIGURED in /etc/portage/make.conf : check KO${NC}\n"
|
||||
# Portage PORTAGE_BINHOST well CONFIGURED
|
||||
else
|
||||
# If there are multiple definitions of PORTAGE_BINHOST variable, KO
|
||||
PORTAGE_BINHOST_DEFINITION_NUMBER="$(grep "^[[:space:]]*PORTAGE_BINHOST" /etc/portage/make.conf | wc -l)"
|
||||
if [ "${PORTAGE_BINHOST_DEFINITION_NUMBER}" -gt "1" ]
|
||||
# Portage conf does NOT include getbinpkg FEATURE
|
||||
if [ $RC -ne 0 ]
|
||||
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 ;"
|
||||
echo -e "${RED}Multiple definitions of PORTAGE_BINHOST variable in /etc/portage/make.conf : check KO${NC}\n"
|
||||
# Else it's OK
|
||||
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 ${conf_file_to_test} : check KO${NC}\n"
|
||||
# Portage conf includes getbinpkg FEATURE
|
||||
else
|
||||
echo -e "${GREEN}Portage PORTAGE_BINHOST variable well CONFIGURED in /etc/portage/make.conf : check OK${NC}\n"
|
||||
# If there are multiple definitions of FEATURE variable, KO
|
||||
FEATURE_DEFINITION_NUMBER="$(grep \"^[[:space:]]*FEATURES\" ${conf_file_to_test} | wc -l)"
|
||||
if [ "${FEATURE_DEFINITION_NUMBER}" -gt "1" ]
|
||||
then
|
||||
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 ${conf_file_to_test} : check KO${NC}\n"
|
||||
# Else it's OK
|
||||
else
|
||||
echo -e "${GREEN}Portage getbinpkg feature CONFIGURED in ${conf_file_to_test} : check OK${NC}\n"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# Check if make.conf includes well configured ACCEPT_LICENSE
|
||||
echo "Check if /etc/portage/make.conf includes well configured ACCEPT_LICENSE"
|
||||
grep -q "^[[:space:]]*ACCEPT_LICENSE=\"${PORTAGE_ACCEPTLICENSE}\"[[:space:]]*$" /etc/portage/make.conf
|
||||
# Check if 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:]]*$" ${conf_file_to_test}
|
||||
|
||||
# Return Code
|
||||
RC=$?
|
||||
# Return Code
|
||||
RC=$?
|
||||
|
||||
# Portage ACCEPT_LICENSE NOT well CONFIGURED
|
||||
if [ $RC -ne 0 ]
|
||||
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 ;"
|
||||
echo -e "${RED}Portage ACCEPT_LICENSE feature is NOT well CONFIGURED in /etc/portage/make.conf : check KO${NC}\n"
|
||||
# Portage ACCEPT_LICENSE well CONFIGURED
|
||||
else
|
||||
# If there are multiple definitions of ACCEPT_LICENSE variable, KO
|
||||
ACCEPT_LICENSE_DEFINITION_NUMBER="$(grep "^[[:space:]]*ACCEPT_LICENSE" /etc/portage/make.conf | wc -l)"
|
||||
if [ "${ACCEPT_LICENSE_DEFINITION_NUMBER}" -gt "1" ]
|
||||
# Portage PORTAGE_BINHOST NOT well CONFIGURED
|
||||
if [ $RC -ne 0 ]
|
||||
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 ;"
|
||||
echo -e "${RED}Multiple definitions of ACCEPT_LICENSE variable in /etc/portage/make.conf : check KO${NC}\n"
|
||||
# Else it's OK
|
||||
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 ${conf_file_to_test} : check KO${NC}\n"
|
||||
# Portage PORTAGE_BINHOST well CONFIGURED
|
||||
else
|
||||
echo -e "${GREEN}Portage ACCEPT_LICENSE variable well CONFIGURED in /etc/portage/make.conf : check OK${NC}\n"
|
||||
# If there are multiple definitions of PORTAGE_BINHOST variable, KO
|
||||
PORTAGE_BINHOST_DEFINITION_NUMBER="$(grep "^[[:space:]]*PORTAGE_BINHOST" ${conf_file_to_test} | wc -l)"
|
||||
if [ "${PORTAGE_BINHOST_DEFINITION_NUMBER}" -gt "1" ]
|
||||
then
|
||||
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 ${conf_file_to_test} : check KO${NC}\n"
|
||||
# Else it's OK
|
||||
else
|
||||
echo -e "${GREEN}Portage PORTAGE_BINHOST variable well CONFIGURED in ${conf_file_to_test} : check OK${NC}\n"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# Check if global USE flags is well configured in /etc/portage/make.conf
|
||||
echo "Check if global USE flags is well configured in /etc/portage/make.conf"
|
||||
|
||||
# Check if USE variable has multiple definiton
|
||||
USE_DEFINITION_NUMBER="$(grep "^[[:space:]]*USE" /etc/portage/make.conf | wc -l)"
|
||||
# Check if 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:]]*$" ${conf_file_to_test}
|
||||
|
||||
# If there is only one definition, it's OK
|
||||
if [ "${USE_DEFINITION_NUMBER}" -eq "1" ]
|
||||
then
|
||||
# Get actual global USE flags in /etc/portage/make.conf 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:]]*$//')"
|
||||
PORTAGE_USE_SORTED="$(echo ${PORTAGE_USE} | sed 's/ /\n/g' | sort | tr '\n' ' ' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
|
||||
# Return Code
|
||||
RC=$?
|
||||
|
||||
# Global USE flags in /etc/portage/make.conf is well configured
|
||||
if [ "$ACTUAL_PORTAGE_USE" == "$PORTAGE_USE_SORTED" ]
|
||||
# Portage ACCEPT_LICENSE NOT well CONFIGURED
|
||||
if [ $RC -ne 0 ]
|
||||
then
|
||||
echo -e "${GREEN}Global USE flags in /etc/portage/make.conf is well configured : check OK${NC}\n"
|
||||
# Global USE flags in /etc/portage/make.conf is NOT well configured
|
||||
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 ${conf_file_to_test} : check KO${NC}\n"
|
||||
# Portage ACCEPT_LICENSE well CONFIGURED
|
||||
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 ;"
|
||||
echo -e "${RED}Global USE flags in /etc/portage/make.conf is NOT well CONFIGURED : check KO${NC}\n"
|
||||
# If there are multiple definitions of ACCEPT_LICENSE variable, KO
|
||||
ACCEPT_LICENSE_DEFINITION_NUMBER="$(grep "^[[:space:]]*ACCEPT_LICENSE" ${conf_file_to_test} | wc -l)"
|
||||
if [ "${ACCEPT_LICENSE_DEFINITION_NUMBER}" -gt "1" ]
|
||||
then
|
||||
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 ${conf_file_to_test} : check KO${NC}\n"
|
||||
# Else it's OK
|
||||
else
|
||||
echo -e "${GREEN}Portage ACCEPT_LICENSE variable well CONFIGURED in ${conf_file_to_test} : check OK${NC}\n"
|
||||
fi
|
||||
fi
|
||||
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 ;"
|
||||
echo -e "${RED}Global USE flags in /etc/portage/make.conf has multiple definitions OR USE variable is not defined : check KO${NC}\n"
|
||||
fi
|
||||
|
||||
|
||||
# Check if make.conf includes well configured CHOST
|
||||
echo "Check if /etc/portage/make.conf includes well configured CHOST"
|
||||
grep -q "^[[:space:]]*CHOST=\"${PORTAGE_CHOST}\"[[:space:]]*$" /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 ${conf_file_to_test}"
|
||||
|
||||
# Return Code
|
||||
RC=$?
|
||||
# Check if USE variable has multiple definiton
|
||||
USE_DEFINITION_NUMBER="$(grep "^[[:space:]]*USE" ${conf_file_to_test} | wc -l)"
|
||||
|
||||
# Portage CHOST NOT well CONFIGURED
|
||||
if [ $RC -ne 0 ]
|
||||
then
|
||||
PORTAGE_CONFIG_CHECK_FAILED="${PORTAGE_CONFIG_CHECK_FAILED} Portage CHOST not configured, add CHOST=\"${PORTAGE_CHOST}\" in /etc/portage/make.conf ;"
|
||||
echo -e "${RED}Portage CHOST feature is NOT well CONFIGURED in /etc/portage/make.conf : check KO${NC}\n"
|
||||
# Portage CHOST well CONFIGURED
|
||||
else
|
||||
# If there are multiple definitions of CHOST variable, KO
|
||||
CHOST_DEFINITION_NUMBER="$(grep "^[[:space:]]*CHOST" /etc/portage/make.conf | wc -l)"
|
||||
if [ "${CHOST_DEFINITION_NUMBER}" -gt "1" ]
|
||||
# If there is only one definition, it's OK
|
||||
if [ "${USE_DEFINITION_NUMBER}" -eq "1" ]
|
||||
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 ;"
|
||||
echo -e "${RED}Multiple definitions of CHOST variable in /etc/portage/make.conf : check KO${NC}\n"
|
||||
# Else it's OK
|
||||
# Get actual global USE flags in ${conf_file_to_test} and format to compare
|
||||
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:]]*$//')"
|
||||
|
||||
# Global USE flags in ${conf_file_to_test} is well configured
|
||||
if [ "$ACTUAL_PORTAGE_USE" == "$PORTAGE_USE_SORTED" ]
|
||||
then
|
||||
echo -e "${GREEN}Global USE flags in ${conf_file_to_test} is well configured : check OK${NC}\n"
|
||||
# Global USE flags in ${conf_file_to_test} is NOT well configured
|
||||
else
|
||||
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 ${conf_file_to_test} is NOT well CONFIGURED : check KO${NC}\n"
|
||||
fi
|
||||
else
|
||||
echo -e "${GREEN}Portage CHOST variable well CONFIGURED in /etc/portage/make.conf : check OK${NC}\n"
|
||||
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 ${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 GRUB_PLATFORMS
|
||||
echo "Check if /etc/portage/make.conf includes well configured GRUB_PLATFORMS"
|
||||
grep -q "^[[:space:]]*GRUB_PLATFORMS=\"${PORTAGE_GRUB_PLATFORMS}\"[[:space:]]*$" /etc/portage/make.conf
|
||||
# Check if make.conf includes well configured CHOST
|
||||
echo "Check if ${conf_file_to_test} includes well configured CHOST"
|
||||
grep -q "^[[:space:]]*CHOST=\"${PORTAGE_CHOST}\"[[:space:]]*$" ${conf_file_to_test}
|
||||
|
||||
# Return Code
|
||||
RC=$?
|
||||
# Return Code
|
||||
RC=$?
|
||||
|
||||
# Portage GRUB_PLATFORMS NOT well CONFIGURED
|
||||
if [ $RC -ne 0 ]
|
||||
then
|
||||
PORTAGE_CONFIG_CHECK_FAILED="${PORTAGE_CONFIG_CHECK_FAILED} Portage CHOST not configured, add GRUB_PLATFORMS=\"${PORTAGE_GRUB_PLATFORMS}\" in /etc/portage/make.conf ;"
|
||||
echo -e "${RED}Portage GRUB_PLATFORMS feature is NOT well CONFIGURED in /etc/portage/make.conf : check KO${NC}\n"
|
||||
# Portage GRUB_PLATFORMS well CONFIGURED
|
||||
else
|
||||
# If there are multiple definitions of CHOST variable, KO
|
||||
GRUB_PLATFORMS_DEFINITION_NUMBER="$(grep "^[[:space:]]*GRUB_PLATFORMS" /etc/portage/make.conf | wc -l)"
|
||||
if [ "${GRUB_PLATFORMS_DEFINITION_NUMBER}" -gt "1" ]
|
||||
# Portage CHOST NOT well CONFIGURED
|
||||
if [ $RC -ne 0 ]
|
||||
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 ;"
|
||||
echo -e "${RED}Multiple definitions of GRUB_PLATFORMS variable in /etc/portage/make.conf : check KO${NC}\n"
|
||||
# Else it's OK
|
||||
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 ${conf_file_to_test} : check KO${NC}\n"
|
||||
# Portage CHOST well CONFIGURED
|
||||
else
|
||||
echo -e "${GREEN}Portage GRUB_PLATFORMS variable well CONFIGURED in /etc/portage/make.conf : check OK${NC}\n"
|
||||
# If there are multiple definitions of CHOST variable, KO
|
||||
CHOST_DEFINITION_NUMBER="$(grep "^[[:space:]]*CHOST" ${conf_file_to_test} | wc -l)"
|
||||
if [ "${CHOST_DEFINITION_NUMBER}" -gt "1" ]
|
||||
then
|
||||
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 ${conf_file_to_test} : check KO${NC}\n"
|
||||
# Else it's OK
|
||||
else
|
||||
echo -e "${GREEN}Portage CHOST variable well CONFIGURED in ${conf_file_to_test} : check OK${NC}\n"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# Check if portage organization mirror is configured in /etc/portage/make.conf
|
||||
echo "Check if portage oragnization mirror is configured in /etc/portage/make.conf"
|
||||
|
||||
# Check if GENTOO_MIRRORS variable has multiple definiton
|
||||
GENTOO_MIRRORS_DEFINITION_NUMBER="$(grep "^[[:space:]]*GENTOO_MIRRORS" /etc/portage/make.conf | wc -l)"
|
||||
|
||||
# If there is only one definition, it's OK
|
||||
if [ "${GENTOO_MIRRORS_DEFINITION_NUMBER}" -eq "1" ]
|
||||
then
|
||||
# Check if GENTOO_MIRRORS value in /etc/portage/make.conf includes organization mirror
|
||||
sed -n '/^[[:space:]]*GENTOO_MIRRORS=\"/,/\"/p' /etc/portage/make.conf | grep -q "${PORTAGE_ORGANIZATION_MIRROR}"
|
||||
# Check if 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:]]*$" ${conf_file_to_test}
|
||||
|
||||
# Return Code
|
||||
RC=$?
|
||||
|
||||
# GENTOO_MIRRORS in /etc/portage/make.conf includes organization mirror
|
||||
if [ $RC -eq 0 ]
|
||||
# Portage GRUB_PLATFORMS NOT well CONFIGURED
|
||||
if [ $RC -ne 0 ]
|
||||
then
|
||||
echo -e "${GREEN}GENTOO_MIRRORS in /etc/portage/make.conf includes organization mirror : check OK${NC}\n"
|
||||
# GENTOO_MIRRORS in /etc/portage/make.conf does NOT includes organization mirror
|
||||
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 ${conf_file_to_test} : check KO${NC}\n"
|
||||
# Portage GRUB_PLATFORMS well CONFIGURED
|
||||
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 ;"
|
||||
echo -e "${RED}GENTOO_MIRRORS in /etc/portage/make.conf does NOT includes organization mirror : check KO${NC}\n"
|
||||
# If there are multiple definitions of CHOST variable, KO
|
||||
GRUB_PLATFORMS_DEFINITION_NUMBER="$(grep "^[[:space:]]*GRUB_PLATFORMS" ${conf_file_to_test} | wc -l)"
|
||||
if [ "${GRUB_PLATFORMS_DEFINITION_NUMBER}" -gt "1" ]
|
||||
then
|
||||
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 ${conf_file_to_test} : check KO${NC}\n"
|
||||
# Else it's OK
|
||||
else
|
||||
echo -e "${GREEN}Portage GRUB_PLATFORMS variable well CONFIGURED in ${conf_file_to_test} : check OK${NC}\n"
|
||||
fi
|
||||
fi
|
||||
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 ;"
|
||||
echo -e "${RED}GENTOO_MIRRORS in /etc/portage/make.conf has multiple definitions OR GENTOO_MIRRORS variable is not defined : check KO${NC}\n"
|
||||
fi
|
||||
|
||||
|
||||
# Check if portage organization mirror is configured in ${conf_file_to_test}
|
||||
echo "Check if portage oragnization mirror is configured in ${conf_file_to_test}"
|
||||
|
||||
# Check if GENTOO_MIRRORS variable has multiple definiton
|
||||
GENTOO_MIRRORS_DEFINITION_NUMBER="$(grep "^[[:space:]]*GENTOO_MIRRORS" ${conf_file_to_test} | wc -l)"
|
||||
|
||||
# If there is only one definition, it's OK
|
||||
if [ "${GENTOO_MIRRORS_DEFINITION_NUMBER}" -eq "1" ]
|
||||
then
|
||||
# Check if GENTOO_MIRRORS value in ${conf_file_to_test} includes organization mirror
|
||||
sed -n '/^[[:space:]]*GENTOO_MIRRORS=\"/,/\"/p' ${conf_file_to_test} | grep -q "${PORTAGE_ORGANIZATION_MIRROR}"
|
||||
|
||||
# Return Code
|
||||
RC=$?
|
||||
|
||||
# GENTOO_MIRRORS in ${conf_file_to_test} includes organization mirror
|
||||
if [ $RC -eq 0 ]
|
||||
then
|
||||
echo -e "${GREEN}GENTOO_MIRRORS in ${conf_file_to_test} includes organization mirror : check OK${NC}\n"
|
||||
# GENTOO_MIRRORS in ${conf_file_to_test} does NOT includes organization mirror
|
||||
else
|
||||
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 ${conf_file_to_test} does NOT includes organization mirror : check KO${NC}\n"
|
||||
fi
|
||||
else
|
||||
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 ${conf_file_to_test} has multiple definitions OR GENTOO_MIRRORS variable is not defined : check KO${NC}\n"
|
||||
fi
|
||||
|
||||
|
||||
# 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 /etc/portage/make.conf"
|
||||
|
||||
# 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)"
|
||||
# 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 ${conf_file_to_test}"
|
||||
|
||||
# If there is only one definition, it's OK
|
||||
if [ "${CPU_FLAGS_X86_DEFINITION_NUMBER}" -eq "1" ]
|
||||
then
|
||||
# Get actual global CPU_FLAGS_X86 flags in /etc/portage/make.conf 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:]]*$//')"
|
||||
PORTAGE_CPU_FLAGS_X86_SORTED="$(echo ${PORTAGE_CPU_FLAGS_X86} | sed 's/ /\n/g' | sort | tr '\n' ' ' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
|
||||
# Check if CPU_FLAGS_X86 variable has multiple definiton
|
||||
CPU_FLAGS_X86_DEFINITION_NUMBER="$(grep "^[[:space:]]*CPU_FLAGS_X86" ${conf_file_to_test} | wc -l)"
|
||||
|
||||
# Global CPU_FLAGS_X86 flags in /etc/portage/make.conf is well configured
|
||||
if [ "$ACTUAL_PORTAGE_CPU_FLAGS_X86" == "$PORTAGE_CPU_FLAGS_X86_SORTED" ]
|
||||
# If there is only one definition, it's OK
|
||||
if [ "${CPU_FLAGS_X86_DEFINITION_NUMBER}" -eq "1" ]
|
||||
then
|
||||
echo -e "${GREEN}Global CPU_FLAGS_X86 flags in /etc/portage/make.conf is well configured : check OK${NC}\n"
|
||||
# Global CPU_FLAGS_X86 flags in /etc/portage/make.conf is NOT well configured
|
||||
# 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' ${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:]]*$//')"
|
||||
|
||||
# Global CPU_FLAGS_X86 flags in ${conf_file_to_test} is well configured
|
||||
if [ "$ACTUAL_PORTAGE_CPU_FLAGS_X86" == "$PORTAGE_CPU_FLAGS_X86_SORTED" ]
|
||||
then
|
||||
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 ${conf_file_to_test} is NOT well configured
|
||||
else
|
||||
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 ${conf_file_to_test} is NOT well CONFIGURED : check KO${NC}\n"
|
||||
fi
|
||||
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 ;"
|
||||
echo -e "${RED}Global CPU_FLAGS_X86 flags in /etc/portage/make.conf is NOT well CONFIGURED : check KO${NC}\n"
|
||||
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 ${conf_file_to_test} has multiple definitions OR CPU_FLAGS_X86 variable is not defined : check KO${NC}\n"
|
||||
fi
|
||||
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 ;"
|
||||
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"
|
||||
fi
|
||||
|
@ -1,64 +1,74 @@
|
||||
print_config_title 'CHECK SSH CONFIG'
|
||||
|
||||
|
||||
# PasswordAuthentication
|
||||
check_value_in_conf_file "SSH" "/etc/ssh/sshd_config" "PasswordAuthentication" "no"
|
||||
conf_file_to_test="/etc/snmp/snmpd.conf"
|
||||
|
||||
case ${?} in
|
||||
0) # OK, nothing to do
|
||||
;;
|
||||
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;"
|
||||
;;
|
||||
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' ;"
|
||||
;;
|
||||
3) # All expected values are NOT configured
|
||||
SSH_CONFIG_CHECK_FAILED=${SSH_CONFIG_CHECK_FAILED}" PasswordAuthentication is not set to 'no', set 'PasswordAuthentication no' ;"
|
||||
;;
|
||||
*) # Unknown return code...
|
||||
SSH_CONFIG_CHECK_FAILED=${SSH_CONFIG_CHECK_FAILED}" Error, unknown return code when calling check_value_in_conf_file to check PasswordAuthentication;"
|
||||
;;
|
||||
esac
|
||||
# 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
|
||||
check_value_in_conf_file "SSH" "${conf_file_to_test}" "PasswordAuthentication" "no"
|
||||
|
||||
# PermitRootLogin
|
||||
check_value_in_conf_file "SSH" "/etc/ssh/sshd_config" "PermitRootLogin" "no"
|
||||
case ${?} in
|
||||
0) # OK, nothing to do
|
||||
;;
|
||||
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 or file not found;"
|
||||
;;
|
||||
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' ;"
|
||||
;;
|
||||
3) # All expected values are NOT configured
|
||||
SSH_CONFIG_CHECK_FAILED=${SSH_CONFIG_CHECK_FAILED}" PasswordAuthentication is not set to 'no', set 'PasswordAuthentication no' ;"
|
||||
;;
|
||||
*) # Unknown return code...
|
||||
SSH_CONFIG_CHECK_FAILED=${SSH_CONFIG_CHECK_FAILED}" Error, unknown return code when calling check_value_in_conf_file to check PasswordAuthentication;"
|
||||
;;
|
||||
esac
|
||||
|
||||
case ${?} in
|
||||
0) # OK, nothing to do
|
||||
;;
|
||||
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;"
|
||||
;;
|
||||
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' ;"
|
||||
;;
|
||||
3) # All expected values are NOT configured
|
||||
SSH_CONFIG_CHECK_FAILED=${SSH_CONFIG_CHECK_FAILED}" PermitRootLogin is not set to 'no', set 'PermitRootLogin no' ;"
|
||||
;;
|
||||
*) # Unknown return code...
|
||||
SSH_CONFIG_CHECK_FAILED=${SSH_CONFIG_CHECK_FAILED}" Error, unknown return code when calling check_value_in_conf_file to check PermitRootLogin;"
|
||||
;;
|
||||
esac
|
||||
|
||||
# PermitRootLogin
|
||||
check_value_in_conf_file "SSH" "${conf_file_to_test}" "PermitRootLogin" "no"
|
||||
|
||||
# ListenAddress
|
||||
check_value_in_conf_file "SSH" "/etc/ssh/sshd_config" "ListenAddress" "${IPV4_ADMIN_LAN_IP} ${IPV6_ADMIN_LAN_IP}"
|
||||
case ${?} in
|
||||
0) # OK, nothing to do
|
||||
;;
|
||||
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 or file not found;"
|
||||
;;
|
||||
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' ;"
|
||||
;;
|
||||
3) # All expected values are NOT configured
|
||||
SSH_CONFIG_CHECK_FAILED=${SSH_CONFIG_CHECK_FAILED}" PermitRootLogin is not set to 'no', set 'PermitRootLogin no' ;"
|
||||
;;
|
||||
*) # Unknown return code...
|
||||
SSH_CONFIG_CHECK_FAILED=${SSH_CONFIG_CHECK_FAILED}" Error, unknown return code when calling check_value_in_conf_file to check PermitRootLogin;"
|
||||
;;
|
||||
esac
|
||||
|
||||
case ${?} in
|
||||
0) # OK, nothing to do
|
||||
;;
|
||||
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;"
|
||||
;;
|
||||
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;"
|
||||
;;
|
||||
3) # All expected values are NOT configured
|
||||
SSH_CONFIG_CHECK_FAILED=${SSH_CONFIG_CHECK_FAILED}" ListenAddress are not well configured, set ListenAddress for IPv4 and IPv6;"
|
||||
;;
|
||||
*) # Unknown return code...
|
||||
SSH_CONFIG_CHECK_FAILED=${SSH_CONFIG_CHECK_FAILED}" Error, unknown return code when calling check_value_in_conf_file to check ListenAddress;"
|
||||
;;
|
||||
esac
|
||||
|
||||
# ListenAddress
|
||||
check_value_in_conf_file "SSH" "${conf_file_to_test}" "ListenAddress" "${IPV4_ADMIN_LAN_IP} ${IPV6_ADMIN_LAN_IP}"
|
||||
|
||||
case ${?} in
|
||||
0) # OK, nothing to do
|
||||
;;
|
||||
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 or file not found;"
|
||||
;;
|
||||
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;"
|
||||
;;
|
||||
3) # All expected values are NOT configured
|
||||
SSH_CONFIG_CHECK_FAILED=${SSH_CONFIG_CHECK_FAILED}" ListenAddress are not well configured, set ListenAddress for IPv4 and IPv6;"
|
||||
;;
|
||||
*) # Unknown return code...
|
||||
SSH_CONFIG_CHECK_FAILED=${SSH_CONFIG_CHECK_FAILED}" Error, unknown return code when calling check_value_in_conf_file to check ListenAddress;"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
Loading…
Reference in new issue