LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 03-08-2004, 12:41 PM   #1
MQMan
Member
 
Registered: Jan 2004
Location: Los Angeles
Distribution: Slack64 14.1
Posts: 581

Rep: Reputation: 38
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
 
Old 03-08-2004, 04:25 PM   #2
OdieQ
Member
 
Registered: Jan 2004
Location: Stockholm, Sweden
Distribution: Debian, Slackware
Posts: 71

Rep: Reputation: 15
ScrollLock

You can use ScrollLock to hold the console and Shift-PageUp to scroll back.
 
Old 03-08-2004, 05:05 PM   #3
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
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.
 
Old 03-08-2004, 05:46 PM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
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".
 
Old 03-08-2004, 09:32 PM   #5
MQMan
Member
 
Registered: Jan 2004
Location: Los Angeles
Distribution: Slack64 14.1
Posts: 581

Original Poster
Rep: Reputation: 38
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
 
Old 03-08-2004, 10:49 PM   #6
skog
Member
 
Registered: Sep 2003
Location: TX
Distribution: slackware
Posts: 301

Rep: Reputation: 30
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.
 
Old 03-09-2004, 10:11 AM   #7
MQMan
Member
 
Registered: Jan 2004
Location: Los Angeles
Distribution: Slack64 14.1
Posts: 581

Original Poster
Rep: Reputation: 38
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.

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.

Cheers,
 
Old 03-09-2004, 11:35 AM   #8
MQMan
Member
 
Registered: Jan 2004
Location: Los Angeles
Distribution: Slack64 14.1
Posts: 581

Original Poster
Rep: Reputation: 38
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. As long as I can work out what that cryptic comment means.

Cheers,
Eddie
 
Old 03-09-2004, 12:03 PM   #9
flyfishin
Member
 
Registered: Aug 2003
Location: KC, MO
Distribution: CentOS, RHEL, SuSE, Fedora
Posts: 243

Rep: Reputation: 30
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.
 
Old 03-09-2004, 12:22 PM   #10
MQMan
Member
 
Registered: Jan 2004
Location: Los Angeles
Distribution: Slack64 14.1
Posts: 581

Original Poster
Rep: Reputation: 38
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.

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,
 
Old 03-09-2004, 12:39 PM   #11
skog
Member
 
Registered: Sep 2003
Location: TX
Distribution: slackware
Posts: 301

Rep: Reputation: 30
why dont you just comment out the call to rc.inet1 in rc.hotplug or in rc.M so it only executes once?
 
Old 03-09-2004, 12:40 PM   #12
flyfishin
Member
 
Registered: Aug 2003
Location: KC, MO
Distribution: CentOS, RHEL, SuSE, Fedora
Posts: 243

Rep: Reputation: 30
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
init scripts lvgandhi Debian 2 10-11-2005 02:44 AM
Customize my init scripts Spack971 Slackware 16 07-04-2005 05:37 PM
New init scripts? xconspirisist Fedora 9 12-09-2004 11:41 AM
Bootsplash init scripts TheRepublican Slackware 5 05-11-2004 02:13 AM
Scripts in /etc/rc.d/init.d correro Linux - General 1 03-13-2003 09:47 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 01:37 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration