View previous topic :: View next topic |
Author |
Message |
DaggyStyle Watchman
Joined: 22 Mar 2006 Posts: 5909
|
Posted: Wed Jun 05, 2013 6:03 pm Post subject: udev rule problem [solved] |
|
|
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
Last edited by DaggyStyle on Thu Jun 06, 2013 6:22 pm; edited 1 time in total |
|
Back to top |
|
|
PaulBredbury Watchman
Joined: 14 Jul 2005 Posts: 7310
|
Posted: Wed Jun 05, 2013 7:45 pm Post subject: |
|
|
Maybe rule ordering.
Use a rule filename of > 60, so it is run after the ENV vars have been set up. |
|
Back to top |
|
|
DaggyStyle Watchman
Joined: 22 Mar 2006 Posts: 5909
|
Posted: Wed Jun 05, 2013 8:07 pm Post subject: |
|
|
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 |
|
Back to top |
|
|
PaulBredbury Watchman
Joined: 14 Jul 2005 Posts: 7310
|
Posted: Wed Jun 05, 2013 8:13 pm Post subject: |
|
|
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 |
|
|
DaggyStyle Watchman
Joined: 22 Mar 2006 Posts: 5909
|
Posted: Wed Jun 05, 2013 8:58 pm Post subject: |
|
|
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 |
|
Back to top |
|
|
DaggyStyle Watchman
Joined: 22 Mar 2006 Posts: 5909
|
Posted: Thu Jun 06, 2013 5:29 am Post subject: |
|
|
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 |
|
Back to top |
|
|
DaggyStyle Watchman
Joined: 22 Mar 2006 Posts: 5909
|
Posted: Thu Jun 06, 2013 6:22 pm Post subject: |
|
|
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 |
|
Back to top |
|
|
|