How to execute a script only once, only & immediately after ALL network interfaces are up?

I run Opensuse 12.2.

I have 3 network interfaces, eth[012]

The interfaces are configured in /etc/sysconfig/network/ifcfg-eth[012]

I want to execute a script immediately after ALL three interfaces are ‘up’.

Adding

POST_UP_SCRIPT="/path/to/script.sh"

to ifcfg-eth[012] executes the script after any ONE interface is up.

Placing the script in

/etc/sysconfig/network/if-up.d/script.sh

executes the script multiple times - once after EACH interface is up.

How do I execute the script ONLY ONCE, only & immediately after the last interface is brought up?

On Thu 29 Nov 2012 05:26:01 PM CST, dan a wrote:

I run Opensuse 12.2.

I have 3 network interfaces, eth[012]

The interfaces are configured in /etc/sysconfig/network/ifcfg-eth[012]

I want to execute a script immediately after ALL three interfaces are
‘up’.

Adding

Code:

POST_UP_SCRIPT="/path/to/script.sh"

to ifcfg-eth[012] executes the script after any ONE interface is up.

Placing the script in

Code:

/etc/sysconfig/network/if-up.d/script.sh

executes the script multiple times - once after EACH interface is up.

How do I execute the script ONLY ONCE, only & immediately after the
last interface is brought up?

Hi
Just add a counter in your script so on the third iteration to actually
execute? Or add an ‘and’ statement if x && y && z; do something?


Cheers Malcolm °¿° (Linux Counter #276890)
openSUSE 12.2 (x86_64) Kernel 3.4.11-2.16-desktop
up 2 days 2:10, 4 users, load average: 0.02, 0.04, 0.13
CPU Intel i5 CPU M520@2.40GHz | Intel Arrandale GPU

Just add a counter in your script so on the third iteration to actually
execute? Or add an ‘and’ statement if x && y && z; do something?

I’m looking for a general solution.

Your suggestion presumes that the script ‘knows’ how many interfaces – physical &/or virtual – are enabled.

How do I count them before they’re brought up?

AFTER they are all up,

cat /proc/net/dev

can provide a countable list. But not before …

I’m looking for a “wait until the LAST (not the Nth) enabled interface is up (link detected == yes)” check/trigger.

On Thu 29 Nov 2012 06:06:01 PM CST, dan a wrote:

> Just add a counter in your script so on the third iteration to
> actually execute? Or add an ‘and’ statement if x && y && z; do
> something?

I’m looking for a general solution.

Your suggestion presumes that the script ‘knows’ how many interfaces –
physical &/or virtual – are enabled.

How do I count them before they’re brought up?

AFTER they are all up,

Code:

cat /proc/net/dev

can provide a countable list. But not before …

I’m looking for a “wait until the LAST (not the Nth) enabled interface
is up (link detected == yes)” check/trigger.

Hi
In YaST /etc/sysconfig editor set them as mandatory devices then your
script will only run after they are up.


Cheers Malcolm °¿° (Linux Counter #276890)
openSUSE 12.2 (x86_64) Kernel 3.4.11-2.16-desktop
up 2 days 2:44, 4 users, load average: 0.17, 0.12, 0.16
CPU Intel i5 CPU M520@2.40GHz | Intel Arrandale GPU