123 lines
2.8 KiB
Bash
Executable file
123 lines
2.8 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
# Recipe script for a Gentoo system to check basic configuration
|
|
|
|
# Define colors
|
|
RED='\033[1;31m'
|
|
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=""
|
|
|
|
RESOLV_FAILED=""
|
|
|
|
RESOLVER_NOT_IN_ETC_RESOLVCONF=""
|
|
|
|
IP_NOT_RECORDED_IN_DNS=""
|
|
|
|
PING_FAILED=""
|
|
|
|
# Get ALL locales IPs except loopback
|
|
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
|
|
|
|
# Print services not started or with error at end script
|
|
SERVICES_NOT_STARTED_OR_ERROR=""
|
|
|
|
# Print message at end script if hostname *.grif or *.grifon.fr not configured
|
|
BOOL_CHECK_HOSTNAME=0
|
|
|
|
SSH_CONFIG_CHECK_FAILED=""
|
|
NRPE_CONFIG_CHECK_FAILED=""
|
|
MUNIN_CONFIG_CHECK_FAILED=""
|
|
MAIL_ALIAS_CONFIG_CHECK_FAILED=""
|
|
|
|
usage() {
|
|
printf "Usage: ./recipe_gentoo.sh [--physical]\n"
|
|
printf "option : \t-P, --physical : if the current server is not a VM but a physical machine\n"
|
|
printf "option : \t-h, --help print this current message\n"
|
|
}
|
|
|
|
# Check parameters
|
|
if [ $1 ]; then
|
|
if [ $# -gt 1 ]; then
|
|
echo "ERROR : to much parameters (one MAX)"
|
|
usage
|
|
exit 0
|
|
# Print help
|
|
elif [ $1 = '-h' ] || [ $1 = '--help' ]; then
|
|
usage
|
|
exit 0
|
|
# Set boolean physical
|
|
elif [ $1 = '-P' ] || [ $1 = '--physical' ];then
|
|
PACKAGES+=(${PACKAGES_PHYSICAL[@]})
|
|
SERVICES_TO_CHECK+=(${SERVICES_TO_CHECK_PHYSICAL[@]})
|
|
# If unknown parameter
|
|
else
|
|
echo "ERROR : unknown parameter"
|
|
usage
|
|
exit 0
|
|
fi
|
|
fi
|
|
|
|
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
|
|
|
|
. recipes/recipe_check_dns_config.sh
|
|
|
|
. recipes/recipe_check_ping.sh
|
|
|
|
. recipes/recipe_check_ip_admin.sh
|
|
|
|
. recipes/recipe_check_services.sh
|
|
|
|
. recipes/recipe_check_ssh_config.sh
|
|
|
|
. recipes/recipe_check_nrpe_config.sh
|
|
|
|
. recipes/recipe_check_munin_config.sh
|
|
|
|
. recipes/recipe_check_mail_alias_config.sh
|
|
|
|
. recipes/recipe_final_summary.sh
|
|
|
|
exit 0
|