Hi! Thanks for your reply. This week we're having a school project in which
we're supposed to compile dhcpd and make it start normally after booting.
Sorry for the long follow-up..
I appended your line to my script and it looked like it was getting
interrupted right after executing the "$0 stop" line of the restart case:
Code:
student@ubuntu12:~$ sudo service dhcpd restart
< .. output of the script in it's entirety .. >
+ case $1 in
+ echo 'turned off'
turned off
+ /etc/init.d/dhcpd stop
< .. output of the script in it's entirety .. >
+ case $1 in
+ pkill dhcpd
student@ubuntu12:~$
I'did a little bit of tweaking to the code by adding "ps -ef | grep dhcpd"
to the restart case:
Code:
restart) echo "turned off"
ps -ef | grep dhcpd
$0 stop
echo "this line got executed"
sleep 2
$0 start
echo "turned on" ;;
Here's the output I got after adding that line:
Code:
student@ubuntu12:~$ sudo service dhcpd restart
< .. output of the script in it's entirety .. >
+ case $1 in
+ echo 'turned off'
turned off
+ ps -ef
+ grep dhcpd
root 2172 1 0 11:27 ? 00:00:00 /opt/dhcpd/sbin/dhcpd -cf
/opt/dhcpd/etc/dhcpd.conf -lf /opt/dhcpd/etc/dhcpd.leases
root 2174 2013 0 11:28 pts/2 00:00:00 sudo service dhcpd restart
root 2175 2174 0 11:28 pts/2 00:00:00 /bin/bash /etc/init.d/dhcpd restart
root 2179 2175 0 11:28 pts/2 00:00:00 grep dhcpd
+ /etc/init.d/dhcpd stop
< .. output of the script in it's entirety .. >
+ case $1 in
+ pkill dhcpd
student@ubuntu12:~$
So it turned out the script was sending itself the kill signal all along.
I changed the script's name to dhcpsrv, and sure enough it is now working
properly.
Again, many thanks for the input,
Mike