#!/bin/sh # BasOS Jan 2006 # # Script for usbmount to create standard symlinks to specific partitions # Patritions are defined in /etc/usbmount/partitions.conf setting the variable PARTITIONS # PARTITIONS is space delimited list of partition definitions and corresponding mount points # A partition definition is a comma dellimited list whith a -mpoint= entry specifying the # symlink, a -label= and/or -uuid= entry specifying a label match and/or uuid match. #e.g. PARTITIONS="-label=lab1,-mpoint=/mnt/a -uuid=EA32-3AE4,moint=/mnt/b # -label=lab2,-uuid=EADE-EA34,-moint=/mnt/c" # # Το παρόν χρησιμοποιείται με το usbmount και εγκαθίσταται στο /etc/usbmount/mount.d # Δημιουργεί στανταρ slinks για συγκεκριμενα partitions τα οποία ορίζονται στο # /etc/usbmount/partitions.conf στη μεταβλητή PARTITIONS. Η τελευταία είναι μία λίστα χωριζόμενη # με κενά με ορισμούς partition. Καθε ορισμός partition είναι μια λίστο χωριζόμενη με κόμμα # που περιέχει μια καταχώρηση -mpoint= για το symlink του partition , μία καταχώρηση -label= # ή/και μια καταχώρηση -uuid= για τον προσδιορισμό του label ή/και του uuid ενος partition. # Τα στοιχεία (label,uuid) ενός partition τα βλέπουμε με το vol_id device # π.χ. PARTITIONS="-label=lab1,-mpoint=/mnt/a -uuid=EA32-3AE4,moint=/mnt/b # -label=lab2,-uuid=EADE-EA34,-moint=/mnt/c" # # 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. # # v0.5 d="off"; # Log a string via the syslog facility. 2004, 2005 Martin Dickopp log() { if test $1 != "debug" || test "$d" = "on"; then logger -p user.$1 -t "partitionmount[$$]" -- "$2" fi } label=`/sbin/vol_id -l "$UM_DEVICE"` uuid=`/sbin/vol_id -u "$UM_DEVICE"` test -n "$label" || test -n "$uuid" || exit 1 if test "$d" = "on"; then echo "label is $label" echo "uuid is $uuid" fi if test -r /etc/usbmount/partitions.conf; then . /etc/usbmount/partitions.conf else log warning "partitions.conf not found" exit 1; fi for v in $PARTITIONS; do tlabel=`echo $v | grep -o "\-label=[^,]*" | sed "s/-label=//"`; tuuid=`echo $v | grep -o "\-uuid=[^,]*" | sed "s/-uuid=//"`; mpoints=`echo $v | grep -o "\-mpoint=[^,]*" | sed "s/-mpoint=//"`; if test $d = "on"; then echo "listitem is $v" echo "tlabel is $tlabel" echo "tuuid is $tuuid" echo "mpoints is $mpoints" fi if ! test -z "$mpoints"; then if (! test -z "$tlabel" && test -z "$tuuid" && test "$tlabel" = "$label") || \ (test -z "$tlabel" && ! test -z "$tuuid" && test "$tuuid" = "$uuid") || \ (! test -z "$tlabel" && ! test -z "$tuuid" && test "$tlabel" = "$label" && test "$tuuid" = "$uuid"); then for mpoint in $mpoints; do (test -e "$mpoint" && log waring "$mpoint already exists. Not doing anything for $UM_MOUNTPOINT") || (ln -sf "$UM_MOUNTPOINT" "$mpoint" && log info "Created $mpoint -> $UM_MOUNTPOINT for $label $uuid") if test "$d" = "on" ;then echo "Suppose to have created $mpoint -> $UM_MOUNTPOINT" ;fi done fi else log warning "Erroneus partition description $tlabel $tuuid" fi done exit 0