2

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.

1 Answers1

2

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.

Olli
  • 7,631