recipe_gentoo/recipes/recipe_check_autoupdate_con...

39 lines
1.5 KiB
Bash

print_config_title 'CHECK AUTO-UPDATE'
# Check if auto-update script is present
echo "Check if auto-update script is present"
if [[ -f "${AUTOUPDATE_SCRIPT}" ]]
then
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
echo "Check if the auto-update script is executable"
if [[ -x "${AUTOUPDATE_SCRIPT}" ]]
then
echo -e "${GREEN}The auto-update script is executable : check OK${NC}\n"
else
AUTOUPDATE_CONFIG_CHECK_FAILED=${AUTOUPDATE_CONFIG_CHECK_FAILED}" The auto-update script is NOT executable;"
echo -e "${RED}The auto-update script is NOT executable: check KO${NC}\n"
fi
# Check if the auto-update cron task is configured
echo "Check if the cron task is configured"
crontab -l 2>/dev/null | grep -q "${AUTOUPDATE_SCRIPT}"
RCa=${?} # First Return Code
grep -q "${AUTOUPDATE_SCRIPT}" /etc/cron.d/*
RCb=${?} # Second Return Code
grep -q "${AUTOUPDATE_SCRIPT}" /etc/crontab
RCc=${?} # Third Return Code
if [[ ${RCa} -ne 0 ]] && [[ ${RCb} -ne 0 ]] && [[ ${RCc} -ne 0 ]]
then
AUTOUPDATE_CONFIG_CHECK_FAILED=${AUTOUPDATE_CONFIG_CHECK_FAILED}" No cron entry for auto-update, configure it;"
echo -e "${RED}NO cron entry for auto-update : check KO${NC}\n"
# Service started without error
else
echo -e "${GREEN}Cron entry for auto-update exist: check OK${NC}\n"
fi