#! /bin/sh
# change the range of the dhcpd.conf. so every time the client can get the
# different IP after the dhcp leases.
set -x
# if the dhcpd is running then kill it
dhcp_pid=`ps -A |grep dhcpd | awk '{print $1}'`
if [ $dhcp_pid -ne "0" ]
then kill $dhcp_pid
fi
theend=200 #the init of the end of the range
# the loop
while (true)
do
if [ $theend -lt "250" ]
then theend=`expr $theend + 10`
else theend=200
fi
thestart=`expr $theend - 10`
myword=" range 192.168.1.$thestart 192.168.1.$theend;"
theword=`grep range dhcpd.conf`
sed "s/$theword/$myword/g" dhcpd.conf > text # use the new range to replace the old
mv text dhcpd.conf
dhcp_pid=`ps -A |grep dhcpd | awk '{print $1}'`
kill $dhcp_pid
dhcpd
sleep 90
done
set +x