[ SEA-GHOST MINI SHELL]
#!/bin/bash
#
# Define variables
checked_hooks_filename="/var/lib/zabbix/cpanel_hooks_check.list"
#
# Show error if source file is absent
if [ ! -f $checked_hooks_filename ]; then
echo "ERROR: hook list file is absent ${checked_hooks_filename}"
exit 1
fi
#
missed_hooks=""
installed_hooks=`/usr/local/cpanel/bin/manage_hooks list | grep hook | awk '{print $2}' | sort | uniq`
#Read checked hooks to array
readarray checked_hooks < $checked_hooks_filename
#Check if hooks present
for hook in "${checked_hooks[@]}"
do
hook=`echo $hook | sed ':a;N;$!ba;s/\n//g'`
if [[ $installed_hooks != *$hook* ]]; then
missed_hooks+=" $hook"
fi
done
#Return status
if [ -n "$missed_hooks" ]; then
echo "ERROR: missing hooks ${missed_hooks}"
else
echo "OK: All hooks installed"
fi
SEA-GHOST - SHELL CODING BY SEA-GHOST