aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Stack <bgstack15@gmail.com>2023-10-05 14:51:35 -0400
committerB. Stack <bgstack15@gmail.com>2023-10-05 14:51:35 -0400
commit1c1f6e8aca57284e0e03091ad8f4aa673778ef52 (patch)
tree5e69478db972c725c4b454ca5a2a70a3f1eb1450
parentadd _service to scm (diff)
downloadmyautomount-support-lvm.tar.gz
myautomount-support-lvm.tar.bz2
myautomount-support-lvm.zip
WIP: lvm but autofs cannot do thatsupport-lvm
-rwxr-xr-xsrc/usr/bin/myautomountd80
1 files changed, 56 insertions, 24 deletions
diff --git a/src/usr/bin/myautomountd b/src/usr/bin/myautomountd
index e6a1466..1d9370d 100755
--- a/src/usr/bin/myautomountd
+++ b/src/usr/bin/myautomountd
@@ -10,6 +10,7 @@
# 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
+# 2023-10-05 ATTEMPTED TO ADD lvm autofs support, but STOPPED because autofs does not support lvm.
# 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
@@ -62,30 +63,8 @@ handleEvent() {
esac
}
-createEntry() {
- # call: createEntry "{device}" "${filepath}"
- _device="${1}"
- _filepath="${2}"
- test -n "${STACKTRACE}" && echo "STUB createEntry \"${_device}\" \"${_filepath}\"" 1>&2
- 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|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;" )"
+createEntryFile() {
+ # set these beforehand: _filepath, _device, AUTOMOUNT_BROWSEDIR, _use_fs, _label, _vendor, _model, _fs
touch "${_filepath}" ; chmod 0755 "${_filepath}"
{
echo "[Desktop Entry]"
@@ -118,6 +97,59 @@ createEntry() {
} > "${_filepath}"
}
+createEntry() {
+ # call: createEntry "{device}" "${filepath}"
+ _device="${1}"
+ _filepath="${2}"
+ test -n "${STACKTRACE}" && echo "STUB createEntry \"${_device}\" \"${_filepath}\"" 1>&2
+ unset _fs _model _vendor _label _atracks _fs_version _use_fs _vg _lvs
+ _use_lvs=0
+ # _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|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
+ # if lvm, then get all the way down to the logical volume mount point type
+ test "${_fs}" = "LVM2_member" && {
+ _use_lvs=1
+ _vg="$( sudo pvs "/dev/${_device}" --noheadings -o-pv_name,pv_fmt,pv_attr,pv_size,pv_free,vg_name -o+vg_name | xargs )"
+ _lvs="$( sudo lvs "${_vg}" --noheadings -o-vg_name,lv_attr,lv_size,pool_lv,origin,data_percent,metadata_percent,copy_percent,move_pv,mirror_log,convert_lv,lv_name -o+lv_name | xargs )"
+ }
+ 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;" )"
+ if test "${_use_lvs}" = "1" ;
+ then
+ for _thislv in ${_lvs} ;
+ do
+ # get fs type:
+ _device="${_vg}/${_thislv}"
+ _lv_info="$( sudo wipefs "/dev/${_device}" --noheadings --parsable --output TYPE,LABEL )"
+ _fs="$( echo "${_lv_info}" | awk -F',' '{print $1}' )"
+ _label="$( echo "${_lv_info}" | awk -F',' '{print $2}' )"
+ 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;" )"
+ createEntryFile
+ done
+ else
+ # not lvm, so regular
+ createEntryFile
+ fi
+}
+
# INITIALIZE
test -z "${UID}" && export UID="$( $( which id ) -u "${USER}" )"
. ${MYA_PREFIX}/etc/myautomount.conf
bgstack15