diff --git a/recipe_gentoo.sh b/recipe_gentoo.sh index e66f570..8b6c454 100755 --- a/recipe_gentoo.sh +++ b/recipe_gentoo.sh @@ -8,8 +8,33 @@ BLUE='\033[1;34m' GREEN='\033[1;32m' NC='\033[0m' # No Color +REQUIREMENTS="GREP ECHO EMERGE NSLOOKUP IP HOSTNAME AWK SED CUT TR PING" + . vars.sh +# Check requirements +for requirement in $REQUIREMENTS +do + # Check if requirement tool exit on the system + which $(eval echo "\$${requirement}") &>/dev/null + + # Return Code + RC=$? + + if [ ${RC} -ne 0 ] + then + echo "ERROR : ${requirement} ($(eval echo "\$${requirement}")) is required to use this script. Requirements are : ${REQUIREMENTS}." + exit 1 + fi +done + +# Be sure only root can run the script +if [ "$(id -u)" != "0" ]; then + echo "ERROR : This script must be run as root" 1>&2 + exit 1 +fi + + # Print packages not installed or with error at end script PACKAGES_TO_CHECK="" @@ -22,7 +47,7 @@ IP_NOT_RECORDED_IN_DNS="" PING_FAILED="" # Get ALL locales IPs except loopback -LOCALES_IP_WITHOUT_LOOPBACK=$(ip a |grep inet |grep -v 'fe80\|127.0.0.1\|::1/128'| tr -s " " |cut -f3 -d' '| cut -d\/ -f1) +LOCALES_IP_WITHOUT_LOOPBACK=$(ip addr show scope global | awk '/inet/ { sub(/\/.*$/, "", $2); print $2 }') BOOL_ADMIN_IPV4_NOT_CONFIGURED=0 BOOL_ADMIN_IPV6_NOT_CONFIGURED=0 @@ -70,6 +95,8 @@ echo "-------------------------------------------------" echo -e "------- ${BLUE}RECIPE GENTOO - CHECK BASIC CONFIG${NC} ------" echo -e "-------------------------------------------------\n" +# Voir pour mettre ./ à la place de . + . recipes/recipe_check_packages.sh . recipes/recipe_check_hostname.sh