LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   How to Debug Init Scripts (https://www.linuxquestions.org/questions/slackware-14/how-to-debug-init-scripts-155035/)

MQMan 03-08-2004 12:41 PM

How to Debug Init Scripts
 
Hi,

How can I debug my rc.d/rc.* scripts as they are called from init. I've got a problem (see other post) where dhcpcd is started 2 (or 3) times for the same network interface. I've tried using -x, but that doesn't help. Also, entering the scripts as commands doesn't work, because it works perfectly every time in this mode.

I've added a bunch of "echo" and "sleep" statements, but there still seems to be a problem with the order that things are showing up on the console. Could that be because of "multiuser" mode. If so, how can I get around it (while still staying "multi"). Should I use something instead of "sleep" to hold the console, to give me time to read it.

Cheers,
Eddie

OdieQ 03-08-2004 04:25 PM

ScrollLock
 
You can use ScrollLock to hold the console and Shift-PageUp to scroll back.

trickykid 03-08-2004 05:05 PM

You can always do something like:

sh +x <scriptname>

to see where its failing, etc. This is what I use to see where a script fails and such.

unSpawn 03-08-2004 05:46 PM

sh +x <scriptname>
to see where its failing, etc. This is what I use to see where a script fails and such.

.. and for the equivalent for usage inside (Ba)sh scripts, add a line "set +x".

MQMan 03-08-2004 09:32 PM

BUT. As I pointed our earlier, -x DOES NOT WORK for scripts started from init.

Also, using Scroll Lock *does* hold the console, but as the scripts aren't printing anything useful, what use is pausing it.

Cheers,
Eddie

skog 03-08-2004 10:49 PM

if your starting several versions of dhcpcd i doubt it is your scripts that are cuasing the problem.

try this though:
grep dhcpcd /etc/rc.d/rc* <--- that will show you everywhere the dhcp Client Deamon is being called from.

should be only in there once and maybe some comments. Check in rc.inet1.conf and look for the lines like:
USE_DHCP[x]="" <--- i leave it blank for nics i dont have so they arent used, but i think it has to be "yes" for it to try and use dhcpcd for that nic
and make sure you have the correct settings

In /etc/rc.d/rc.inet.conf check what you have for nic settings.

if that all looks correct what does it say when you ps -ax for dhcpcd? should be like:
12345 ? S 0:00 /sbin/dhcpcd -t 10 -d eth0 <---does it show for all -d as eth0

check what you have in /etc/host.conf should be something like:
order bind, hosts
multi on
nospoof

if that all works try:
ifconfig eth0 down
ps -ax <--- see if all the dhcpcd processes ended if they did then run the next command if they didnt kill the other dhcpcd processes.
dhcpcd -t 10 -d eth0
ps -ax <--- see how many processes you have running starting dhcpcd this way.

MQMan 03-09-2004 10:11 AM

I did grep through rc.d and the only place that dhcpcd is called is in rc.inet1. There are 2 entries, but wrapped inside an if - else, so only one could ever execute.

rc.inet1.conf is correct. There's only one entry with 'yes', USE_DHCP[0]='yes'.

Here's the output from a ps -ef:

root 96 1 0 Mar07 ? 00:00:00 /sbin/dhcpcd -t 10 -d -R eth0
root 98 1 0 Mar07 ? 00:00:00 /sbin/dhcpcd -t 10 -d -R eth0

You can see that both are for the SAME interface, with the SAME options set. Plus, the PIDs are so close, that they must have been fired off almost simultaneously.

As I said earlier, I've added some 'debugging' echos in the script, but the output doesn't seem to always run sequentially. :confused:

I can't try the other suggestions, as I'm not at home and taking down the interface will kill my cable connection, which will stop me restarting it. :D

Cheers,

MQMan 03-09-2004 11:35 AM

Well, after a bunch of searching around on my system, I found a 2nd place where rc.inet1 is called. It's also called from /etc/hotplug/net.agent. And the only change I've made recently was to enable rc.hotplug so my USB ports are available at boot time for a UPS.

And guess what else I found. This in a SuSE sysconfig package changelog:

- is_iface_available(): It will now only modprobe <interface> if called from ifup, because it must not trigger unwanted hotplug events (#13178, dhcpcd was started twice)

Looks like Slack has the same bug. :rolleyes: As long as I can work out what that cryptic comment means. :D

Cheers,
Eddie

flyfishin 03-09-2004 12:03 PM

Grep through /etc on down. If you start in rc.d you'll miss potential uses above that directory. I found references to dhcpcd in pcmcia/network and rc.d/rc.inet1.

MQMan 03-09-2004 12:22 PM

I could have 'grep'ped through the whole disk, and still only found one reference to dhcpcd. ;)

The problem is that the script that starts dhcpcd, rc.inet1, is called from multiple places. :(

The problem is that the 1st time rc.inet1 is called, it fires off dhcpcd to get the IP (and all the rest of the stuff). Immediately after, rc.hotplug is then started, which because the preceeding dhcpcd is still running, thinks that the interface is not up, and so fires off rc.inet1 AGAIN. :eek:

My "short term" plan is to put a delay in, so that the 1st dhcpcd completes before rc.hotplug gets control.

Lastly, how do I report bugs back to Patrick.

Cheers,

skog 03-09-2004 12:39 PM

why dont you just comment out the call to rc.inet1 in rc.hotplug or in rc.M so it only executes once?

flyfishin 03-09-2004 12:40 PM

Rather than putting in a delay, why not just comment out the reference to rc.inet1 in net.agent? Looking at the code in net.agent there is a Slackware section that runs ifconfig and greps for your interface. It fires it up the network card if ifconfig returns nothing. Just comment out the section for Slackware.


All times are GMT -5. The time now is 05:19 PM.