Implement active sleep/wait for devices that could not appear. Add more useful information to /var/log/automount.log file.
This commit is contained in:
parent
7ed9202cd4
commit
547c186ae4
58
automount
58
automount
|
|
@ -35,6 +35,7 @@ It needs these ports to mount NTFS/exFAT/EXT4 respectively:
|
||||||
o sysutils/fusefs-ntfs
|
o sysutils/fusefs-ntfs
|
||||||
o sysutils/fusefs-exfat
|
o sysutils/fusefs-exfat
|
||||||
o sysutils/fusefs-ext4fuse
|
o sysutils/fusefs-ext4fuse
|
||||||
|
o sysutils/e2fsprogs
|
||||||
|
|
||||||
By default it mounts/unmounts all removable media but
|
By default it mounts/unmounts all removable media but
|
||||||
it is possible to set some additional options at the
|
it is possible to set some additional options at the
|
||||||
|
|
@ -99,14 +100,25 @@ REMOVEDIRS (set to NO by default)
|
||||||
BLACKLIST (unset by default)
|
BLACKLIST (unset by default)
|
||||||
The automount will ignore devices defined here.
|
The automount will ignore devices defined here.
|
||||||
|
|
||||||
example: BLACKLIST="da0 da3"
|
example: BLACKLIST="da0 da3s1a"
|
||||||
|
|
||||||
|
TIMEOUT (set to 8 by default)
|
||||||
|
Do not wait longer then the specified timeout for
|
||||||
|
the device node to appear in /dev and be accessible.
|
||||||
|
|
||||||
|
example: TIMEOUT="8"
|
||||||
|
|
||||||
|
DELAY (set to 0.3 seconds by default)
|
||||||
|
How often to check for device availability.
|
||||||
|
|
||||||
|
example: DELAY="2.5"
|
||||||
EOF
|
EOF
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ "${1}" = "--version" ]
|
if [ "${1}" = "--version" ]
|
||||||
then
|
then
|
||||||
echo "automount 1.4.2 2013/02/13"
|
echo "automount 1.4.2 2013/02/15"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -131,6 +143,8 @@ fi
|
||||||
: ${REMOVEDIRS="NO"} # remove empty dirs under ${MNTPREFIX}
|
: ${REMOVEDIRS="NO"} # remove empty dirs under ${MNTPREFIX}
|
||||||
: ${USER="0"} # which user to use for popup
|
: ${USER="0"} # which user to use for popup
|
||||||
: ${FM="0"} # which file manager to use
|
: ${FM="0"} # which file manager to use
|
||||||
|
: ${TIMEOUT="8"} # stop waiting for device after that time
|
||||||
|
: ${DELAY="0.3"} # check for the device node that often
|
||||||
|
|
||||||
if [ "${USERUMOUNT}" = YES ]
|
if [ "${USERUMOUNT}" = YES ]
|
||||||
then
|
then
|
||||||
|
|
@ -194,6 +208,25 @@ __check_already_mounted() { # 1=(-d|-m) 2=(DEV|MNT)
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__wait_for_device() { # 1=DEV
|
||||||
|
local COUNT=0
|
||||||
|
while ! head -c 1 ${1} 1> /dev/null 2> /dev/null
|
||||||
|
do
|
||||||
|
sleep ${DELAY}
|
||||||
|
local COUNT=$( echo ${COUNT} + ${DELAY} | bc -l )
|
||||||
|
if ! echo ${COUNT} | grep -q -E '^[0-9]'
|
||||||
|
then
|
||||||
|
local COUNT=0${COUNT}
|
||||||
|
fi
|
||||||
|
local COUNT_INT=$( echo ${COUNT} | cut -d '.' -f 1 )
|
||||||
|
if [ ${COUNT_INT} -gt ${TIMEOUT} ]
|
||||||
|
then
|
||||||
|
__log "${DEV}: device node not available"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
DEV=/dev/${1}
|
DEV=/dev/${1}
|
||||||
|
|
||||||
case ${2} in
|
case ${2} in
|
||||||
|
|
@ -219,18 +252,17 @@ case ${2} in
|
||||||
then
|
then
|
||||||
OPTS="noatime"
|
OPTS="noatime"
|
||||||
fi
|
fi
|
||||||
while ! head -c 1 ${DEV} 1> /dev/null 2> /dev/null
|
__wait_for_device ${DEV}
|
||||||
do
|
|
||||||
sleep 0.2
|
|
||||||
done
|
|
||||||
case $( file -b -L -s ${DEV} | sed -E 's/label:\ \".*\"//g' ) in
|
case $( file -b -L -s ${DEV} | sed -E 's/label:\ \".*\"//g' ) in
|
||||||
(*FAT*) # must be before NTFS section because: newfs_msdos -O NTFS -L NTFS
|
(*FAT*) # must be before NTFS section because: newfs_msdos -O NTFS -L NTFS
|
||||||
__create_mount_point ${DEV}
|
__create_mount_point ${DEV}
|
||||||
|
__wait_for_device ${DEV}
|
||||||
fsck_msdosfs -y ${DEV} \
|
fsck_msdosfs -y ${DEV} \
|
||||||
| while read LINE
|
| while read LINE
|
||||||
do
|
do
|
||||||
__log "${DEV}: fsck_msdosfs ${LINE}"
|
__log "${DEV}: fsck_msdosfs ${LINE}"
|
||||||
done
|
done
|
||||||
|
__wait_for_device ${DEV}
|
||||||
if mount_msdosfs -o large -D ${CODEPAGE} -L ${ENCODING} \
|
if mount_msdosfs -o large -D ${CODEPAGE} -L ${ENCODING} \
|
||||||
-m 644 -M 755 ${DEV} ${MNT}
|
-m 644 -M 755 ${DEV} ${MNT}
|
||||||
then
|
then
|
||||||
|
|
@ -243,8 +275,10 @@ case ${2} in
|
||||||
;;
|
;;
|
||||||
(*NTFS*) # must be after FAT section: newfs_msdos -O NTFS -L NTFS
|
(*NTFS*) # must be after FAT section: newfs_msdos -O NTFS -L NTFS
|
||||||
__create_mount_point ${DEV}
|
__create_mount_point ${DEV}
|
||||||
|
__wait_for_device ${DEV}
|
||||||
if which ntfs-3g 1> /dev/null 2> /dev/null # sysutils/fusefs-ntfs
|
if which ntfs-3g 1> /dev/null 2> /dev/null # sysutils/fusefs-ntfs
|
||||||
then
|
then
|
||||||
|
__wait_for_device ${DEV}
|
||||||
if ntfs-3g -o ${OPTS} ${DEV} ${MNT}
|
if ntfs-3g -o ${OPTS} ${DEV} ${MNT}
|
||||||
then
|
then
|
||||||
ADD=1
|
ADD=1
|
||||||
|
|
@ -269,11 +303,13 @@ case ${2} in
|
||||||
;;
|
;;
|
||||||
(*ext2*)
|
(*ext2*)
|
||||||
__create_mount_point ${DEV}
|
__create_mount_point ${DEV}
|
||||||
|
__wait_for_device ${DEV}
|
||||||
fsck.ext2 -y ${DEV} \
|
fsck.ext2 -y ${DEV} \
|
||||||
| while read LINE
|
| while read LINE
|
||||||
do
|
do
|
||||||
__log "${DEV}: fsck.ext2 ${LINE}"
|
__log "${DEV}: fsck.ext2 ${LINE}"
|
||||||
done
|
done
|
||||||
|
__wait_for_device ${DEV}
|
||||||
if mount -t ext2fs -o ${OPTS} ${DEV} ${MNT}
|
if mount -t ext2fs -o ${OPTS} ${DEV} ${MNT}
|
||||||
then
|
then
|
||||||
ADD=1
|
ADD=1
|
||||||
|
|
@ -285,11 +321,13 @@ case ${2} in
|
||||||
;;
|
;;
|
||||||
(*ext3*)
|
(*ext3*)
|
||||||
__create_mount_point ${DEV}
|
__create_mount_point ${DEV}
|
||||||
|
__wait_for_device ${DEV}
|
||||||
fsck.ext3 -y ${DEV} \
|
fsck.ext3 -y ${DEV} \
|
||||||
| while read LINE
|
| while read LINE
|
||||||
do
|
do
|
||||||
__log "${DEV}: fsck.ext3 ${LINE}"
|
__log "${DEV}: fsck.ext3 ${LINE}"
|
||||||
done
|
done
|
||||||
|
__wait_for_device ${DEV}
|
||||||
if mount -t ext2fs -o ${OPTS} ${DEV} ${MNT}
|
if mount -t ext2fs -o ${OPTS} ${DEV} ${MNT}
|
||||||
then
|
then
|
||||||
ADD=1
|
ADD=1
|
||||||
|
|
@ -301,11 +339,13 @@ case ${2} in
|
||||||
;;
|
;;
|
||||||
(*ext4*)
|
(*ext4*)
|
||||||
__create_mount_point ${DEV}
|
__create_mount_point ${DEV}
|
||||||
|
__wait_for_device ${DEV}
|
||||||
fsck.ext4 -y ${DEV} \
|
fsck.ext4 -y ${DEV} \
|
||||||
| while read LINE
|
| while read LINE
|
||||||
do
|
do
|
||||||
__log "${DEV}: fsck.ext4 ${LINE}"
|
__log "${DEV}: fsck.ext4 ${LINE}"
|
||||||
done
|
done
|
||||||
|
__wait_for_device ${DEV}
|
||||||
if ext4fuse ${DEV} ${MNT} # sysutils/fusefs-ext4fuse
|
if ext4fuse ${DEV} ${MNT} # sysutils/fusefs-ext4fuse
|
||||||
then
|
then
|
||||||
ADD=1
|
ADD=1
|
||||||
|
|
@ -317,11 +357,13 @@ case ${2} in
|
||||||
;;
|
;;
|
||||||
(*Unix\ Fast\ File*)
|
(*Unix\ Fast\ File*)
|
||||||
__create_mount_point ${DEV}
|
__create_mount_point ${DEV}
|
||||||
|
__wait_for_device ${DEV}
|
||||||
fsck_ufs -C -y ${DEV} \
|
fsck_ufs -C -y ${DEV} \
|
||||||
| while read LINE
|
| while read LINE
|
||||||
do
|
do
|
||||||
__log "${DEV}: fsck_ufs ${LINE}"
|
__log "${DEV}: fsck_ufs ${LINE}"
|
||||||
done
|
done
|
||||||
|
__wait_for_device ${DEV}
|
||||||
if mount -t ufs -o ${OPTS} ${DEV} ${MNT}
|
if mount -t ufs -o ${OPTS} ${DEV} ${MNT}
|
||||||
then
|
then
|
||||||
ADD=1
|
ADD=1
|
||||||
|
|
@ -335,6 +377,7 @@ case ${2} in
|
||||||
case $( dd < ${DEV} count=1 2> /dev/null | strings | head -1 ) in
|
case $( dd < ${DEV} count=1 2> /dev/null | strings | head -1 ) in
|
||||||
(*EXFAT*)
|
(*EXFAT*)
|
||||||
__create_mount_point ${DEV}
|
__create_mount_point ${DEV}
|
||||||
|
__wait_for_device ${DEV}
|
||||||
if mount.exfat -o ${OPTS} ${DEV} ${MNT} # sysutils/fusefs-exfat
|
if mount.exfat -o ${OPTS} ${DEV} ${MNT} # sysutils/fusefs-exfat
|
||||||
then
|
then
|
||||||
ADD=1
|
ADD=1
|
||||||
|
|
@ -344,6 +387,9 @@ case ${2} in
|
||||||
fi
|
fi
|
||||||
__log "${DEV}: mount (exfat)"
|
__log "${DEV}: mount (exfat)"
|
||||||
;;
|
;;
|
||||||
|
(*)
|
||||||
|
__log "${DEV}: filesystem not supported or no filesystem"
|
||||||
|
exit 0
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue