22 lines
680 B
Bash
Executable File
22 lines
680 B
Bash
Executable File
#! /bin/bash
|
|
|
|
HOMEDIR=$(readlink -f ~)
|
|
mkdir ${HOMEDIR}/videos
|
|
|
|
for device in /sys/block/*/device; do
|
|
if echo $(readlink -f "$device") | egrep -q "usb" ; then
|
|
disk=$(echo "$device" | cut -f4 -d/)
|
|
# Try the disk first.
|
|
if sudo mount -t auto -o ro /dev/$disk ${HOMEDIR}/videos 2> /dev/null ; then
|
|
echo "Mounted /dev/$disk to ${HOMEDIR}/videos"
|
|
exit
|
|
fi
|
|
# Try the first partition.
|
|
if sudo mount -t auto -o ro /dev/${disk}1 ${HOMEDIR}/videos 2> /dev/null ; then
|
|
echo "Mounted /dev/${disk}1 to ${HOMEDIR}/videos"
|
|
exit
|
|
fi
|
|
fi
|
|
done
|
|
echo "Could not find a USB drive to mount!"
|