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.

I have a few mount commands that I want to run on connecting to a specific network. So far I've tried using NetworkManager's dispatch functionality, inspecting the UUID:

uuid=7047cbdb-6477-4f1b-8796-1f44a003c043

if [ "${CONNECTION_UUID}" == "${uuid}" ]; then
...

That fails since the UUID of a connection seems to change on reboot. (I've verified that the script works if I modify the UUID to match the current one, then bring down the network, then bring it up again).

Is NetworkManager even the correct tool to use for this?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

This question suggests exactly what you are doing, so it's interesting that the UUID seems to change on reboot.

However, one of the comments mentions another method. Put a script in /etc/network/if-up.d, and it should run every time you connect to a network. You can put in something like iwconfig | grep -q "some SSID" to test whether you are connected to a specific network (maybe you could use MAC address as well).

share|improve this answer
    
Yeah that is interesting, I think I'll have to dig deeper into this. The one obvious thing that differs is that the network I'm connecting to is wired. I don't know if that is what causes the UUID to change each time. –  Magnus Apr 27 at 7:37
1  
One of the comments (askubuntu.com/questions/13963/…) hints at the answer: in order to not have the UUID change on each reboot I had to configure the wired connection rather than rely on the transient, automatically created config. –  Magnus Apr 28 at 7:47

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.