#!/bin/sh
# author: Georgi Georgiev - hip0
# http://www.pc-freak.net
# requires lynx to be installed
# test how many lines usually your defined $host_to_check returns and based on thatchange $html_output_lines_cnt
# To find out the value for my domain http://www.pc-freak.net
# lynx --dump http://www.pc-freak.net |wc -l
# 182
# This script is preserver
lynx_path=$(which lynx);
html_output_lines_cnt='182';
host_to_check='http://www.pc-freak.net';
restart_apache_init_script='/etc/init.d/apache2';
log_file='/var/log/apache_restarts_log.txt';
if [ $($lynx_path --dump $host_to_check|wc -l ) -lt "$html_output_lines_cnt" ]; then 
echo "$(date) : $restart_apache_init_script restart ISSUED" >> $log_file
$restart_apache_init_script restart; 
fi
