Quote:
You absolutely have to have your uuid in the script as that is how it know to run the script.
|
Where is this defined? I see only a vague reference in the man page to $CONNECTION_UUID.
That said, I see part of the problem. NM runs outside any user environment. Originally in my test script I used $TMP rather than /tmp. There was no file in $TMP but eventually I found the file in /. That always happens when environment variables are not defined.
Here is my test script:
Code:
#!/bin/sh
INTERFACE=$1
STATUS=$2
WIRED_UUID="`grep uuid= /etc/NetworkManager/system-connections/Wired | grep -v grep | cut -d = -f 2`"
if [ "$CONNECTION_UUID" = "$WIRED_UUID" ]; then
case $STATUS in
up)
echo "$INTERFACE ($WIRED_UUID) is up." >> /tmp/int-status
;;
down)
echo "$INTERFACE ($WIRED_UUID) is down." >> /tmp/int-status
;;
esac
fi
I named the script 10_test.sh. Permissions are 755, root:root. I have two files /etc/NetworkManager/system-connections: Wired and Wireless. My script greps and grabs the UUID of the wired connection. I could copy and paste the UUID into the script but this way works too.
I rebooted the laptop with the cable connected. I verified the wired connection was active. Then I pulled the cable. The 'nmcli d' command indicated the cable was no longer available. Eventually I found the output file and then changed the output to /tmp.
That said, I then commented out the if and fi statements. The script still works every time I pull and connect the cable. Yes, without the if/fi statements the test script will always respond to any up or down event, although I have not tested toggling the wireless switch.
I suspect another problem is echo statements are not routed to stdout. Without a typical user environment, they disappear into the bit bucket unless redirected to a file or log. That does not explain why previous scripts failed. I'm still foggy about this whole UUID "requirement."
I still have to test re-running the firewall script on an up/down event. I'll post later.