Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
configurazione hotplug [RISOLTO]
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Forum italiano (Italian)
View previous topic :: View next topic  
Author Message
micron
Guru
Guru


Joined: 23 Jul 2003
Posts: 411
Location: Bergamo, Italy

PostPosted: Mon Mar 08, 2004 2:06 pm    Post subject: configurazione hotplug [RISOLTO] Reply with quote

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 :wink:)

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
View user's profile Send private message
antenore
n00b
n00b


Joined: 15 Jul 2003
Posts: 46

PostPosted: Mon Mar 08, 2004 2:13 pm    Post subject: Reply with quote

Hai guardato questo howto:
http://tldp.org/HOWTO/XFree-Local-multi-user-HOWTO/tweak_input_devs-inputagent1.html

e un pò di googleing...

http://www.google.it/search?hl=it&ie=UTF-8&oe=UTF-8&q=hotplug+usb+mouse+action&btnG=Cerca+con+Google&lr=
Back to top
View user's profile Send private message
micron
Guru
Guru


Joined: 23 Jul 2003
Posts: 411
Location: Bergamo, Italy

PostPosted: Mon Mar 08, 2004 3:12 pm    Post subject: Reply with quote

antenore wrote:
Hai guardato questo howto:
http://tldp.org/HOWTO/XFree-Local-multi-user-HOWTO/tweak_input_devs-inputagent1.html

La guida non risolve i miei dubbi dato che non è ne parla...

antenore wrote:
e un pò di googleing...

http://www.google.it/search?hl=it&ie=UTF-8&oe=UTF-8&q=hotplug+usb+mouse+action&btnG=Cerca+con+Google&lr=

Già cercato... nada :(
_________________
~ "Progress is merely a realisation of utopias" ~
Back to top
View user's profile Send private message
dnix
Apprentice
Apprentice


Joined: 17 Jun 2003
Posts: 271
Location: Italy

PostPosted: Mon Mar 08, 2004 3:23 pm    Post subject: Reply with quote

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
View user's profile Send private message
antenore
n00b
n00b


Joined: 15 Jul 2003
Posts: 46

PostPosted: Mon Mar 08, 2004 3:29 pm    Post subject: Reply with quote

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
View user's profile Send private message
silian87
Advocate
Advocate


Joined: 06 Oct 2003
Posts: 2318
Location: Treviso, Italy

PostPosted: Mon Mar 08, 2004 3:37 pm    Post subject: Reply with quote

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
View user's profile Send private message
silian87
Advocate
Advocate


Joined: 06 Oct 2003
Posts: 2318
Location: Treviso, Italy

PostPosted: Mon Mar 08, 2004 3:41 pm    Post subject: Reply with quote

A parte che se definisci il punto di mount della chiavetta sull'fstab, con il click destro sul desktop di gnome 2.4 puoi montarla e smontarla on the fly.
_________________
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
View user's profile Send private message
motaboy
Retired Dev
Retired Dev


Joined: 15 Dec 2003
Posts: 1483

PostPosted: Mon Mar 08, 2004 6:21 pm    Post subject: Reply with quote

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
View user's profile Send private message
motaboy
Retired Dev
Retired Dev


Joined: 15 Dec 2003
Posts: 1483

PostPosted: Mon Mar 08, 2004 7:31 pm    Post subject: Reply with quote

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
View user's profile Send private message
motaboy
Retired Dev
Retired Dev


Joined: 15 Dec 2003
Posts: 1483

PostPosted: Mon Mar 08, 2004 7:46 pm    Post subject: Reply with quote

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
View user's profile Send private message
micron
Guru
Guru


Joined: 23 Jul 2003
Posts: 411
Location: Bergamo, Italy

PostPosted: Mon Mar 08, 2004 9:17 pm    Post subject: Reply with quote

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!! :roll: :oops:

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
Code:
input.hotplug


Ora funziona tutto alla meraviglia!!
Grazie mille! :)
_________________
~ "Progress is merely a realisation of utopias" ~
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Forum italiano (Italian) 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