11.04.2013 Views

Guida avanzata di scripting Bash - Portale Posta DMI

Guida avanzata di scripting Bash - Portale Posta DMI

Guida avanzata di scripting Bash - Portale Posta DMI

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Ora uno script che installa e monta quelle graziose “chiavi” USB.<br />

Esempio A-23. Montare le chiavi <strong>di</strong> memoria USB<br />

Appen<strong>di</strong>ce A. Script aggiuntivi<br />

#!/bin/bash<br />

# ==> usb.sh<br />

# ==> Script for mounting and installing pen/keychain USB storage devices.<br />

# ==> Runs as root at system startup (see below).<br />

# ==><br />

# ==> Newer Linux <strong>di</strong>stros (2004 or later) autodetect<br />

# ==> and install USB pen drives, and therefore don’t need this script.<br />

# ==> But, it’s still instructive.<br />

# This code is free software covered by GNU GPL license version 2 or above.<br />

# Please refer to http://www.gnu.org/ for the full license text.<br />

#<br />

# Some code lifted from usb-mount by Michael Hamilton’s usb-mount (LGPL)<br />

#+ see http://users.actrix.co.nz/michael/usbmount.html<br />

#<br />

# INSTALL<br />

# -------<br />

# Put this in /etc/hotplug/usb/<strong>di</strong>skonkey.<br />

# Then look in /etc/hotplug/usb.<strong>di</strong>stmap, and copy all usb-storage entries<br />

#+ into /etc/hotplug/usb.usermap, substituting "usb-storage" for "<strong>di</strong>skonkey".<br />

# Otherwise this code is only run during the kernel module invocation/removal<br />

#+ (at least in my tests), which defeats the purpose.<br />

#<br />

# TODO<br />

# ----<br />

# Handle more than one <strong>di</strong>skonkey device at one time (e.g. /dev/<strong>di</strong>skonkey1<br />

#+ and /mnt/<strong>di</strong>skonkey1), etc. The biggest problem here is the handling in<br />

#+ devlabel, which I haven’t yet tried.<br />

#<br />

# AUTHOR and SUPPORT<br />

# ------------------<br />

# Konstantin Riabitsev, .<br />

# Send any problem reports to my email address at the moment.<br />

#<br />

# ==> Comments added by ABS Guide author.<br />

SYMLINKDEV=/dev/<strong>di</strong>skonkey<br />

MOUNTPOINT=/mnt/<strong>di</strong>skonkey<br />

DEVLABEL=/sbin/devlabel<br />

DEVLABELCONFIG=/etc/sysconfig/devlabel<br />

IAM=$0<br />

##<br />

# Functions lifted near-verbatim from usb-mount code.<br />

#<br />

function allAttachedScsiUsb {<br />

find /proc/scsi/ -path ’/proc/scsi/usb-storage*’ -type f | xargs grep -l ’Attached: Yes’<br />

661

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!