#!/bin/bash

DOMAIN='dd.vqiu.cn'
ACL_FILE='/usr/local/apache2/conf/vhost/http.acl'
NEW_IP=$(ping -c 1 ${DOMAIN}|awk '/time=/{print $4}'|sed 's/\://g')
OLD_IP=$(awk '{print $3}' /usr/local/apache2/conf/vhost/http.acl)
CUR_TIME=$(date +%F" "%T)

if [ "${OLD_IP}" = "${NEW_IP}" ]
then
    echo 'No changed';
    exit 1;
else
    echo "${CUR_TIME}	${NEW_IP}" >> /data/shell/private_ip_record.log
    echo -en "require ip ${NEW_IP}" > ${ACL_FILE}
    /usr/local/apache2/bin/apachectl -k graceful
fi
