Package: usbmount
Version: 0.0.22
Followup-For: Bug #510007
Severity: minor
Tags: patch
Dear Rogério,
thank you for maintaining the usbmount package, I like it very much. I would
like to contribute the following feature:
If a device has a device label, use this label instead of vendor/model for the
symlink name in /var/run/usbmount/. This change affects only the file
/etc/usbmount/mount.d/00_create_model_symlink. An appropriate patch follows
below.
Furthermore, I would like to remark that it seems very convenient to me to
make /media/usb a symlink to /var/run/usbmount/ instead of /media/usb0. An
external hard disk might be found at /media/usb/MyHDD, which is very
intuitive.
Thank you again for maintaining this and the other packages.
Sincerely
Lars
--- 8>< ----------------------------------------------------------------------
--- /etc/usbmount/mount.d/00_create_model_symlink 2011-08-08
17:01:54.000000000 +0200
+++ 00_create_model_symlink.label 2015-03-15 11:33:15.230847209 +0100
@@ -1,6 +1,7 @@
#!/bin/sh
-# This script creates the model name symlink in /var/run/usbmount.
+# This script creates the label or model name symlink in /var/run/usbmount.
# Copyright (C) 2005 Martin Dickopp
+# Copyright (C) 2011 Lars Stollenwerk
#
# This file is free software; the copyright holder gives unlimited
# permission to copy and/or distribute it, with or without
@@ -13,25 +14,33 @@
#
set -e
-# Replace spaces with underscores, remove special characters in vendor
-# and model name.
-UM_VENDOR=`echo "$UM_VENDOR" | sed 's/ /_/g;
s/[^0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ._-]//g'`
-UM_MODEL=`echo "$UM_MODEL" | sed 's/ /_/g;
s/[^0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ._-]//g'`
-
-# Exit if both vendor and model name are empty.
-test -n "$UM_VENDOR" || test -n "$UM_MODEL" || exit 0
-
-# Build symlink name.
-if test -n "$UM_VENDOR" && test -n "$UM_MODEL"; then
- name="${UM_VENDOR}_$UM_MODEL"
-else
- name="$UM_VENDOR$UM_MODEL"
-fi
+# Try to get a label
+#name=`vol_id --label $UM_DEVICE`
+name=`blkid -s LABEL -o value $UM_DEVICE`
+
+# On empty label, use vendor and model
+if test -z "$name"; then
+
+ # Replace spaces with underscores, remove special characters in vendor
+ # and model name.
+ UM_VENDOR=`echo "$UM_VENDOR" | sed 's/ /_/g; s/[^0-9a-zA-Z._-]//g'`
+ UM_MODEL=`echo "$UM_MODEL" | sed 's/ /_/g; s/[^0-9a-zA-Z._-]//g'`
+
+ # Exit if both vendor and model name are empty.
+ test -n "$UM_VENDOR" || test -n "$UM_MODEL" || exit 0
+
+ # Build symlink name.
+ if test -n "$UM_VENDOR" && test -n "$UM_MODEL"; then
+ name="${UM_VENDOR}_$UM_MODEL"
+ else
+ name="$UM_VENDOR$UM_MODEL"
+ fi
-# Append partition number, if any, to the symlink name.
-partition=`echo "$UM_DEVICE" | sed 's/^.*[^0123456789]\([0123456789]*\)/\1/'`
-if test -n "$partition"; then
- name="${name}_$partition"
+ # Append partition number, if any, to the symlink name.
+ partition=`echo "$UM_DEVICE" | sed
's/^.*[^0123456789]\([0123456789]*\)/\1/'`
+ if test -n "$partition"; then
+ name="${name}_$partition"
+ fi
fi
# If the symlink does not yet exist, create it.
--- 8>< ----------------------------------------------------------------------
-- System Information:
Debian Release: 7.8
APT prefers stable-updates
APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: i386 (i686)
Kernel: Linux 3.2.0-4-686-pae (SMP w/2 CPU cores)
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Versions of packages usbmount depends on:
ii lockfile-progs 0.1.17
ii udev 175-7.2
ii util-linux 2.20.1-5.3
Versions of packages usbmount recommends:
ii pmount 0.9.23-2
usbmount suggests no packages.
-- no debconf information
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]