you need a file not a dir
/etc/dhclient-exit-hooks should be your script
put something like this at the top for more logging
Ahhh, I see. Thanks for the clarification. I feel as if I am very close to achieving my goal.
So after making that correction. my dhclient-exit-hooks script seems to work, somewhat. It seems to detect when I connect an ethernet cable and establish a connection, however it does not detect when I remove it. On the contrary, when using the devd.conf rules, it seems to detect when the ethernet cable is removed, but not re-inserted. When both are implemented together, they accomplish what I am trying to achieve. However I feel as one of these implementations should be able to handle what I need., not both. If I am wrong please let me know. Worse case scenario is that I implement both. Below are both scripts.
For some clarification, I am testing this by running an executable called "displayip" which simply makes an ifconfig call and tells me the status and ip (if there is one) of the relative network interface. In the dhclient-exit-hooks script, I added pretty much all of the available reasons as so that the network interface status information is kept up to date in real time. Could that be the source of my issue?
Also the same logic I applied with the devd.conf rules. I added both "ATTACH" and "DETACH" as types because my initial testing with "LINK_UP" and "LINK_DOWN" only resulted in "LINK_DOWN" working.
dhclient-exit-hooks:
Bash:
#!/bin/bash
exec >>/tmp/dhclient.log 2>&1
date "+==============%Y-%m-%d %H:%M:%S================"
set -x
if [ "${interface}" = "em0" ] || [ "${interface}" = "em1" ] || [ "${interface}" = "igb0" ] || [ "${interface}" = "igb1" ]; then
case "${reason}" in BOUND|RENEW|REBIND|REBOOT|EXPIRE|FAIL|TIMEOUT|MEDIUM|PREINIT)
/usr/home/develop/Display/displayip
;;
esac
fi
displayip.conf:
Code:
notify 0 {
match "system" "IFNET";
match "subsystem" "(em0|em1|igb0|igb1)";
match "type" "LINK_DOWN";
action "/usr/home/develop/Display/displayip";
notify 0 {
match "system" "IFNET";
match "subsystem" "(em0|em1|igb0|igb1)";
match "type" "LINK_UP";
action "/usr/home/develop/Display/displayip";
};
notify 0 {
match "system" "IFNET";
match "subsystem" "(em0|em1|igb0|igb1)";
match "type" "ATTACH";
action "/usr/home/develop/Display/displayip";
};
notify 0 {
match "system" "IFNET";
match "subsystem" "(em0|em1|igb0|igb1)";
match "type" "DETACH";
action "/usr/home/develop/Display/displayip";
}