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