OpenWrt Forum Archive

Topic: shell scripts executed before interface down or after interface up?

The content of this topic has been archived on 1 May 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

What should I do to have some shell scripts executed before interface down or after interface up?

Does netifd provide such interfaces?

I noticed that most luci related tasks invoke "ubus call network reload", this is tricky, I haven't understand the full logic inside.
Can anyone give me an advice that where's the right point to do the hack?

I also want my shell script to cover cases like "ifconfig xxx down/up", is it possible (without changing code in busybox) ?

(Last edited by nossiac on 11 Mar 2014, 04:43)

What do you want to do? What do you mean by saying :" What should I do to have some shell scripts executed before interface down or after interface up?"

Actually I am reading the scripts , maybe we can have some discussion about that?

http://wiki.openwrt.org/doc/techref/hotplug

Save the example script at /etc/hotplug.d/iface/99-my-action.

#!/bin/sh

[ "$ACTION" = ifup ] && {
  logger -t button-hotplug Device: $DEVICE / Action: $ACTION
}
Every time an interface goes up then the if/fi statement will be executed.

@Wandy

i'm about to wade through the complete hotplug-related scripts to document "where is what and how"

see https://forum.openwrt.org/viewtopic.php?id=48017

btw. it touches the whole system as of

           procd + udev(uevent)  + ubus +  ubox+ netifd + json data & scripts

Is there an overall-concept-documentation to be found somewhere? Couldnt find any until now !

Maybe creating a separate thread to work that out ?

regards
3zl

(Last edited by 3zl on 11 Mar 2014, 16:10)

Wandy wrote:

What do you want to do? What do you mean by saying :" What should I do to have some shell scripts executed before interface down or after interface up?"

Actually I am reading the scripts , maybe we can have some discussion about that?

Yes of course.
I am reading the source code of netifd recently.

neryba wrote:

http://wiki.openwrt.org/doc/techref/hotplug

Save the example script at /etc/hotplug.d/iface/99-my-action.

#!/bin/sh

[ "$ACTION" = ifup ] && {
  logger -t button-hotplug Device: $DEVICE / Action: $ACTION
}
Every time an interface goes up then the if/fi statement will be executed.

That looks like what I am looking for.
let me try it out, thank you!

3zl wrote:

@Wandy

i'm about to wade through the complete hotplug-related scripts to document "where is what and how"

see https://forum.openwrt.org/viewtopic.php?id=48017

btw. it touches the whole system as of

           procd + udev(uevent)  + ubus +  ubox+ netifd + json data & scripts

Is there an overall-concept-documentation to be found somewhere? Couldnt find any until now !

Maybe creating a separate thread to work that out ?

regards
3zl


I want to make a change in LuCI. Exactly, I want to figure out how the config files in /etc/config are parsed by the shell scripts, especially the wireless config and change some option of it.  But the problem is I can't find which script handle this work. Do you have any idea?

Wandy wrote:
3zl wrote:

@Wandy

i'm about to wade through the complete hotplug-related scripts to document "where is what and how"

see https://forum.openwrt.org/viewtopic.php?id=48017

btw. it touches the whole system as of

           procd + udev(uevent)  + ubus +  ubox+ netifd + json data & scripts

Is there an overall-concept-documentation to be found somewhere? Couldnt find any until now !

Maybe creating a separate thread to work that out ?

regards
3zl


I want to make a change in LuCI. Exactly, I want to figure out how the config files in /etc/config are parsed by the shell scripts, especially the wireless config and change some option of it.  But the problem is I can't find which script handle this work. Do you have any idea?

There are 2 different things, but related to each other.
1. luci parses the config files to generate its webpages, and user settings will be written back to config files.
2. shell scripts parses config files then apply those settings to a specific module/driver.

neryba wrote:

http://wiki.openwrt.org/doc/techref/hotplug

Save the example script at /etc/hotplug.d/iface/99-my-action.

#!/bin/sh

[ "$ACTION" = ifup ] && {
  logger -t button-hotplug Device: $DEVICE / Action: $ACTION
}
Every time an interface goes up then the if/fi statement will be executed.

I tried this, but it didn't work as expected.
this hotplug wiki seems to be out of date, since there's no such folder in the trunk anymore.
https://dev.openwrt.org/browser/trunk/package/hotplug2

I am using the trunk branch, any idea?

nossiac wrote:
Wandy wrote:
3zl wrote:

@Wandy

i'm about to wade through the complete hotplug-related scripts to document "where is what and how"

see https://forum.openwrt.org/viewtopic.php?id=48017

btw. it touches the whole system as of

           procd + udev(uevent)  + ubus +  ubox+ netifd + json data & scripts

Is there an overall-concept-documentation to be found somewhere? Couldnt find any until now !

Maybe creating a separate thread to work that out ?

regards
3zl


I want to make a change in LuCI. Exactly, I want to figure out how the config files in /etc/config are parsed by the shell scripts, especially the wireless config and change some option of it.  But the problem is I can't find which script handle this work. Do you have any idea?

There are 2 different things, but related to each other.
1. luci parses the config files to generate its webpages, and user settings will be written back to config files.
2. shell scripts parses config files then apply those settings to a specific module/driver.


Yeah, you are right. Now I am interested in the second one.  But I can't find the related scripts.  Will you please give me some clue about that?

3zl wrote:

Is there an overall-concept-documentation to be found somewhere? Couldnt find any until now !

Maybe creating a separate thread to work that out ?

Yeah, you have to read the source code until now. I think there is no other detailed documentation at this time.

Sorry, I can't give you any better info yet..

The discussion might have continued from here.