usbmount/mount.d/00_create_model_symlink
changeset 0 60bc07f3f415
child 2 ee0797f46473
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/usbmount/mount.d/00_create_model_symlink	Thu Feb 27 17:12:59 2014 +0100
     1.3 @@ -0,0 +1,41 @@
     1.4 +#!/bin/sh
     1.5 +# This script creates the model name symlink in /var/run/usbmount.
     1.6 +# Copyright (C) 2005 Martin Dickopp
     1.7 +#
     1.8 +# This file is free software; the copyright holder gives unlimited
     1.9 +# permission to copy and/or distribute it, with or without
    1.10 +# modifications, as long as this notice is preserved.
    1.11 +#
    1.12 +# This file is distributed in the hope that it will be useful,
    1.13 +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
    1.14 +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
    1.15 +# PARTICULAR PURPOSE.
    1.16 +#
    1.17 +set -e
    1.18 +
    1.19 +# Replace spaces with underscores, remove special characters in vendor
    1.20 +# and model name.
    1.21 +UM_VENDOR=`echo "$UM_VENDOR" | sed 's/ /_/g; s/[^0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ._-]//g'`
    1.22 +UM_MODEL=`echo "$UM_MODEL" | sed 's/ /_/g; s/[^0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ._-]//g'`
    1.23 +
    1.24 +# Exit if both vendor and model name are empty.
    1.25 +test -n "$UM_VENDOR" || test -n "$UM_MODEL" || exit 0
    1.26 +
    1.27 +# Build symlink name.
    1.28 +if test -n "$UM_VENDOR" && test -n "$UM_MODEL"; then
    1.29 +    name="${UM_VENDOR}_$UM_MODEL"
    1.30 +else
    1.31 +    name="$UM_VENDOR$UM_MODEL"
    1.32 +fi
    1.33 +
    1.34 +# Append partition number, if any, to the symlink name.
    1.35 +partition=`echo "$UM_DEVICE" | sed 's/^.*[^0123456789]\([0123456789]*\)/\1/'`
    1.36 +if test -n "$partition"; then
    1.37 +    name="${name}_$partition"
    1.38 +fi
    1.39 +
    1.40 +mkdir -p "/var/run/usbmount/$name"
    1.41 +osecfs /etc/osecfs/osecfs_usb.cfg /var/run/usbmount/$name ro
    1.42 +
    1.43 +
    1.44 +exit 0