linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* udev rule matching using ENV
@ 2011-07-26 19:15 william
  2011-07-26 19:18 ` william
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: william @ 2011-07-26 19:15 UTC (permalink / raw)
  To: linux-hotplug

Dear list

i am trying to create a udev rule which executes a script whenever a usb 
stick is removed with a particular uuid

The uuid is changeable and we have a common settings file which exports 
the UUID from the usb partition.

What i would like is to import the UUID from the settings file and match 
that with the actual ID_FS_UUID with the remove action.

So i created 99-remove-usb.rules with the following contents

IMPORT{program}="/usr/local/bin/usb-stick-uuid.sh"
ACTION="remove", ENV{ID_FS_UUID}="ENV{MY_UUID}", 
RUN+="/usr/local/bin/usb-removed.sh"

The program usb-stick-uuid.sh now only echo's:
MY_UUIDÿ744c66-3671-447c-8fa0-d96fc6f82352
and nothing else.
But it does never match.

When i enter the uuid by hand in the rule it does work:
ACTION="remove", 
ENV{ID_FS_UUID}="ff744c66-3671-447c-8fa0-d96fc6f82352", 
RUN+="/usr/local/bin/usb-removed.sh"

Am i doing something wrong or is it just the way it works? I also could 
not find any example on the internet matching two ENV strings.

My system:
ubuntu 10.10
udev version 162


^ permalink raw reply	[flat|nested] 4+ messages in thread

* udev rule matching using ENV
  2011-07-26 19:15 udev rule matching using ENV william
@ 2011-07-26 19:18 ` william
  2011-07-26 20:35 ` Kay Sievers
  2011-07-27  4:48 ` william
  2 siblings, 0 replies; 4+ messages in thread
From: william @ 2011-07-26 19:18 UTC (permalink / raw)
  To: linux-hotplug

Dear list

i am trying to create a udev rule which executes a script whenever a usb 
stick is removed with a particular uuid

The uuid is changeable and we have a common settings file which exports 
the UUID from the usb partition.

What i would like is to import the UUID from the settings file and match 
that with the actual ID_FS_UUID with the remove action.

So i created 99-remove-usb.rules with the following contents

IMPORT{program}="/usr/local/bin/usb-stick-uuid.sh"
ACTION="remove", ENV{ID_FS_UUID}="ENV{MY_UUID}", 
RUN+="/usr/local/bin/usb-removed.sh"

The program usb-stick-uuid.sh now only echo's:
MY_UUIDÿ744c66-3671-447c-8fa0-d96fc6f82352
and nothing else.
But it does never match.

When i enter the uuid by hand in the rule it does work:
ACTION="remove", 
ENV{ID_FS_UUID}="ff744c66-3671-447c-8fa0-d96fc6f82352", 
RUN+="/usr/local/bin/usb-removed.sh"

Am i doing something wrong or is it just the way it works? I also could 
not find any example on the internet matching two ENV strings.

My system:
ubuntu 10.10
udev version 162

With kind regards

William

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: udev rule matching using ENV
  2011-07-26 19:15 udev rule matching using ENV william
  2011-07-26 19:18 ` william
@ 2011-07-26 20:35 ` Kay Sievers
  2011-07-27  4:48 ` william
  2 siblings, 0 replies; 4+ messages in thread
From: Kay Sievers @ 2011-07-26 20:35 UTC (permalink / raw)
  To: linux-hotplug

On Tue, Jul 26, 2011 at 21:18, william <kc@cobradevil.org> wrote:
> i am trying to create a udev rule which executes a script whenever a usb
> stick is removed with a particular uuid
>
> So i created 99-remove-usb.rules with the following contents
>
> IMPORT{program}="/usr/local/bin/usb-stick-uuid.sh"
> ACTION="remove", ENV{ID_FS_UUID}="ENV{MY_UUID}",

> But it does never match.

ENV{ID_FS_UUID}="$env{MY_UUID}" ?

Kay

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: udev rule matching using ENV
  2011-07-26 19:15 udev rule matching using ENV william
  2011-07-26 19:18 ` william
  2011-07-26 20:35 ` Kay Sievers
@ 2011-07-27  4:48 ` william
  2 siblings, 0 replies; 4+ messages in thread
From: william @ 2011-07-27  4:48 UTC (permalink / raw)
  To: linux-hotplug

On 07/26/2011 10:35 PM, Kay Sievers wrote:
> On Tue, Jul 26, 2011 at 21:18, william<kc@cobradevil.org>  wrote:
>> i am trying to create a udev rule which executes a script whenever a usb
>> stick is removed with a particular uuid
>>
>> So i created 99-remove-usb.rules with the following contents
>>
>> IMPORT{program}="/usr/local/bin/usb-stick-uuid.sh"
>> ACTION="remove", ENV{ID_FS_UUID}="ENV{MY_UUID}",
>> But it does never match.
> ENV{ID_FS_UUID}="$env{MY_UUID}" ?
>
no match with the $env{MY_UUID}

When i remove this match so it will execute the script i do get the 
MY_UUID in the environment so i know it gets filled.
Also visible when using:
udevadm test --action=remove /block/sdb


William
> Kay
> --
> To unsubscribe from this list: send the line "unsubscribe linux-hotplug" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-07-27  4:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-26 19:15 udev rule matching using ENV william
2011-07-26 19:18 ` william
2011-07-26 20:35 ` Kay Sievers
2011-07-27  4:48 ` william

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).