Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

1 Answer 1

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

#!/bin/sh
/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

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.