From: Bertrik Sikken <bertrik@zonnet.nl>
To: linux-hotplug@vger.kernel.org
Subject: Re: Run script when USB scanner unplugged
Date: Sat, 05 Jun 2004 18:26:39 +0000 [thread overview]
Message-ID: <40C2105F.9020705@zonnet.nl> (raw)
In-Reply-To: <40BE3850.8070106@comcast.net>
Ian Pilcher wrote:
> Greg KH wrote:
>
>> On Wed, Jun 02, 2004 at 03:28:00PM -0500, Ian Pilcher wrote:
>>
>>> Running Fedora Core 2 here. I've found that the hotplug scripts shipped
>>> with the distribution do a fine job of setting the permissions when a
>>> USB scanner is plugged in *after* a user has logged in.
>>
>>
>>
>> There is no /dev node for a USB scanner anymore, as there is no kernel
>> driver for it in 2.6. Do you realize this? Because of this, modifying
>> the hotplug scripts will be quite difficult, and udev will know nothing
>> about this kind of device, sorry.
>>
>
> /etc/hotplug/usb/libusbscanner, as shipped with Fedora Core 2, already
> sets the ownership of the appropriate /proc/bus/usb/... file to the
> "console" user. This works fine when a scanner is plugged in *after*
> the user has logged on.
>
> I've hacked /etc/hotplug/usb/libusbscanner to create a symbolic link
> from /dev/usb/scanner-%sys%devices%pci%... to that /proc/bus/usb...
> file. When the USB "insertion" is processed during system boot, the
> symlink gets created. Then when a "console" user logs on, PAM follows
> the symlink and sets the ownership of the /proc/bus/usb... file
> appropriately.
>
> All I want to do is run a script during the USB "remove" event to get
> rid of this symlink. Reading through /etc/hotplug/usb.agent, it looks
> like I should be able to put a script in the location specified by the
> ${REMOVER} variable, but I've tried this and it never gets executed.
>
> What do I need to do?
I'm not really an expert with hotplug, however I got remove to work
after a bit of experimentation (and some minimal testing).
On the 'add' event, the user script create a symbolic link at
$REMOVER to itself. When the remove occurs, the same script is
called again, but now with ACTION=remove.
Kind regards,
Bertrik
(my script follows)
#!/bin/bash
# hack: wait 1 second to improve chance that /proc/bus/usb file is
present during add
sleep 1
# handle add event
if [ "${ACTION}" = "add" ] && [ -f "${DEVICE}" ]
then
logger -t netmd NetMD plugged in at $DEVICE
chown root.usb $DEVICE
chmod ug+w $DEVICE
# create symbolic link for remove event
ln -s /etc/hotplug/usb/minidisc $REMOVER
fi
# handle remove event
if [ "${ACTION}" = "remove" ]
then
logger -t netmd NetMD unplugged from $DEVICE
fi
-------------------------------------------------------
This SF.Net email is sponsored by the new InstallShield X.
From Windows to Linux, servers to mobile, InstallShield X is the one
installation-authoring solution that does it all. Learn more and
evaluate today! http://www.installshield.com/Dev2Dev/0504
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
next prev parent reply other threads:[~2004-06-05 18:26 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-06-02 20:28 Run script when USB scanner unplugged Ian Pilcher
2004-06-03 8:34 ` Harald Hoyer
2004-06-03 17:36 ` Ian Pilcher
2004-06-04 13:55 ` Ian Pilcher
2004-06-04 17:07 ` Bertrik Sikken
2004-06-04 21:13 ` Greg KH
2004-06-05 16:01 ` Ian Pilcher
2004-06-05 16:05 ` Greg KH
2004-06-05 17:35 ` Ian Pilcher
2004-06-05 17:36 ` Ian Pilcher
2004-06-05 18:26 ` Bertrik Sikken [this message]
2004-06-08 0:30 ` Marcelo Ricardo Leitner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=40C2105F.9020705@zonnet.nl \
--to=bertrik@zonnet.nl \
--cc=linux-hotplug@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.