Reglamento general de los foros   •   FAQ   •   Buscar en el foro •  Registrarse | Iniciar sesión 



Foros Linux » Filosofía y conocimiento » Documentación


Nuevo tema Responder al tema
 [ 4 mensajes ] 
Patrocinadores

Autor
Buscar:
Mensaje

Desconectado
Administrador
Administrador
Avatar de Usuario

Registrado: Mié Dic 31, 1969 6:00 pm
Mensajes: 3237
Ubicación: León, Guanajuato; México.

Nota Publicado: Lun Feb 19, 2007 11:46 am 
Arriba  
Hola:

Se abre este post para comentar, exponer dudas o hacer observaciones sobre el documento publicado en el Taller Linux : "Udev en Slackware" bajo la autoria de Meleagro.

Son bienvenidos todos sus mensajes al respecto.

Saludos.

_________________
No hay nada que agradecer. Hago, lo tengo que hacer.
Reglamento del foro | Temas más preguntados | Blog personal | Twitter: @pacorevilla

 Perfil WWW ICQ  

Desconectado
Miembro ETEL
Miembro ETEL
Avatar de Usuario

Registrado: Lun Jun 06, 2005 11:00 pm
Mensajes: 1162
Ubicación: En tus pesadillas

Nota Publicado: Lun Feb 19, 2007 1:51 pm 
Arriba  
Ajax creo que te mandé el tutorial con una errata, donde pone:

# Start the udev setup procedure.
if [ -x /etc/rc.d/rc.udev ]; then
. /etc/rc.d/rc.udev
fi

Debeía poner:

# Start the udev setup procedure.
if [ -x /etc/rc.d/rc.udev ]; then
. /etc/rc.d/rc.udev start
fi

Un saludo !!!

_________________
Slack in peace
Usuario Linux # 385639
http://www.meleagro.es.kz
Participa en #espaciolinux - irc.freenode.net

 Perfil Email WWW  

Desconectado
Administrador
Administrador
Avatar de Usuario

Registrado: Mié Dic 31, 1969 6:00 pm
Mensajes: 3237
Ubicación: León, Guanajuato; México.

Nota Publicado: Lun Feb 19, 2007 2:02 pm 
Arriba  
Hola, Meleagro:

Ya está corregido.

Un saludo.

_________________
No hay nada que agradecer. Hago, lo tengo que hacer.
Reglamento del foro | Temas más preguntados | Blog personal | Twitter: @pacorevilla

 Perfil WWW ICQ  

Desconectado
Forista Medio
Forista Medio
Avatar de Usuario

Registrado: Lun Feb 12, 2007 12:00 am
Mensajes: 116
Ubicación: Mexico

Nota Publicado: Mar Mar 13, 2007 3:51 am 
Arriba  
ya que se habla de Udev, voy a poner algo que vi en http://esslackware.blogspot.com/
ese blog es uno de los que traen los mejores consejos practicos para slack aunque sea nuevo :P

Citar:
Modificamos /etc/udev/udev.conf

# udev.conf
# The main config file for udev
#
# This file can be used to override some of udev's default values
# for where it looks for files, and where it places device nodes.


# udev_root - where in the filesystem to place the device nodes
udev_root="/dev/"

# udev_db - The name and location of the udev database.
udev_db="/dev/.udev.tdb"

# udev_rules - The name and location of the udev rules dir
udev_rules="/etc/udev/rules.d"

# default_mode - set the default mode for all nodes that have no
# explicit match in the permissions file
default_mode="666"

# default_owner - set the default owner for all nodes that have no
# explicit match in the permissions file
default_owner="root"

# default_group - set the default group for all nodes that have no
# explicit match in the permissions file
default_group="root"

# udev_log - set to "yes" if you want logging, else "no"
udev_log="no"

Creamos /etc/udev/rules.d/20-hotmount.rules

# USB storage devices
KERNEL=="sd*|sr*|ub*", ACTION=="add", SUBSYSTEMS=="usb", ENV{DEVFLAG}="usbdisk", NAME="%k", GROUP="cdrom", MODE="0660", RUN+="/lib/udev/usbmount.sh add /dev/%k"
KERNEL=="sd*|sr*|ub*", ACTION=="remove", ENV{DEVFLAG}=="usbdisk", RUN+="/lib/udev/usbmount.sh remove /dev/%k"


Creamos /lib/udev/usbmount.sh
#!/bin/sh
# This script mounts USB and other mass storage devices when they are plugged in
# and unmounts them when they are removed.
# It also creates mountpoints as needed, and removes them afterward
# Copyright (C) 2006 Jean-Philippe Guillemin and Mark Colclough
#
# This file is free software; the copyright holder gives unlimited
# permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
#
# This file is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
#

# Usage : [hotmount.sh|usbmount.sh|firemount.sh|pcmciamount.sh] (add|remove) DEVICE [MOUNTPOINT]
# if the variable $NICEMOUNTPOINT is defined it will be used as the first tried mountpoint

# version 1.0 11/06/2006

VERBOSE="no"

# Log a string via the syslog facility.
log()
{
[ "$VERBOSE" = "yes" ] && logger -p user.$1 -t "usbmount[$$]" -- "$2"
}


# Test if the first parameter is in the list given by the second
# parameter.
in_list()
{
for v in $2; do
test "$1" != "$v" || return 0
done
return 1
}

# Test if /lib/udev/vol_id is executable.
test -x /lib/udev/vol_id || { log err "cannnot execute /lib/udev/vol_id"; exit 1; }

# Default mountpoints depend on how we were called
case "${0##*/}" in
firemount.sh)
MOUNTPOINTS="/mnt/fire /mnt/fire1 /mnt/fire2 /mnt/fire3 /mnt/fire4 /mnt/fire5 /mnt/fire6 /mnt/fire7 /mnt/fire8 /mnt/fire9 /mnt/fire10 /mnt/fire11"
;;
pcmciamount.sh)
MOUNTPOINTS="/mnt/pcm /mnt/pcm1 /mnt/pcm2 /mnt/pcm3 /mnt/pcm4 /mnt/pcm5 /mnt/pcm6 /mnt/pcm7 /mnt/pcm8 /mnt/pcm9 /mnt/pcm10 /mnt/pcm11"
;;
mmcmount.sh)
MOUNTPOINTS="/mnt/mmc /mnt/mmc1 /mnt/mmc2 /mnt/mmc3 /mnt/mmc4 /mnt/mmc5 /mnt/mmc6 /mnt/mmc7 /mnt/mmc8 /mnt/mmc9 /mnt/mmc10 /mnt/mmc11"
;;
*)
MOUNTPOINTS="/mnt/usb /mnt/usb1 /mnt/usb2 /mnt/usb3 /mnt/usb4 /mnt/usb5 /mnt/usb6 /mnt/usb7 /mnt/usb8 /mnt/usb9 /mnt/usb10 /mnt/usb11"
;;
esac
MOUNTOPTIONS=" noauto,user,rw,owner,exec"

# The device name MUST be given as 2nd argument
DEVNAME="$2"

# Maybe a user-defined mountpoint in fstab ?
FSTABMOUNTPOINT="$(grep "$DEVNAME[[:space:]]" /etc/fstab | awk '{print $2}' | tail -n1)"
[ "$FSTABMOUNTPOINT" ] && MOUNTPOINTS="$FSTABMOUNTPOINT $MOUNTPOINTS"
FSTABMOUNTOPTIONS="$(grep "$DEVNAME[[:space:]]" /etc/fstab | awk '{print $4}' | tail -n1)"

# The mount point COULD be given as 3rd argument
[ "$3" ] && MOUNTPOINTS="$3 $MOUNTPOINTS"

# if the variable $NICEMOUNTPOINT is defined it will be used as the first tried mountpoint
[ "$NICEMOUNTPOINT" ] && MOUNTPOINTS="$NICEMOUNTPOINT $MOUNTPOINTS"

umask 000

if [ "$1" = add ] ; then

log info "devname == $DEVNAME !!"
# Try to read from the device. Some devices need a few seconds
# initialization time before they can be accessed. Give up after
# 20 seconds (a Markish infinite... ;).
log info "testing whether $DEVNAME is readable"
read_success=no
for t in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19; do
dd if="$DEVNAME" of=/dev/null bs=512 count=1
if [ "$?" = "0" ] ; then
read_success=yes
break
fi
log info "attempt $t to read from $DEVNAME failed"
sleep 1
done
if [ "$read_success" != "yes" ]; then
log err "cannot read from $DEVNAME"
exit 1
fi

# Test if the device contains a filesystem.
/lib/udev/vol_id "$DEVNAME" | egrep -q '^ID_FS_USAGE=(filesystem|disklabel)$'
if [ "$?" = "0" ] ; then
log info "$DEVNAME contains a filesystem or disklabel"

fstype="$(/lib/udev/vol_id -t $DEVNAME )"
log info "$DEVNAME contains filesystem type $fstype"

# We search for available mountpoint in the list
for mountpoint in $MOUNTPOINTS; do

# Get a lock for the mountpoint under consideration
for t in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19; do
(set -C; echo "$$" > /var/lock/${mountpoint##*/}) && break
log info "waiting for $mountpoint lockfile to be released"
sleep 1
done

if [ -d "$mountpoint" ]; then
log info "mountpoint $mountpoint exists"
if [ ! "$( mount | awk '{print $3}' | grep "$mountpoint" )" ]; then
log info "mountpoint $mountpoint is available for $DEVNAME"
break
else
log info "mountpoint $mountpoint is busy"
rm -f /var/lock/${mountpoint##*/}
continue
fi
else
log info "creating mountpoint $mountpoint for $DEVNAME"
mkdir -p -m0 $mountpoint
umount -l "$mountpoint"
log info "mountpoint $mountpoint is available for $DEVNAME"
break
fi
rm -f /var/lock/${mountpoint##*/}
done

if [ "$mountpoint" ] ; then

# Determine mount options.
options=""
if [ "$FSTABMOUNTOPTIONS" ]; then
options="$FSTABMOUNTOPTIONS"
else
[ "$MOUNTOPTIONS" ] && options="$MOUNTOPTIONS"
[ ! "$fstype" = "vfat" ] && options="${options},sync,dirsync"
[ "$fstype" = "vfat" ] && options="${options},uid=0,gid=100,umask=0"
fi

# Mount the filesystem.
for t in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19; do
[ "$( mount | awk '{print $1}' | grep "$DEVNAME" )" ] && break
log info "executing command: mount -t $fstype -o $options $DEVNAME $mountpoint"
eval "mount -t $fstype -o $options $DEVNAME $mountpoint"
/lib/udev/montaje.sh $DEVNAME $mountpoint
done
rm -f /var/lock/${mountpoint##*/}
else
# No suitable mount point found.
log warning "no mountpoint found for $DEVNAME"
exit 1
fi
else
log info "$DEVNAME does not contain a filesystem or disklabel"
fi

elif [ "$1" = remove ] ; then
/lib/udev/montaje.sh $DEVNAME $DEVNAME $1
# A block or partition device has been removed.
# Test if it is mounted.
while read device mountpoint fstype remainder; do
if [ "$DEVNAME" = "$device" ] ; then
# If the mountpoint and filesystem type are maintained by
# this script, unmount the filesystem.
if in_list "$mountpoint" "$MOUNTPOINTS" ; then
log info "unmounting $mountpoint"
umount -l "$mountpoint"
rmdir $mountpoint && break
log info "cannot remove $mountpoint, maybe not empty"
fi
break
fi
done < /proc/mounts fi exit 0

Por último creamos /lib/udev/montaje.sh

#!/bin/bash
# 06/02/07 SiTuH~
Home_Des="introduce la ruta de tu escritorio"
nombre=`echo $2 | cut -c 6,7,8,9`

if [ "$3" != remove ]
then
echo " [Desktop Entry]
Type=FSDevice
Dev=$1
MountPoint=$2
Encoding=UTF-8
Icon=usbpendrive_mount
UnmountIcon=usbpendrive_unmount
Name=$nombre" > $Home_Des/$nombre.desktop
echo $1 $2 >> /tmp/.puntomontaje.log

else
borra=`cat /tmp/.puntomontaje.log | grep $2 | cut -f 2 -d ' '`
cat /tmp/.puntomontaje.log | grep $2 -v > /tmp/.puntomontaje.log
rmdir $borra
dis=`echo $borra | cut -d / -f 3 | cut -d ' ' -f 1`
rm $Home_Des/$dis.desktop
fi

y con esto lo que conseguimos es que al pinchar nuestra memoria usb aparezca en nuestro escritorio un link a ella, con opcion de desmontarla con un par de clicks, al quitar nuestro usb el link desaparece.

No olvidar dar permiso de ejecucion a los scripts
chmod +x script


saludos

_________________
bla bla bla

 Perfil Email  
Mostrar mensajes previos:  Ordenar por  
 [ 4 mensajes ] 
Nuevo tema Responder al tema

Saltar a:  


¿Quién está conectado?

Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 1 invitado

No puede abrir nuevos temas en este Foro
No puede responder a temas en este Foro
No puede editar sus mensajes en este Foro
No puede borrar sus mensajes en este Foro
No puede enviar adjuntos en este Foro

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group :: Style based on FI Subice by phpBBservice.nl :: Todos los horarios son UTC - 6 horas
Traducción al español por Huan Manwë
phpBB SEO