usbmount/mount.d/00_create_model_symlink
author ft
Thu, 27 Feb 2014 17:12:59 +0100
changeset 0 60bc07f3f415
child 2 ee0797f46473
permissions -rwxr-xr-x
initial commit
     1 #!/bin/sh
     2 # This script creates the model name symlink in /var/run/usbmount.
     3 # Copyright (C) 2005 Martin Dickopp
     4 #
     5 # This file is free software; the copyright holder gives unlimited
     6 # permission to copy and/or distribute it, with or without
     7 # modifications, as long as this notice is preserved.
     8 #
     9 # This file is distributed in the hope that it will be useful,
    10 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
    11 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
    12 # PARTICULAR PURPOSE.
    13 #
    14 set -e
    15 
    16 # Replace spaces with underscores, remove special characters in vendor
    17 # and model name.
    18 UM_VENDOR=`echo "$UM_VENDOR" | sed 's/ /_/g; s/[^0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ._-]//g'`
    19 UM_MODEL=`echo "$UM_MODEL" | sed 's/ /_/g; s/[^0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ._-]//g'`
    20 
    21 # Exit if both vendor and model name are empty.
    22 test -n "$UM_VENDOR" || test -n "$UM_MODEL" || exit 0
    23 
    24 # Build symlink name.
    25 if test -n "$UM_VENDOR" && test -n "$UM_MODEL"; then
    26     name="${UM_VENDOR}_$UM_MODEL"
    27 else
    28     name="$UM_VENDOR$UM_MODEL"
    29 fi
    30 
    31 # Append partition number, if any, to the symlink name.
    32 partition=`echo "$UM_DEVICE" | sed 's/^.*[^0123456789]\([0123456789]*\)/\1/'`
    33 if test -n "$partition"; then
    34     name="${name}_$partition"
    35 fi
    36 
    37 mkdir -p "/var/run/usbmount/$name"
    38 osecfs /etc/osecfs/osecfs_usb.cfg /var/run/usbmount/$name ro
    39 
    40 
    41 exit 0