Code: Select all
#!/bin/sh
newip=$(/usr/bin/lynx -source http://www.showmyip.com | /bin/grep TITLE | /usr/bin/cut -f 4-d'>' | /usr/bin/cut -f5 -d' ')
echo "$newip" > /tmp/newip
diff /tmp/ipnow /tmp/newip &> /dev/null
if [ $? -eq 0 ]
then
echo The IP hasn't changed
else
echo "UPDATE Monitors SET Host='"$newip"' WHERE id=1;" > /tmp/updateip.sql
mysql -h hostserverzm -uzmuser -pzmpassword zmdb < /tmp/updateip.sql &> /dev/null
if [ $? -eq 0 ]
then
echo $newip > /tmp/ipnow
else
echo DB FAILED
fi
fi
The id is the Monitor id of zoneminder server
The hostserverzm,zmuser,zmpassword,zmdb must have the correct values for the zoneminder server.
This script can be in cron for example each 15 minutes to get always the correct ip.
Best Regards