Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
udev rule problem [solved]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
DaggyStyle
Advocate
Advocate


Joined: 22 Mar 2006
Posts: 4883

PostPosted: Wed Jun 05, 2013 6:03 pm    Post subject: udev rule problem [solved] Reply with quote

Hello all,

I want to run a program when a partition becomes visible and unvisible, so I wrote the following udev rule:
Code:

ACTION=="add", KERNEL=="sd[b-z][0-9]", ENV{ID_FS_UUID}=="01fdb30e-f5a8-424a-8917-c2e215371416", RUN+="/usr/local/bin/backup.sh start", OPTIONS="last_rule"
ACTION=="remove", KERNEL=="sd[b-z][0-9]", ENV{ID_FS_UUID}=="01fdb30e-f5a8-424a-8917-c2e215371416"", RUN+="/usr/local/bin/backup.sh stop", OPTIONS="last_rule"


problem is, the rules definition doesn't works.
does anyone spots my error?

Thanks.
_________________
Only two things are infinite, the universe and human stupidity and I'm not sure about the former - Albert Einstein
ProjectFootball


Last edited by DaggyStyle on Thu Jun 06, 2013 6:22 pm; edited 1 time in total
Back to top
View user's profile Send private message
PaulBredbury
Watchman
Watchman


Joined: 14 Jul 2005
Posts: 7310

PostPosted: Wed Jun 05, 2013 7:45 pm    Post subject: Reply with quote

Maybe rule ordering.

Use a rule filename of > 60, so it is run after the ENV vars have been set up.
Back to top
View user's profile Send private message
DaggyStyle
Advocate
Advocate


Joined: 22 Mar 2006
Posts: 4883

PostPosted: Wed Jun 05, 2013 8:07 pm    Post subject: Reply with quote

PaulBredbury wrote:
Maybe rule ordering.

Use a rule filename of > 60, so it is run after the ENV vars have been set up.


I run it in level 80 so I think this isn't the issue
_________________
Only two things are infinite, the universe and human stupidity and I'm not sure about the former - Albert Einstein
ProjectFootball
Back to top
View user's profile Send private message
PaulBredbury
Watchman
Watchman


Joined: 14 Jul 2005
Posts: 7310

PostPosted: Wed Jun 05, 2013 8:13 pm    Post subject: Reply with quote

Then debug it.

In /etc/udev/rules.d/91-local.rules (add an additional filter on whatever you're interested in, before the RUN)
Code:
RUN+="/root/bin/test-udev-env"


In /root/bin/test-udev-env
Code:
#!/bin/bash

export > /root/export.txt

And:
Code:
chmod 700 /root/bin/test-udev-env


Then you can see all the ENV variables.
Back to top
View user's profile Send private message
DaggyStyle
Advocate
Advocate


Joined: 22 Mar 2006
Posts: 4883

PostPosted: Wed Jun 05, 2013 8:58 pm    Post subject: Reply with quote

PaulBredbury wrote:
Then debug it.

In /etc/udev/rules.d/91-local.rules (add an additional filter on whatever you're interested in, before the RUN)
Code:
RUN+="/root/bin/test-udev-env"


In /root/bin/test-udev-env
Code:
#!/bin/bash

export > /root/export.txt

And:
Code:
chmod 700 /root/bin/test-udev-env


Then you can see all the ENV variables.


is there a way to trigger the rules sweep and make it verbose?
_________________
Only two things are infinite, the universe and human stupidity and I'm not sure about the former - Albert Einstein
ProjectFootball
Back to top
View user's profile Send private message
DaggyStyle
Advocate
Advocate


Joined: 22 Mar 2006
Posts: 4883

PostPosted: Thu Jun 06, 2013 5:29 am    Post subject: Reply with quote

I didn't got the chance to test it yet but I think that ID_FS_UUID is my issue, I want to detect based on a specific partition, ID_FS_UUID isn't for partitions, ID_PART_ENTRY_UUID is.

so I modified the file to be the following:
Code:

ACTION=="add", KERNEL=="sd[b-z][0-9]", ENV{ID_PART_ENTRY_UUID}=="01fdb30e-f5a8-424a-8917-c2e215371416", RUN+="/usr/local/bin/backup.sh start", OPTIONS="last_rule"
ACTION=="remove", KERNEL=="sd[b-z][0-9]", ENV{ID_PART_ENTRY_UUID}=="01fdb30e-f5a8-424a-8917-c2e215371416"", RUN+="/usr/local/bin/backup.sh stop", OPTIONS="last_rule"


will check it later on today.
_________________
Only two things are infinite, the universe and human stupidity and I'm not sure about the former - Albert Einstein
ProjectFootball
Back to top
View user's profile Send private message
DaggyStyle
Advocate
Advocate


Joined: 22 Mar 2006
Posts: 4883

PostPosted: Thu Jun 06, 2013 6:22 pm    Post subject: Reply with quote

I'm happy to report that it working :)
_________________
Only two things are infinite, the universe and human stupidity and I'm not sure about the former - Albert Einstein
ProjectFootball
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum