Denys,
-----Original Message-----
From: Denys Vlasenko [mailto:vda.linux at googlemail.com]
Sent: Friday, February 21, 2014 6:56 AM
To: Bryan Evenson
Cc: busybox at busybox.net
Subject: Re: Looking for simple ifplugd example script
On Fri, Feb 21, 2014 at 11:39 AM, Bryan Evenson
Post by Bryan EvensonPost by Bryan EvensonPost by Bryan EvensonAt this point, ifplugd is not running. After some poking around, I see that
there is no default daemon script for ifplugd included with Busybox.
I'm assuming a script to do the above isn't that difficult, but I
can't seem to find any examples on how to do this. Does anyone have
a simple example that I can go by? I did see the example in the
Busybox source under examples/var_service/ifplugd_if, but I couldn't
make any sense of what that script did and how to make use of it.
It means that busybox/examples/var_service/README is badly located,
or badly written, or both.
I found the README you were talking about. I have never used runsvdir
before and I don't have it included in my version of Busybox. I
didn't realize that Busybox was assuming you'd use runsvdir to run
ifplugd,
We don't pull Lenart Pottering here.
Busybox does not assume or require you to use runsvdir with ifplugd.
You can use ifplugd with or without runsvdir.
ifplugd is written in a way that it's *you* who decide what to do when link
goes up or down (by the way of writing desired actions in your script).
Post by Bryan Evensonwhich was the start of my confusion. And since I didn't know that's what
was assumed, I didn't think to look a couple directories up for a related
README.
How about this fix (adding another README)?
$ cat examples/var_service/ifplugd_if/README
The real README file is one directory up.
A copy of examples/var_service/nmeter/README in examples/var_service/ifplugd_if/ would be helpful. In my searches for examples on how to use ifplugd, everything I found said "see /etc/default/ifplugd for example usage", which I didn't have. I'm unfamiliar with runsvdir, so I didn't know "run" was the file that called ifplugd. So the example in run is as follows:
ifplugd -apqns -t3 -u8 -d8 -i "$if" -r "$pwd/ifplugd_handler"
I'm trying to get a better understanding as to what this command does and how it'd apply to my setup if I wanted to use it in an init script with sysVinit. Following the setup from the other init scripts in my system, I would be using start-stop-daemon to start ifplugd. And as far as right now, forget what I'd mentioned before about the static IP address; first step is just getting the system to re-attempt DHCP when someone plugs in the Ethernet cable.
Based on how I'm assuming I would need to call ifplugd from a sysVinit script, here is the script I have as a starting point:
#! /bin/sh
#
# ifplugd init.d script
test -x /usr/bin/ifplugd || exit 0
#Functions to do individual actions
startdaemon(){
# Start the application
echo -n "Starting ifplugd: "
start-stop-daemon --start --quiet --background --exec /usr/bin/ifplugd -- "-apq -t3 -u8 -d8 -i eth0 -r /etc/udhcpc.d/50default"
echo "done"
}
stopdaemon(){
echo -n "Stopping ifplugd: "
start-stop-daemon --stop --quiet --exec /usr/bin/ifplugd
echo "done"
}
case "$1" in
start)
startdaemon
;;
stop)
stopdaemon
;;
restart|force-reload)
stopdaemon
sleep 2
startdaemon
;;
*)
echo "Usage: /etc/init.d/ifplugd { start | stop | restart | force-reload }" >&2
exit 1
;;
esac
exit 0
Basically, start ifplugd and let it call udhcpc if ifplugd detects a change in the link. My startup says that its calling this script, and I can call "/etc/init.d/ifplugd start" on the command line and I don't see any complaints. However, I don't see ifplugd in my running process list; for some reason the daemon isn't running (or, maybe it starts but fails for some reason). I also don't see any message related to ifplugd in my system log. Are there some arguments I got wrong in the call to ifplugd?
Post by Bryan EvensonA little more background on my system. It's an ARM family processor and
I'm using the Yocto Project's Poky distribution on my system. The default
image for that build uses sysVinit and is setup for ifup/ifdown.
Post by Bryan EvensonSo if I wanted to use ifplugd, is the suggestion that I include runsvdir and
runsv in my Busybox configuration and use it to run ifplugd?
If you want to use ifplugd, use it.
Namely, decide where to start it, and what to put into its helper script.
Post by Bryan EvensonI'm unclear what runsvdir is doing that sysVinit can't.
There are plenty of stuff about daemontools and runsvdir on Google.
A very short synopsis: runsvdir babysits processes just like sysVinit does for
you can add/remove/start/stop these babysitted processes without sending
signals or editing text config file.
Post by Bryan EvensonIf not ifup, what would you suggest? I'm open to ideas, just looking
for the simplest path to get to where I want to go.
The very simplest path wouldn't work: you can't design your networking for a
single wired ethernet with static address or DHCP, and then start bolting on
hacks to make it work with wifi, more than one interface, vpn's, dynamic
firewalling etc. It would be a horrifying mess.
I went through that path already.
Agreed, trying to do all that with either a static IP address or with DHCP would be a horrifying mess. I'm not looking for something that complicated. We have one Ethernet port on our board, and there are instances that we would want to direct connect a laptop to the board for pulling data off of the board, etc. My thought would be the easiest way to do that would be to just have it use a known static IP address if DHCP failed. We do have a secondary static IP address right now that is live all the time at eth0:0, but we want to get away from that for some of the reasons you mentioned.
So back to my original question: assuming I use ifplugd in a sysVinit for automatically starting DHCP when someone plugs in the Ethernet cable (and I get that working), is there a good way with ifplugd (or udhcpc for that matter) to set a static IP address if DHCP fails?
Thanks,
Bryan
http://busybox.net/~vda/no_ifup.txt