View previous topic :: View next topic |
Author |
Message |
micron Guru
![Guru Guru](/images/ranks/rank_rect_3.gif)
![](images/avatars/3680636553f92ac21ef702.jpg)
Joined: 23 Jul 2003 Posts: 411 Location: Bergamo, Italy
|
Posted: Mon Mar 08, 2004 2:06 pm Post subject: configurazione hotplug [RISOLTO] |
|
|
Vorrei semplicemente eseguire dei comandi quando il mouse usb viene inserito e tolto dal portatile, ho quindi pensato di ricorrere ad hotplug.
Dato che la documentazione è abbastanza scarsa ho cercato di interpretare i vari script bash che vengono chiamat,i ma purtroppo non sono riuscito a togliermi un dubbio.
Innanzi tutto il mouse usb è una periferica di input, quindi dovrò agire su
Code: | /etc/hotplug/input.agent |
Guardanda all'interno del file si trova:
Code: | case $ACTION in
add)
input_convert_vars
FOUND=false
LABEL="INPUT product $PRODUCT"
if [ -r $MAP_CURRENT ]; then
load_drivers input $MAP_CURRENT "$LABEL"
fi
if [ "$DRIVERS" != "" ]; then
FOUND=true
fi
if [ "$FOUND" = "false" ]; then
mesg "... no modules for $LABEL"
exit 2
fi
;;
remove)
: nothing so far
;;
*)
debug_mesg INPUT $ACTION event not supported
exit 1
;;
esac |
ho provato a mettere delle azioni dentro
Code: | if [ "$DRIVERS" != "" ]; then
FOUND=true
fi |
ma da quanto ho visto questo if non si realizza mai, nonstante il mouse sia trovato, ed il suo modulo sia caricato... Ho risolto mettendo lo script da eseguire dentro
Code: | /etc/hotplug/hotplug.functions |
(se a qualcuno interessa sapere come me lo chieda pure )
Il vero problema ora è eseguire il comando alla rimozione del mouse, infatti nel blocco
Code: | remove)
: nothing so far
;; |
non so come identificare il nome della periferica scollagata... persino in
Code: | /etc/hotplug/hotplug.functions |
non sono riuscito a trovare un punto in cui andare a fare il controllo sulla periferica tolta (per poi agire di conseguenza)...
nessuno mi può dare una dritta? _________________ ~ "Progress is merely a realisation of utopias" ~
Last edited by micron on Mon Mar 08, 2004 9:18 pm; edited 1 time in total |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
antenore n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
![](images/avatars/gallery/Diablo/Diablo_2_-_Necromancer.gif)
Joined: 15 Jul 2003 Posts: 46
|
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
micron Guru
![Guru Guru](/images/ranks/rank_rect_3.gif)
![](images/avatars/3680636553f92ac21ef702.jpg)
Joined: 23 Jul 2003 Posts: 411 Location: Bergamo, Italy
|
Posted: Mon Mar 08, 2004 3:12 pm Post subject: |
|
|
La guida non risolve i miei dubbi dato che non è ne parla...
Già cercato... nada ![Sad :(](images/smiles/icon_sad.gif) _________________ ~ "Progress is merely a realisation of utopias" ~ |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
dnix Apprentice
![Apprentice Apprentice](/images/ranks/rank_rect_2.gif)
![](images/avatars/3563391504157de442a70b.jpg)
Joined: 17 Jun 2003 Posts: 271 Location: Italy
|
Posted: Mon Mar 08, 2004 3:23 pm Post subject: |
|
|
solleviamo un altro dubbio (dovuto forse a causa della mia pigrizia):
come faccio a montare automaticamente a quei cari utenti di gnome la loro chiavina usb senza insegnarli mount etc etc?
ciao e scusate l'interferenza,
Denis |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
antenore n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
![](images/avatars/gallery/Diablo/Diablo_2_-_Necromancer.gif)
Joined: 15 Jul 2003 Posts: 46
|
Posted: Mon Mar 08, 2004 3:29 pm Post subject: |
|
|
Purtroppo non ho mai usato hotplug in modo così tosto...
Però ho dato un'occhiata a questa guida
http://www.linuxjournal.com/article.php?sid=5604 e sembra molto chiara...
quello che sembra importante estrapolare è l'identificativo del device e in particolare:
Quote: | USB
USB devices call /sbin/hotplug with the following arguments:
argv [0] = hotplug_path
argv [1] = "usb"
argv [2] = 0
and the system environment is set to the following:
HOME=/
PATH=/sbin:/bin:/usr/sbin:/usr/bin
ACTION=action
PRODUCT=idVendor/idProduct/bcdDevice
TYPE=device_class/device_subclass/device_protocol
The action setting is ``add'' or ``remove'' depending on whether the device is being inserted or removed from the system, and idVendor, idProduct, bcdDevice, device_class, device_subclass and device_protocol are filled in with the information from the USB device's descriptors.
If the USB device's deviceClass is 0 then the environment variable INTERFACE is set to:
INTERFACE=class/subclass/protocol
This is because USB has a much more complex model for device configuration than PCI does.
If the USB subsystem is compiled with the usbdevfs filesystem enabled, the following environment variables also are set:
DEVFS=/proc/bus/usb
DEVICE=/proc/bus/usb/bus_number/device_number
where bus_number and device_number are set to the bus number and device number that this specific USB device is assigned.
Network
The network core code calls /sbin/hotplug whenever a network device is registered or unregistered with the network subsystem, and /sbin/hotplug is called with the following arguments when called from the network core:
argv [0] = hotplug_path
argv [1] = "net"
argv [2] = 0
and the system environment is set to the following:
HOME=/
PATH=/sbin:/bin:/usr/sbin:/usr/bin
INTERFACE=interface
ACTION=action
The action setting is ``register'' or ``unregister'' depending on what happened in the network core, and interface is the name of the interface that just had the action applied to itself. |
|
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
silian87 Advocate
![Advocate Advocate](/images/ranks/rank-G-1-advocate.gif)
![](images/avatars/611424389404f8bcc764f4.jpg)
Joined: 06 Oct 2003 Posts: 2318 Location: Treviso, Italy
|
Posted: Mon Mar 08, 2004 3:37 pm Post subject: |
|
|
Quote: | come faccio a montare automaticamente a quei cari utenti di gnome la loro chiavina usb senza insegnarli mount etc etc? |
Devi compilare il kernel con l'opzione supermount, e poi devi modificare l'fs-tab. Ti verra' una cosa in stile mandkrake. Cerca un po' in giro a riguardo di questi argomenti... _________________ Musica che ascolto: http://www.last.fm/user/silian87/
Silian87 FAQs: http://marentax.homelinux.org/~silian87/silian87-faq.txt
GTalk: silian87@gmail.com |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
silian87 Advocate
![Advocate Advocate](/images/ranks/rank-G-1-advocate.gif)
![](images/avatars/611424389404f8bcc764f4.jpg)
Joined: 06 Oct 2003 Posts: 2318 Location: Treviso, Italy
|
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
motaboy Retired Dev
![Retired Dev Retired Dev](/images/ranks/rank-retired.gif)
![](images/avatars/146642313240262a7185133.png)
Joined: 15 Dec 2003 Posts: 1483
|
Posted: Mon Mar 08, 2004 6:21 pm Post subject: |
|
|
In teoria non è corretto modificare input.agent o gli altri agenti.
Infatti da quanto dice "man hotplug" e sul sito http://linux-hotplug.sf.net questi agenti chiamano a loro volta script definiti dall''utente nella directory:
/etc/hotplug/NAME/DRIVER driver setup scripts, invoked by agents
Dove NAME nel tuo caso è "input" e DRIVER è il nome del modulo associato alla periferica.
percio nella directory /etc/hotplug/input dovresti fare uno script col nome del modulo relativo al mouse e cui dentro mettere le istruzioni da eseguire.
Al tuo script vengono passate le stesse variabili di ambiente passate all'agente, perciò da esse puoi determinare se la periferica è stata collegata o scollegata, il tipo ed altre informazioni (vedi il sito).
Quindi la prima cosa da fare è sapere il nome del modulo relativo al mouse, io ho provato col mio mouse PS2 e per sicurezza ho usato evdev e funziona ma non so se funziona anche se il modulo è compilato staticamente nel kernel... mi sa di no ma bisognerebbe provare.
Perciò prova a fare un file /etc/hotplug/input/evdev (non è il metodo corretto perchè esso viene chiamato tante volte)
scrivere le istruzioni che vuoi eseguire (dovresti mettere il riconoscimento della periferica per evitare che le istruzioni vengano eseguite sempre!)
spero ti possa servire.
Bye! _________________ ... |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
motaboy Retired Dev
![Retired Dev Retired Dev](/images/ranks/rank-retired.gif)
![](images/avatars/146642313240262a7185133.png)
Joined: 15 Dec 2003 Posts: 1483
|
Posted: Mon Mar 08, 2004 7:31 pm Post subject: |
|
|
Ho pensato che potresti anche usare uno script in /etc/hotplug/usb visto che il tuo mouse è USB e come nome dello script il modulo del mouse.
Per montare le schede di memoria c'era un'altro script hotplug molto valido messo sul forum:
https://forums.gentoo.org/viewtopic.php?t=113911
non il primo script fornito ma uno pubblicato dopo che usa hotplug e che è anche apparso sulle gentoo weekly news
e che trovi qua:
http://dev.gentoo.org/~wmertens/automount.hotplug
per i kernel 2.6
Bye! _________________ ... |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
motaboy Retired Dev
![Retired Dev Retired Dev](/images/ranks/rank-retired.gif)
![](images/avatars/146642313240262a7185133.png)
Joined: 15 Dec 2003 Posts: 1483
|
Posted: Mon Mar 08, 2004 7:46 pm Post subject: |
|
|
Ok visto che era un pò che non scrivevo ho notato guardando lo script di mount delle memory script che puoi aggirare direttamente gli agenti in modo che lo script funzioni anche se il modulo è caricato staticamente.
Infatti nella dir /etc/hotplug.d
puoi fare vari script per ogni classe di periferiche.
per esempio in default c'è quello di hotplug che chiama gli agenti, questo è lo script vero e proprio chiamato da /sbin/hotplug
Cosi ho fatto una dir "input" e vi ho messo dentro lo script che ho chiamato (per esempio) input.hotplug.
Adesso ogni volta che avviene un evento relativo all'input questo script viene chiamato.
Puoi fare lop stesso facendo una dir di nome "usb" e mettendo uno script qui, in questo modo ogni volta che colleghi/scollleghi una periferica usb questo script viene chiamato.
Ti consiglio di guardare come funziona lo script per montare le chiavi usb.
Bye! _________________ ... |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
micron Guru
![Guru Guru](/images/ranks/rank_rect_3.gif)
![](images/avatars/3680636553f92ac21ef702.jpg)
Joined: 23 Jul 2003 Posts: 411 Location: Bergamo, Italy
|
Posted: Mon Mar 08, 2004 9:17 pm Post subject: |
|
|
motaboy wrote: | Infatti nella dir /etc/hotplug.d
puoi fare vari script per ogni classe di periferiche.
per esempio in default c'è quello di hotplug che chiama gli agenti, questo è lo script vero e proprio chiamato da /sbin/hotplug |
Ahi ragione, non l'avevo notato!!
motaboy wrote: | Cosi ho fatto una dir "input" e vi ho messo dentro lo script che ho chiamato (per esempio) input.hotplug.
Adesso ogni volta che avviene un evento relativo all'input questo script viene chiamato.
|
Ho fatto lo stesso, ovvero ho creato la dir:
Code: | /etc/hotplug.d/input |
dentro cui ho messo il mio script, ma in verità ho notato che viene chiamato una sola volta...
Per rimediare l'ho messo all'interno di:
Code: | /etc/hotplug.d/default/ |
chiamandolo
Ora funziona tutto alla meraviglia!!
Grazie mille! ![Smile :)](images/smiles/icon_smile.gif) _________________ ~ "Progress is merely a realisation of utopias" ~ |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
|