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.

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

#<br />

if [ ! -e $MOUNTPOINT ]; then<br />

mk<strong>di</strong>r -p $MOUNTPOINT<br />

fi<br />

##<br />

# Take care of /etc/fstab so mounting is easy.<br />

#<br />

if ! grep -q "^$SYMLINKDEV" /etc/fstab; then<br />

# Add an fstab entry<br />

echo -e \<br />

"$SYMLINKDEV\t\t$MOUNTPOINT\t\tauto\tnoauto,owner,kudzu 0 0" \<br />

>> /etc/fstab<br />

fi<br />

done<br />

if [ ! -z "$REMOVER" ]; then<br />

##<br />

# Make sure this script is triggered on device removal.<br />

#<br />

mk<strong>di</strong>r -p ‘<strong>di</strong>rname $REMOVER‘<br />

ln -s $IAM $REMOVER<br />

fi<br />

elif [ "${ACTION}" = "remove" ]; then<br />

##<br />

# If the device is mounted, unmount it cleanly.<br />

#<br />

if grep -q "$MOUNTPOINT" /etc/mtab; then<br />

# unmount cleanly<br />

umount -l $MOUNTPOINT<br />

fi<br />

##<br />

# Remove it from /etc/fstab if it’s there.<br />

#<br />

if grep -q "^$SYMLINKDEV" /etc/fstab; then<br />

grep -v "^$SYMLINKDEV" /etc/fstab > /etc/.fstab.new<br />

mv -f /etc/.fstab.new /etc/fstab<br />

fi<br />

fi<br />

exit 0<br />

Ecco qualcosa che riscalderà i cuori <strong>di</strong> webmaster e insegnanti <strong>di</strong> ogni dove: uno script che salva i<br />

weblog.<br />

Esempio A-24. Preservare i weblog<br />

#!/bin/bash<br />

# archiveweblogs.sh v1.0<br />

# Troy Engel <br />

# Con leggere mo<strong>di</strong>fiche effettuate dall’autore del libro.<br />

# Usato con il consenso dell’autore dello script.<br />

#<br />

663

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

Saved successfully!

Ooh no, something went wrong!