Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to force a restart of Apache as soon as eth0 (or any network interface for that matter) is plugged in?

Update: Some details why I need this. Our clients use mobile terminals that repeatedly get plugged in and unplugged when they are being moved around (a wireless network is no option unfortunately). The terminal runs a site licensed with ionCube. The license contains a MAC address restriction. Now in case a terminal is booted up, and later plugged in to the network, ionCube complains about an invalid license because it could not detect any ethernet devices at the time Apache was started. ionCube caches the network interface information and does not detect any interfaces coming up after Apache was started.

share|improve this question
This sounds evil. Why do you want to do this? – Ignacio Vazquez-Abrams Feb 15 '11 at 10:49
up vote 2 down vote accepted

If you are using Debian/Ubuntu, use /etc/network/if-up.d , create new file (for example "apache2") with contents like

/etc/init.d/apache2 restart

Change permissions to 755;

chmod 755 /etc/network/if-up.d/apache2

Files in /etc/network/if-down.d, if-post-down.d, if-pre-up.d, if-up.d are executed in appropriate phases when interface goes up or down.

share|improve this answer
Thanks, I am using Debian, works great :) – Ton van den Heuvel Feb 15 '11 at 11:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .