aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile2
-rwxr-xr-xsrc/usr/bin/myautomountd22
-rw-r--r--src/usr/libexec/myautomount/myautomount-initialize.sh17
3 files changed, 28 insertions, 13 deletions
diff --git a/src/Makefile b/src/Makefile
index ac6bc46..14e83af 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -14,7 +14,7 @@
# build-devuan: txt2man, bgscripts-core
APPNAME = myautomount
-APPVERSION = 0.0.2
+APPVERSION = 0.0.3
SRCDIR = $(CURDIR)
prefix = /usr
SYSCONFDIR = $(DESTDIR)/etc
diff --git a/src/usr/bin/myautomountd b/src/usr/bin/myautomountd
index 0cbfb1f..e6a1466 100755
--- a/src/usr/bin/myautomountd
+++ b/src/usr/bin/myautomountd
@@ -9,6 +9,7 @@
# History:
# 2020-09-23 originally translated by bgstack15 to shell from Go version (reference 1)
# 2020-09-25 diverged from original architecture
+# 2023-10-04 add fs_type to path to make autofs work with exact fs type
# Usage:
# Invoke this at X startup. This can be from the xdg autostart mechanism, or "exec myautomountd &" in ~/fluxbox.startup
# This is the backend to myautomount-trayicon
@@ -66,22 +67,25 @@ createEntry() {
_device="${1}"
_filepath="${2}"
test -n "${STACKTRACE}" && echo "STUB createEntry \"${_device}\" \"${_filepath}\"" 1>&2
- _fs=
- _model=
- _vendor=
- _label=
- _atracks=
+ unset _fs _model _vendor _label _atracks _fs_version _use_fs
+ # _use_fs simplifies the mount types a little
_bytes="$( udevadm info "/dev/${_device}" 2>/dev/null )"
- _shortbytes="$( printf "%s\n" "${_bytes}" | sed -r -e 's/^E:\s*//;' | grep -E '^(ID_FS_TYPE|ID_MODEL|ID_VENDOR|ID_FS_LABEL|ID_CDROM_MEDIA_TRACK_COUNT_AUDIO)=' )"
- unset ID_FS_TYPE ID_MODEL ID_VENDOR ID_FS_LABEL ID_CDROM_MEDIA_TRACK_COUNT_AUDIO
+ _shortbytes="$( printf "%s\n" "${_bytes}" | sed -r -e 's/^E:\s*//;' | grep -E '^(ID_FS_TYPE|ID_MODEL|ID_VENDOR|ID_FS_LABEL|ID_CDROM_MEDIA_TRACK_COUNT_AUDIO|ID_FS_VERSION)=' )"
+ unset ID_FS_TYPE ID_MODEL ID_VENDOR ID_FS_LABEL ID_CDROM_MEDIA_TRACK_COUNT_AUDIO ID_FS_VERSION
eval "${_shortbytes}"
_fs="${ID_FS_TYPE}"
+ _fs_version="${ID_FS_VERSION}"
_model="${ID_MODEL}"
_vendor="${ID_VENDOR}"
_label="${ID_FS_LABEL}"
_atracks="${ID_CDROM_MEDIA_TRACK_COUNT_AUDIO}"
test -n "${DEBUG}" && echo "fs=${_fs} model=${_model} vendor=${_vendor} label=${_label} atracks=${_atracks}" 1>&2
test "${_fs}" = "" && test "${_atracks}" = "" && return # if the fs cannot be detected
+ test "${_fs}" = "vfat" && test "${_fs_version}" = "FAT32" && _use_fs="fat32"
+ case "${_fs}" in
+ ntfs|ext4) _use_fs="${_fs}" ;;
+ esac
+ _use_fs="$( echo "/${_use_fs%%/}/" | sed -r -e "s@\/\/@\/@g;" )"
touch "${_filepath}" ; chmod 0755 "${_filepath}"
{
echo "[Desktop Entry]"
@@ -95,8 +99,8 @@ createEntry() {
echo "Exec=xdg-open cdda:///dev/${_device}"
else
echo "Type=Application"
- echo "Exec=xdg-open ${AUTOMOUNT_BROWSEDIR}/${_device}"
- echo "Path=${AUTOMOUNT_BROWSEDIR}/${_device}"
+ echo "Exec=xdg-open ${AUTOMOUNT_BROWSEDIR}${_use_fs}${_device}"
+ echo "Path=${AUTOMOUNT_BROWSEDIR}${_use_fs}${_device}"
fi
if test -z "${_label}" ; then
echo "Name=${_vendor} ${_model}"
diff --git a/src/usr/libexec/myautomount/myautomount-initialize.sh b/src/usr/libexec/myautomount/myautomount-initialize.sh
index 8d47bdd..1194ed5 100644
--- a/src/usr/libexec/myautomount/myautomount-initialize.sh
+++ b/src/usr/libexec/myautomount/myautomount-initialize.sh
@@ -11,18 +11,29 @@ fail() {
setupSystem() {
_needrestart=0
mkdir -m0755 -p "${MYA_PREFIX}${AUTOMOUNT_DIR}" || fail "Could not setup autofs rules! Check if this is being run as root?"
- ! grep -q -e "uid=${AUTOMOUNT_USER}," "${MYA_PREFIX}${AUTOMOUNT_FILE}" 2>/dev/null && {
+ ! grep -q -e "uid=${AUTOMOUNT_USER}," "${MYA_PREFIX}${AUTOMOUNT_FILE}.fat32" 2>/dev/null && {
{
touch "${MYA_PREFIX}${AUTOMOUNT_FILE}"
echo "# for fat32, ntfs"
echo "* -fstype=auto,noatime,rw,nosuid,uid=${AUTOMOUNT_USER},gid=users :/dev/& "
+ } > "${MYA_PREFIX}${AUTOMOUNT_FILE}.fat32" || fail "Could not setup autofs rules! Check if this is being run as root?"
+ _needrestart=1
+ }
+ ! grep -q -e "fstype=auto,noatime" "${MYA_PREFIX}${AUTOMOUNT_FILE}.ext4" 2>/dev/null && {
+ {
echo "# for ext4"
echo "* -fstype=auto,noatime,rw,nosuid :/dev/& "
- } > "${MYA_PREFIX}${AUTOMOUNT_FILE}" || fail "Could not setup autofs rules! Check if this is being run as root?"
+ } > "${MYA_PREFIX}${AUTOMOUNT_FILE}.ext4" || fail "Could not setup autofs rules! Check if this is being run as root?"
_needrestart=1
}
! grep -q -e "${AUTOMOUNT_BROWSEDIR}" "${MYA_PREFIX}${AUTOMOUNT_DIR_FILE}" 2>/dev/null && {
- { touch "${MYA_PREFIX}${AUTOMOUNT_DIR_FILE}" && echo "${AUTOMOUNT_BROWSEDIR} ${AUTOMOUNT_FILE} --timeout=5 " > "${MYA_PREFIX}${AUTOMOUNT_DIR_FILE}" ; } || fail "Could not setup autofs rules! Check if this is being run as root?"
+ {
+ touch "${MYA_PREFIX}${AUTOMOUNT_DIR_FILE}"
+ echo "${AUTOMOUNT_BROWSEDIR}/ext4 ${AUTOMOUNT_FILE}.ext4 --timeout=5 "
+ echo "${AUTOMOUNT_BROWSEDIR}/fat32 ${AUTOMOUNT_FILE}.fat32 --timeout=5 "
+ echo "${AUTOMOUNT_BROWSEDIR}/ntfs ${AUTOMOUNT_FILE}.fat32 --timeout=5 "
+ echo "#${AUTOMOUNT_BROWSEDIR} ${AUTOMOUNT_FILE} --timeout=5 "
+ } > "${MYA_PREFIX}${AUTOMOUNT_DIR_FILE}" || fail "Could not setup autofs rules! Check if this is being run as root?"
_needrestart=1
}
test ${_needrestart} -eq 1 && test -z "${MYA_SKIP_RESTART}" && eval "service autofs restart"
bgstack15