summaryrefslogtreecommitdiffstats
path: root/libk3b/scripts/k3b_automount
diff options
context:
space:
mode:
Diffstat (limited to 'libk3b/scripts/k3b_automount')
-rwxr-xr-xlibk3b/scripts/k3b_automount66
1 files changed, 66 insertions, 0 deletions
diff --git a/libk3b/scripts/k3b_automount b/libk3b/scripts/k3b_automount
new file mode 100755
index 0000000..e86e960
--- /dev/null
+++ b/libk3b/scripts/k3b_automount
@@ -0,0 +1,66 @@
+#!/bin/bash
+
+#
+# This script is able to disable and enable automounting for a device.
+# It's usage is as follows:
+#
+# k3b_automount disable /dev/cdrom
+# or
+# k3b_automount enable /dev/cdrom
+#
+# /dev/cdrom needs to have an entry in /etc/fstab.
+#
+# The supported automounting systems are subfs and supermount.
+#
+# Exit codes:
+# 0 - success
+# 1 - wrong usage
+# 2 - device not configured with subfs/supermount in /etc/fstab
+# X - failed to mount/umount
+#
+
+DISABLE=1
+
+if [ $1 = "disable" ]; then
+ DISABLE=1
+elif [ $1 = "enable" ]; then
+ DISABLE=0
+else
+ echo "Usage: $0 disable|enable <device>"
+ exit 1
+fi
+
+DEVICE=$2
+
+if [ -z $DEVICE ]; then
+ echo "Usage: $0 disable|enable <device>"
+ exit 1
+fi
+
+# we have a mode and a device
+
+# open the fstab file and search the DEVICE
+if [ -n "`grep $DEVICE /etc/fstab | grep "subfs\|supermount"`" ]; then
+ if [ $DISABLE = 1 ]; then
+ umount $DEVICE
+ else
+ mount $DEVICE
+ fi
+ exit $?
+fi
+
+#
+# Ok, not using subfs or supermount
+# If some other userspace automounter (like ivman) is running it is sufficient
+# to unmount the device now to get the burning started. This however does not
+# fix the problem with DVD+RW burning which may be mounted once the burning has
+# been started.
+#
+# So we unmount the device in case it is mounted with iso9660 or udf (just to add
+# some security to this suid script. :(
+#
+if [ $DISABLE = 1 ] && [ -n "`grep $DEVICE /etc/mtab | grep "iso9660\|udf"`" ]; then
+ umount $DEVICE
+ exit $?
+fi
+exit 2