diff options
author | B. Stack <bgstack15@gmail.com> | 2023-10-04 16:43:25 -0400 |
---|---|---|
committer | B. Stack <bgstack15@gmail.com> | 2023-10-04 16:43:25 -0400 |
commit | bec3fe5e41aba343b4397fd897d6cb9b6c0a0463 (patch) | |
tree | 847549bdd43109a8256251719ca0408cd271b815 | |
parent | v0.0.2 improve autofs flags to handle ext4 mounts (diff) | |
download | myautomount-bec3fe5e41aba343b4397fd897d6cb9b6c0a0463.tar.gz myautomount-bec3fe5e41aba343b4397fd897d6cb9b6c0a0463.tar.bz2 myautomount-bec3fe5e41aba343b4397fd897d6cb9b6c0a0463.zip |
v0.0.3 add fs_type to automount path
-rw-r--r-- | debian/changelog | 8 | ||||
-rw-r--r-- | debian/myautomount.dsc | 2 | ||||
-rw-r--r-- | files-for-versioning.txt | 4 | ||||
-rw-r--r-- | myautomount.spec | 7 | ||||
-rw-r--r-- | src/Makefile | 2 | ||||
-rwxr-xr-x | src/usr/bin/myautomountd | 22 | ||||
-rw-r--r-- | src/usr/libexec/myautomount/myautomount-initialize.sh | 17 |
7 files changed, 46 insertions, 16 deletions
diff --git a/debian/changelog b/debian/changelog index 87bd9dc..4ad2a3f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +myautomount (0.0.3-1) obs; urgency=low + + * Add filesystem type to automount destination so autofs can + mount both ext4 and ntfs types without having to manually + modify cong files. + + -- B. Stack <bgstack15@gmail.com> Wed, 04 Oct 2023 16:42:35 -0400 + myautomount (0.0.2-1) obs; urgency=low * New version. diff --git a/debian/myautomount.dsc b/debian/myautomount.dsc index 423542f..59390a2 100644 --- a/debian/myautomount.dsc +++ b/debian/myautomount.dsc @@ -2,7 +2,7 @@ Format: 3.0 (quilt) Source: myautomount Binary: myautomount Architecture: all -Version: 0.0.2-1 +Version: 0.0.3-1 Maintainer: B. Stack <bgstack15@gmail.com> Homepage: https://bgstack15.wordpress.com/ Standards-Version: 4.5.0 diff --git a/files-for-versioning.txt b/files-for-versioning.txt new file mode 100644 index 0000000..7962447 --- /dev/null +++ b/files-for-versioning.txt @@ -0,0 +1,4 @@ +myautomount.spec +src/Makefile +debian/changelog +debian/myautomount.dsc diff --git a/myautomount.spec b/myautomount.spec index c324677..8f91f25 100644 --- a/myautomount.spec +++ b/myautomount.spec @@ -20,7 +20,7 @@ %global git_commit 0d5f8b7657527eab8380f5aa81ecd072714cf13c %{?git_commit:%global git_commit_hash %(c=%{git_commit}; echo ${c:0:7})} %else -%global git_commit 0.0.2 +%global git_commit 0.0.3 %endif %global releasenum 1 @@ -46,7 +46,7 @@ Source: https://gitlab.com/bgstack15/%{name}/-/archive/%{git_commit}/%{name} License: CC BY-SA 4.0 and BSD-2-Clause Group: Applications/System URL: https://bgstack15.wordpress.com/ -Packager: B Stack <bgstack15@gmail.com> +Packager: B. Stack <bgstack15@gmail.com> Requires: autofs Requires: sudo Requires: python3-inotify @@ -103,6 +103,9 @@ update-desktop-database 1>/dev/null 2>&1 || : %endif %changelog +* Wed Oct 04 2023 B. Stack <bgstack15@gmail.com> - 0.0.3-1 +- New version + * Mon Oct 25 2021 B. Stack <bgstack15@gmail.com> - 0.0.2-1 - New version 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" |