You are not logged in.

#1 2010-05-04 08:55:32

demian
Member
From: Frankfurt, Germany
Registered: 2009-05-06
Posts: 709

/etc/network/if-{up,down}.d in arch

Hi everyone,

in Debian, there are two folders in which you can put scripts that should be run whenever an interface goes up or down.
I've (probably) found it for ppp and i know that if i used /etc/rc.d/network to control the network i could just add scripts to the appropriate functions in the daemon.
What i need is a more general approach without having to edit various daemons or system files, preferably just place scripts somewhere.
Did i miss it or is there just no debian /etc/network/if-{up,down}.d equivalent in arch?

Regards,
demian

Last edited by demian (2010-05-04 08:56:37)


no place like /home
github

Offline

#2 2010-05-04 09:00:30

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: /etc/network/if-{up,down}.d in arch

Use netcfg, it has pre-up/down and post-up/down support.

Offline

#3 2010-05-04 10:13:13

demian
Member
From: Frankfurt, Germany
Registered: 2009-05-06
Posts: 709

Re: /etc/network/if-{up,down}.d in arch

Thanks, netcfg seems to be a valid choice.
However, I'm porting a debian application to arch linux and i don't want the application to depend on any more than necessary, especially if it's a daemon that could conflict with the network configuration of some people.

To be specific, i need to run a hook after the wireless interface is put up.

Last edited by demian (2010-05-04 10:16:03)


no place like /home
github

Offline

#4 2010-05-04 11:14:17

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: /etc/network/if-{up,down}.d in arch

I don't understand your problem then. You don't want the app to depend on netcfg - is that it?

Offline

#5 2010-05-05 01:14:11

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,230
Website

Re: /etc/network/if-{up,down}.d in arch

Here's a patch for /etc/rc.d/network that will allow /etc/conf.d/ifup-eth0 and /etc/conf.d/ifdown-eth0 to be run as post-up and pre-down hooks:

--- network.ORIG    2010-05-05 21:10:48.852131614 +1000
+++ network    2010-05-05 21:12:54.585458534 +1000
@@ -41,6 +41,10 @@
     else
         /sbin/ifconfig $ifcfg
     fi
+
+    # Post-up Hook
+    [ -x "/etc/conf.d/ifup-$ifname" ] && /etc/conf.d/ifup-$ifname
+
     return $?
 }
 
@@ -63,6 +67,9 @@
 
 ifdown()
 {
+    # Pre-down Hook
+    [ -x "/etc/conf.d/ifdown-$ifname" ] && /etc/conf.d/ifdown-$ifname
+
     if [ "$1" = "" ]; then
         echo "usage: $0 ifdown <interface_name>"
         return 1

Offline

#6 2010-05-05 07:46:37

demian
Member
From: Frankfurt, Germany
Registered: 2009-05-06
Posts: 709

Re: /etc/network/if-{up,down}.d in arch

So, i guess there's no universal way to do this? I mean, some people are using network, others wicd or network manager. I'd have to patch all of these to make this particular function of the application i'm adapting work on every machine it gets installed on.
Maybe I'll do that but don't you think it's a bit intrusive. It's just a hook but I'm still changing important network daemons.

Thanks for your suggestions.

Regards,
demian

Last edited by demian (2010-05-05 07:47:15)


no place like /home
github

Offline

#7 2010-05-05 08:30:28

sand_man
Member
From: Australia
Registered: 2008-06-10
Posts: 2,164

Re: /etc/network/if-{up,down}.d in arch

Well what do you expect? It's not a standard in anyway so every distro has the option to implement something like this. This is why some programs are not portable, when people start using non standard ways of doing things.


neutral

Offline

#8 2010-05-05 08:36:40

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: /etc/network/if-{up,down}.d in arch

No, you don't have to patch anything. The Arch way of doing this is to provide the user with the information they need to implement the hook themselves with their chosen network management utility. netcfg, wicd, and networkmanager can all "run a hook after the wireless interface is put up", which is your specific requirement as posted above. Anyone who uses the basic network init script should be advised that they need to install and configure one of those three utilities to use your application.

Offline

#9 2010-05-05 08:37:55

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: /etc/network/if-{up,down}.d in arch

One more thing - what is this app anyway? smile

Offline

#10 2010-05-05 09:06:12

demian
Member
From: Frankfurt, Germany
Registered: 2009-05-06
Posts: 709

Re: /etc/network/if-{up,down}.d in arch

It's more a collection of bash scripts than an app, really. Much like laptop-mode-tools, but originally written for Ubuntu and ThinkPad laptops as a special target. It has some additional features like setting battery charge thresholds for ThinkPad laptops, some docking station mechanisms, control of phc-intel values etc.
One of these features is applying certain wifi settings whenever the wifi card gets enabled.

Regards,
demian


no place like /home
github

Offline

#11 2010-05-05 13:44:33

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,230
Website

Re: /etc/network/if-{up,down}.d in arch

tomk wrote:

The Arch way of doing this is to provide the user with the information they need to implement the hook themselves with their chosen network management utility.

That is definitely the Arch-way of doing this, since there are so many options that users *could* be using smile

Offline

Board footer

Powered by FluxBB