Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I wonder if system will call my script located in /etc/network/if-up.d/ or /etc/network/if-down.d/ with start or stop. The reason I am asking is that I have a script which can be called with start/stop command line arguments. In order to use with if-up.d I have to split the script into 2 parts. Is there a better way to place the script into /etc/network/if-up.d/ without splitting?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

You could put the real script in one directory, and a symlink to it in the other. Then you could check $0 each time the script gets called, to see which version was invoked. This way you would retain the conveniance to edit the script in one place.

$0 is the variable, which contains the entire path to the script itself when it gets called. You would find a "if-up" or "if-down" as part of the path, and this could be interpreted as start and stop.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.