Add check requirements and if user is root
This commit is contained in:
parent
edf65b7760
commit
dda2109f6d
|
@ -8,8 +8,33 @@ BLUE='\033[1;34m'
|
||||||
GREEN='\033[1;32m'
|
GREEN='\033[1;32m'
|
||||||
NC='\033[0m' # No Color
|
NC='\033[0m' # No Color
|
||||||
|
|
||||||
|
REQUIREMENTS="GREP ECHO EMERGE NSLOOKUP IP HOSTNAME AWK SED CUT TR PING"
|
||||||
|
|
||||||
. vars.sh
|
. 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
|
# Print packages not installed or with error at end script
|
||||||
PACKAGES_TO_CHECK=""
|
PACKAGES_TO_CHECK=""
|
||||||
|
|
||||||
|
@ -22,7 +47,7 @@ IP_NOT_RECORDED_IN_DNS=""
|
||||||
PING_FAILED=""
|
PING_FAILED=""
|
||||||
|
|
||||||
# Get ALL locales IPs except loopback
|
# 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_IPV4_NOT_CONFIGURED=0
|
||||||
BOOL_ADMIN_IPV6_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 "------- ${BLUE}RECIPE GENTOO - CHECK BASIC CONFIG${NC} ------"
|
||||||
echo -e "-------------------------------------------------\n"
|
echo -e "-------------------------------------------------\n"
|
||||||
|
|
||||||
|
# Voir pour mettre ./ à la place de .
|
||||||
|
|
||||||
. recipes/recipe_check_packages.sh
|
. recipes/recipe_check_packages.sh
|
||||||
|
|
||||||
. recipes/recipe_check_hostname.sh
|
. recipes/recipe_check_hostname.sh
|
||||||
|
|
Loading…
Reference in a new issue