Various fixes. Add MTP/XFS/HFS support. Remove delays.
This commit is contained in:
parent
c4921bb118
commit
fc951d10bc
19
README
19
README
|
|
@ -20,6 +20,11 @@ Now plugin Your USB thumb drive and have fun ;)
|
|||
* sysutils/automount
|
||||
* sysutils/exfat-utils
|
||||
* sysutils/fusefs-exfat
|
||||
* sysutils/fusefs-ntfs
|
||||
* sysutils/fusefs-ext4fuse
|
||||
* sysutils/fusefs-simple-mtpfs
|
||||
* sysutils/fusefs-hfsfuse
|
||||
* sysutils/fusefs-lkl
|
||||
|
||||
Regards,
|
||||
vermaden
|
||||
|
|
@ -29,7 +34,19 @@ vermaden
|
|||
C H A N G E L O G
|
||||
=========================
|
||||
|
||||
VERSION 1.5.8 (CURRENT)
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
VERSION 1.5.9 (CURRENT)
|
||||
|
||||
Decreese DELAY for sleep from '1' to '0.1' for faster monting.
|
||||
Remove __random_wait() at 'attach'.
|
||||
Implement MTP mounting.
|
||||
Added XFS and HFS support.
|
||||
Various fixes and cleanups.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
VERSION 1.5.8
|
||||
|
||||
Omit GVFS filesystem in the mount(8) listing.
|
||||
Improve exFAT mount options.
|
||||
|
|
|
|||
211
automount
211
automount
|
|
@ -29,12 +29,15 @@ __usage() {
|
|||
AUTOMOUNT is a devd(8) based automounter for FreeBSD.
|
||||
|
||||
It supports following file systems:
|
||||
UFS/FAT/exFAT/NTFS/EXT2/EXT3/EXT4
|
||||
UFS/FAT/exFAT/NTFS/EXT2/EXT3/EXT4/MTP/HFS
|
||||
|
||||
It needs these ports to mount NTFS/exFAT/EXT4 respectively:
|
||||
Add these to mount NTFS/exFAT/EXT4/MTP/HFS/XFS respectively:
|
||||
o sysutils/fusefs-ntfs
|
||||
o sysutils/fusefs-exfat
|
||||
o sysutils/fusefs-ext4fuse
|
||||
o sysutils/fusefs-simple-mtpfs
|
||||
o sysutils/fusefs-hfsfuse
|
||||
o sysutils/fusefs-lkl
|
||||
|
||||
By default it mounts/unmounts all removable media but
|
||||
it is possible to set some additional options at the
|
||||
|
|
@ -137,7 +140,7 @@ EOF
|
|||
|
||||
if [ "${1}" = "--version" -o "${1}" = "-version" -o "${1}" = "version" ]
|
||||
then
|
||||
echo "automount 1.5.8 2018/06/13"
|
||||
echo "automount 1.5.9 2018/12/08"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
|
@ -163,7 +166,7 @@ fi
|
|||
: ${USER="0"} # which user to use for popup
|
||||
: ${FM="0"} # which file manager to use
|
||||
: ${TIMEOUT="8"} # stop waiting for device after that time
|
||||
: ${DELAY="1"} # check for the device node that often
|
||||
: ${DELAY="0.1"} # check for the device node that often
|
||||
: ${BOOTDELAY="45"} # wait for boot process to complete
|
||||
: ${NOTIFY="NO"} # use 'notify-send' and 'libnotify'
|
||||
: ${WALL="NO"} # use 'wall(1)'
|
||||
|
|
@ -176,12 +179,16 @@ then
|
|||
fi
|
||||
|
||||
__create_mount_point() { # 1=DEV
|
||||
mkdir -p ${MNT}
|
||||
local DEVICE=${1##*/}
|
||||
mkdir -p ${MNTPREFIX}/${DEVICE}
|
||||
if [ "${USER}" != 0 ]
|
||||
then
|
||||
chown ${USER}:$( id -g -n ${USER} ) ${MNT}
|
||||
chown ${USER}:$( id -g -n ${USER} ) ${MNTPREFIX}/${DEVICE}
|
||||
UID=$( id -u ${USER} )
|
||||
GID=$( id -g ${USER} )
|
||||
else
|
||||
UID=0
|
||||
GID=0
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
@ -291,19 +298,19 @@ __wait_for_boot() {
|
|||
fi
|
||||
}
|
||||
|
||||
__random_wait() {
|
||||
RANDOM=$( head -c 256 /dev/urandom | env LC_ALL=C tr -c -d '1-9' )
|
||||
MODULO=$(( ${RANDOM} % 24 ))
|
||||
WAIT=$( echo ${MODULO} / 10 | bc -l )
|
||||
WAIT_TEST=$( echo ${WAIT} | awk -F'.' '{print $1}' )
|
||||
if [ "${WAIT_TEST}" = "" ]
|
||||
then
|
||||
WAIT="0${WAIT}"
|
||||
fi
|
||||
WAIT=$( printf "%.1f" ${WAIT} )
|
||||
sleep ${WAIT}
|
||||
__log "${DEV}: random wait for '${WAIT}' seconds before 'attach' action"
|
||||
}
|
||||
# __random_wait() {
|
||||
# RANDOM=$( head -c 256 /dev/urandom | env LC_ALL=C tr -c -d '1-9' )
|
||||
# MODULO=$(( ${RANDOM} % 24 ))
|
||||
# WAIT=$( echo ${MODULO} / 10 | bc -l )
|
||||
# WAIT_TEST=$( echo ${WAIT} | awk -F'.' '{print $1}' )
|
||||
# if [ "${WAIT_TEST}" = "" ]
|
||||
# then
|
||||
# WAIT="0${WAIT}"
|
||||
# fi
|
||||
# WAIT=$( printf "%.1f" ${WAIT} )
|
||||
# sleep ${WAIT}
|
||||
# __log "${DEV}: random wait for '${WAIT}' seconds before 'attach' action"
|
||||
# }
|
||||
|
||||
__fstype() { # 1=DEV
|
||||
TYPE=$( dd < ${DEV} count=1 2> /dev/null | strings | head -1 )
|
||||
|
|
@ -334,6 +341,16 @@ __fstype() { # 1=DEV
|
|||
TYPE=EXT4
|
||||
return
|
||||
fi
|
||||
if echo "${TYPE}" | grep -q 'SGI XFS'
|
||||
then
|
||||
TYPE=XFS
|
||||
return
|
||||
fi
|
||||
if echo "${TYPE}" | grep -q 'Macintosh HFS'
|
||||
then
|
||||
TYPE=HFS
|
||||
return
|
||||
fi
|
||||
if echo "${TYPE}" | grep -q 'boot sector'
|
||||
then
|
||||
TYPE=$( file -r -k -b -L -s ${DEV} | sed -E 's/label:\ \".*\"//g' )
|
||||
|
|
@ -368,12 +385,91 @@ __fstype() { # 1=DEV
|
|||
}
|
||||
|
||||
DEV=/dev/${1}
|
||||
|
||||
__wait_for_boot
|
||||
case ${1} in
|
||||
|
||||
(ugen*)
|
||||
case ${2} in
|
||||
|
||||
(attach)
|
||||
__random_wait
|
||||
# __random_wait
|
||||
__log "${DEV}: attach"
|
||||
if [ "${BLACKLIST}" != "" ]
|
||||
then
|
||||
__log "${DEV}: using BLACKLIST='${BLACKLIST}'"
|
||||
for I in ${BLACKLIST}
|
||||
do
|
||||
if [ ${1} = "${I}" ]
|
||||
then
|
||||
__log "${DEV}: device blocked by BLACKLIST option"
|
||||
exit 0
|
||||
fi
|
||||
done
|
||||
fi
|
||||
ADD=0
|
||||
MNT="${MNTPREFIX}/${1}"
|
||||
__check_already_mounted -d ${DEV}
|
||||
__check_already_mounted -m ${MNT}
|
||||
__wait_for_device ${DEV}
|
||||
PHONEDEV=$( simple-mtpfs --list-devices -d ${DEV} 2>&1 )
|
||||
if [ "${PHONEDEV}" = "No raw devices found." ]
|
||||
then
|
||||
__log "${DEV}: no raw devices found"
|
||||
exit 0
|
||||
else
|
||||
PHONEDEV=$( echo "${PHONEDEV}" | awk '{print $1}' | tr -d ':' )
|
||||
fi
|
||||
__create_mount_point ${DEV}
|
||||
simple-mtpfs --device ${PHONEDEV} ${MNT} -o uid=${UID} -o gid=${GID} -o allow_other
|
||||
if [ ${?} -ne 0 ]
|
||||
then
|
||||
su - ${USER} -c "env DISPLAY=:0 zenity --info --text 'Allow on the Phone.\n\nThen click OK.' --no-wrap"
|
||||
exit 0
|
||||
else
|
||||
# simple-mtpfs --device ${PHONEDEV} ${MNT} -o uid=${UID} -o gid=${GID} -o allow_other
|
||||
PROVIDER=$( mount | grep -m 1 " ${MNT} " | awk '{printf $1}' )
|
||||
__state_add ${DEV} ${PROVIDER} ${MNT}
|
||||
if [ "${USER}" != 0 -a "${FM}" != 0 ]
|
||||
then
|
||||
su - ${USER} -c "env DISPLAY=:0 ${FM} ${MNT} &"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
|
||||
(detach)
|
||||
__log "${DEV}: detach"
|
||||
if [ -f ${STATE} ]
|
||||
then
|
||||
grep -E "${MNTPREFIX}/${1}$" ${STATE} \
|
||||
| while read DEV PROVIDER MNT
|
||||
do
|
||||
TARGET=$( mount | grep -v \.gvfs | grep -m 1 -E "^${PROVIDER} " | awk '{print $3}' )
|
||||
__state_remove ${MNT}
|
||||
if [ -z ${TARGET} ]
|
||||
then
|
||||
continue
|
||||
fi
|
||||
( # put entire umount/find/rm block into background
|
||||
umount -f ${TARGET}
|
||||
__remove_dir "${TARGET}"
|
||||
__log "${DEV}: removed '${TARGET}'"
|
||||
) &
|
||||
unset TARGET
|
||||
__log "${DEV}: umount"
|
||||
done
|
||||
__remove_dir "${MNTPREFIX}/${1}"
|
||||
__log "${DEV}: mount point '${MNTPREFIX}/${1}' removed"
|
||||
fi
|
||||
;;
|
||||
|
||||
esac
|
||||
;;
|
||||
|
||||
(da*|mmcsd*)
|
||||
case ${2} in
|
||||
|
||||
(attach)
|
||||
# __random_wait
|
||||
__log "${DEV}: attach"
|
||||
if [ "${BLACKLIST}" != "" ]
|
||||
then
|
||||
|
|
@ -398,6 +494,7 @@ case ${2} in
|
|||
__wait_for_device ${DEV}
|
||||
__fstype ${DEV}
|
||||
case ${TYPE} in
|
||||
|
||||
(UFS)
|
||||
__create_mount_point ${DEV}
|
||||
__wait_for_device ${DEV}
|
||||
|
|
@ -414,8 +511,9 @@ case ${2} in
|
|||
__log "${DEV}: mount failed (ufs) 'mount -t ufs ${OPTS} ${DEV} ${MNT}'"
|
||||
exit 1
|
||||
fi
|
||||
__log "${DEV}: mount (ufs)"
|
||||
__log "${DEV}: mount (ufs) 'mount -t ufs ${OPTS} ${DEV} ${MNT}'"
|
||||
;;
|
||||
|
||||
(FAT) # must be before NTFS section because: newfs_msdos -O NTFS -L NTFS
|
||||
__create_mount_point ${DEV}
|
||||
__wait_for_device ${DEV}
|
||||
|
|
@ -431,7 +529,7 @@ case ${2} in
|
|||
else
|
||||
USEROPTS=""
|
||||
fi
|
||||
FATCMD=$( mount_msdosfs ${OPTS} -o large -o longnames -m 644 -M 755 -D ${CODEPAGE} -L ${ENCODING} ${USEROPTS} ${DEV} ${MNT} )
|
||||
FATCMD="mount_msdosfs ${OPTS} -o longnames -m 644 -M 755 -D ${CODEPAGE} -L ${ENCODING} ${USEROPTS} ${DEV} ${MNT}"
|
||||
if ${FATCMD}
|
||||
then
|
||||
ADD=1
|
||||
|
|
@ -440,13 +538,13 @@ case ${2} in
|
|||
FATCUR=0
|
||||
while sleep 1
|
||||
do
|
||||
FATCUR=$(( FATCUR + 1 ))
|
||||
FATCUR=$(( ${FATCUR} + 1 ))
|
||||
if [ ${FATCUR} -gt ${FATOUT} ]
|
||||
then
|
||||
__log "${DEV}: mount failed (fat) 'mount_msdosfs ${OPTS} -o large -o longnames -D ${CODEPAGE} -L ${ENCODING} -m 644 -M 755 ${USEROPTS} ${DEV} ${MNT}'"
|
||||
__log "${DEV}: mount failed (fat) '${FATCMD}'"
|
||||
break
|
||||
fi
|
||||
FATCMD
|
||||
${FATCMD}
|
||||
if [ ${?} -eq 0 ]
|
||||
then
|
||||
ADD=1
|
||||
|
|
@ -457,8 +555,14 @@ case ${2} in
|
|||
done
|
||||
exit 1
|
||||
fi
|
||||
__log "${DEV}: mount (fat)"
|
||||
if [ ${ADD} -eq 1 ]
|
||||
then
|
||||
__log "${DEV}: mount (fat) '${FATCMD}'"
|
||||
else
|
||||
__log "${DEV}: mount failed (fat) '${FATCMD}'"
|
||||
fi
|
||||
;;
|
||||
|
||||
(NTFS) # must be after FAT section: newfs_msdos -O NTFS -L NTFS
|
||||
__create_mount_point ${DEV}
|
||||
__wait_for_device ${DEV}
|
||||
|
|
@ -491,8 +595,9 @@ case ${2} in
|
|||
exit 1
|
||||
fi
|
||||
fi
|
||||
__log "${DEV}: mount (ntfs)"
|
||||
__log "${DEV}: mount (ntfs) 'mount_ntfs ${OPTS} ${DEV} ${MNT}'"
|
||||
;;
|
||||
|
||||
(EXT2)
|
||||
__create_mount_point ${DEV}
|
||||
__wait_for_device ${DEV}
|
||||
|
|
@ -509,8 +614,9 @@ case ${2} in
|
|||
__log "${DEV}: mount failed (ext2) 'mount -t ext2fs ${OPTS} ${DEV} ${MNT}'"
|
||||
exit 1
|
||||
fi
|
||||
__log "${DEV}: mount (ext2)"
|
||||
__log "${DEV}: mount (ext2) 'mount -t ext2fs ${OPTS} ${DEV} ${MNT}'"
|
||||
;;
|
||||
|
||||
(EXT3)
|
||||
__create_mount_point ${DEV}
|
||||
__wait_for_device ${DEV}
|
||||
|
|
@ -527,8 +633,9 @@ case ${2} in
|
|||
__log "${DEV}: mount failed (ext3) 'mount -t ext2fs ${OPTS} ${DEV} ${MNT}'"
|
||||
exit 1
|
||||
fi
|
||||
__log "${DEV}: mount (ext3)"
|
||||
__log "${DEV}: mount (ext3) 'mount -t ext2fs ${OPTS} ${DEV} ${MNT}'"
|
||||
;;
|
||||
|
||||
(EXT4)
|
||||
__create_mount_point ${DEV}
|
||||
__wait_for_device ${DEV}
|
||||
|
|
@ -545,8 +652,9 @@ case ${2} in
|
|||
__log "${DEV}: mount failed (ext4) 'ext4fuse ${DEV} ${MNT}'"
|
||||
exit 1
|
||||
fi
|
||||
__log "${DEV}: mount (ext4)"
|
||||
__log "${DEV}: mount (ext4) 'ext4fuse ${DEV} ${MNT}'"
|
||||
;;
|
||||
|
||||
(EXFAT)
|
||||
__create_mount_point ${DEV}
|
||||
__wait_for_device ${DEV}
|
||||
|
|
@ -562,15 +670,49 @@ case ${2} in
|
|||
then
|
||||
ADD=1
|
||||
else
|
||||
__log "${DEV}: mount failed (exfat) 'mount.exfat ${OPTS} ${USEROPTS} ${DEV} ${MNT}'"
|
||||
__log "${DEV}: mount failed (exfat) 'mount.exfat ${OPTS} ${USEROPTS} -o dmask=022 -o fmask=133 -o noatime ${DEV} ${MNT}'"
|
||||
exit 1
|
||||
fi
|
||||
__log "${DEV}: mount (exfat)"
|
||||
__log "${DEV}: mount (exfat) 'mount.exfat ${OPTS} ${USEROPTS} -o dmask=022 -o fmask=133 -o noatime ${DEV} ${MNT}'"
|
||||
;;
|
||||
|
||||
(XFS)
|
||||
__create_mount_point ${DEV}
|
||||
__wait_for_device ${DEV}
|
||||
xfs_repair -d ${DEV} \
|
||||
| while read LINE
|
||||
do
|
||||
__log "${DEV}: xfs_repair ${LINE}"
|
||||
done
|
||||
__wait_for_device ${DEV}
|
||||
if lklfuse -o type=xfs -o allow_other -o uid=${UID} -o gid=${GID} ${DEV} ${MNT} # sysutils/fusefs-lkl
|
||||
then
|
||||
ADD=1
|
||||
else
|
||||
__log "${DEV}: mount failed (xfs) 'lklfuse -o type=xfs -o allow_other -o uid=${UID} -o gid=${GID} ${DEV} ${MNT}'"
|
||||
exit 1
|
||||
fi
|
||||
__log "${DEV}: mount (xfs) 'lklfuse -o type=xfs -o allow_other -o uid=${UID} -o gid=${GID} ${DEV} ${MNT}'"
|
||||
;;
|
||||
|
||||
(HFS)
|
||||
__create_mount_point ${DEV}
|
||||
__wait_for_device ${DEV}
|
||||
if hfsfuse --force -o noatime ${DEV} ${MNT} # sysutils/fusefs-hfsfuse
|
||||
then
|
||||
ADD=1
|
||||
else
|
||||
__log "${DEV}: mount failed (hfs) 'hfsfuse --force -o noatime ${DEV} ${MNT}'"
|
||||
exit 1
|
||||
fi
|
||||
__log "${DEV}: mount (hfs) 'hfsfuse --force -o noatime ${DEV} ${MNT}'"
|
||||
;;
|
||||
|
||||
(*)
|
||||
__log "${DEV}: filesystem not supported or no filesystem"
|
||||
exit 0
|
||||
;;
|
||||
|
||||
esac
|
||||
if [ ${ADD} -eq 1 ]
|
||||
then
|
||||
|
|
@ -611,3 +753,6 @@ case ${2} in
|
|||
;;
|
||||
|
||||
esac
|
||||
;;
|
||||
|
||||
esac
|
||||
|
|
|
|||
Loading…
Reference in New Issue