Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'A script to unmount cloned backup volumes at login' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
A script to unmount cloned backup volumes at login
Authored by: jpimbert on Jun 29, '04 09:50:39AM
May Be This shell script could help you. You can modify the CCC script to add :

- at the beginning : MountLabel -m "label of your partition"

- at the end: MountLabel -d "label of your partition"

Here is the code for MountLabel (and sorry for the French Comments)


#!/bin/tcsh

##
# Script pour monter/demonter un volume par son Label
#
# Jean-Pierre IMBERT | jean-pierre.imbert@ingenieurs-supelec.org
##

##
# Verification de la syntaxe d'appel
##

set t
switch ($1)
case "-l":
 @ t = ($# == 1)
 set command = "list"
 breaksw
case "-m":
 @ t = ($# == 2)
 set command = "mount"
 breaksw
case "-d":
 @ t = ($# == 2)
 set command = "dismount"
 breaksw
default:
 @ t = 0
 breaksw
endsw

if ($t == 0) then
 echo "MountLabel:  Mount/Dismount Volume with its Label Name"
 echo "MountLabel:  MountLabel [ -m | -d ] Label"
 echo "MountLabel:  MountLabel -l"
 echo "Usage:     You can use MountLabel for mount/dismount or list Volumes knowing their Label"
 echo "Usage:     This command works only for hfs volumes"
 echo "Usage:     The acceptable command line parameters are"
 echo "Usage:         -l -- list all Volumes currently on line"
 echo "Usage:         -m -- mount the volume 'Label'"
 echo "Usage:         -d -- dismount the volume 'Label'"
 exit 1
endif
set vol_label = $2

##
# Recherche de la liste des volumes en ligne 
# et execution de la commande "list" ou recherche du "device" correspondant
##

if ($command == "list") then
 disktool -l | grep "Disk Appeared" | awk -F "'" '{print $8"   "$2}'
 else
 set device = `disktool -l | grep "Disk Appeared" | awk -F "'" '{print $8","$2}' | grep "^$vol_label," | awk -F "," '{print $2}'`
 if ($#device == 0) then
   echo "There is no drive online with label $vol_label"
   exit 1                                 # erreur : le volume cherche n'est pas en ligne
 endif
endif

##
# Realisation de la commande
##
switch ($command)
case "list":
 exit 0
 breaksw
case "mount":
 if !(-d /Volumes/$vol_label) then
   mkdir /Volumes/$vol_label                               # creation du repertoire de montage
   else
   echo "The target drive seems to be already mounted."    # erreur : le volume semble deja monte
   exit 1
 endif
 mount_hfs /dev/$device /Volumes/$vol_label
 if ($? != 0 ) exit 1                                      # erreur : probleme de montage du volume
 disktool -r
 breaksw
case "dismount":
 if !(-d /Volumes/$vol_label) then
   echo "The target drive is not mounted."                 # erreur : le volume n'est pas monte
   exit 1
 endif
 umount -f /dev/$device
 disktool -r
 rmdir /Volumes/$vol_label
 breaksw
endsw


[ Reply to This | # ]