From 9d275e6e88e480d7ec77a3da3d67b44c706fa349 Mon Sep 17 00:00:00 2001 From: "Slawomir Wojciech Wojtczak (vermaden)" Date: Sun, 4 Mar 2012 10:48:00 +0100 Subject: [PATCH] 1.3.1 --- README | 189 +++++++------- automount | 16 +- port/distfiles/automount-1.3.1.tar.gz | Bin 0 -> 3532 bytes port/distfiles/automount-1.3.1/automount | 244 ++++++++++++++++++ port/distfiles/automount-1.3.1/automount.conf | 7 + .../automount-1.3.1/automount.conf.sample | 5 + .../automount-1.3.1/automount_devd.conf | 14 + port/sysutils/automount/Makefile | 2 +- port/sysutils/automount/distinfo | 4 +- 9 files changed, 378 insertions(+), 103 deletions(-) create mode 100644 port/distfiles/automount-1.3.1.tar.gz create mode 100755 port/distfiles/automount-1.3.1/automount create mode 100644 port/distfiles/automount-1.3.1/automount.conf create mode 100644 port/distfiles/automount-1.3.1/automount.conf.sample create mode 100644 port/distfiles/automount-1.3.1/automount_devd.conf diff --git a/README b/README index 4c93d51..760074d 100644 --- a/README +++ b/README @@ -1,101 +1,27 @@ -AUTOMOUNT is a devd(8) based flexible yet very simple automounter for FreeBSD. +VERSION 1.3.1 -Currently it supports these file systems: - -- NTFS requires sysutils/fusefs-ntfs for R/W - -- FAT/FAT32 - -- exFAT requires sysutils/fusefs-exfat - -- EXT2 - -- EXT3 - -- EXT4 requires sysutils/fusefs-ext4fuse - -- UFS - -It keeps state of the mounted devices at /var/run/automount.state and logs -all activities to /var/log/automount.log file. - -The place for the script is at /usr/local/sbin/automount.sh executable. - -The only additional configuration it requires is to add these lines as -/usr/local/etc/devd/automount_devd.conf file, which would allow it to work. - -Remember to restart /etc/rc.d/devd daemon after adding -/usr/local/etc/devd/automount_devd.conf file. - -INSTALL: - -# cp automount.sh /usr/local/sbin/automount.sh -# cp automount.conf /usr/local/etc/automount.conf -# cp automount_devd.conf /usr/local/etc/devd/automount_devd.conf -# /etc/rc.d/devd restart - -Now plugin Your USB thumb drive ;) - -Have Fun ;) -vermaden +Fixed the 'detach' section (s/PREFIX/MNTPREFIX/g). +Fixed removing directories of manually (properly) unmounted filesystems. ------------------------------------------------------------------------------- -Latest changes ... +VERSION 1.3 -I removed the state_lock and stat_unlock mechanisms as they appeared to be not -needed, I have shufled with 3 drives all the time and the 'integrity' has not -been lost, at it was a lot faster, because the lock always had to wait for the -'slowest' drive (in term of initializing the device, like USB hard drive). - -I simplified the 'attach' section a lot, now each filesystem contains only -check/fsck (if possible), mount and log info. - -I also simplified and improved the 'detach' section a little. - -I added an option to automatically launch the set-up in config file manager. - -These are options that I currently successfully use for NAUTILUS file manager, -You need to set-up all three of them to make it work. - -| POPUP=YES -| FM="nautilus --browser --no-desktop" -| USER=vermaden - -My whole config looks like that now: - -| USERUMOUNT=YES -| POPUP=YES -| FM="nautilus --browser --no-desktop" -| USER=vermaden -| ENCODING=pl_PL.ISO8859-2 -| CODEPAGE=cp852 - -All latest updates are available at GITHUB repository: -https://github.com/vermaden/automount - -Regards, -vermaden +Fixed inproper exFAT detection, now mounts fine. +Fixed creating mount dirs for attached devices no matter if needed or not. +Revised 'detach' section, now removes only directory that is unmounted. +Simplified FAT/NTFS sections, removed additional checks as they break + some MP3 players automount. ------------------------------------------------------------------------------- -Latest changes ... +VERSION 1.2.1 -FAT/NTFS detection improvements. -The 'chown' now uses sets user's group. -MSDOS filesystem is now mounted with -m 644 -M 755 options by default. -Removed POPUP=YES option, just use USER + FM for simplicity. -NTFS filesystem, when mounted by mount_ntfs(8) uses -u and -g options by default. -Even more simplified 'detach' section. +Added the --help page. +Removed some small bugs. +Added more options to configure features. -Regards, -vermaden -------------------------------------------------------------------------------- - -Latest changes ... - -Added PORT ;) - -Regards, -vermaden - -------------------------------------------------------------------------------- - -Added the --help page, removed some bugs, added options to configure features. % automount --help AUTOMOUNT is a devd(8) based automounter for FreeBSD. @@ -168,17 +94,88 @@ REMOVEDIRS (set to NO by default) example: REMOVEDIRS="YES" -Regards, -vermaden - ------------------------------------------------------------------------------- -Fixed bug about inproper exFAT detection, now mounts fine. -Fixed bug about creating mount dirs for all attached devices no matter if needed or not. -Revised 'detach' section, now removes only directory that is unmounted (if enabled of course). -Simplified FAT/NTFS sections, removed additional check as it break some MP3 players default filesystems automount. +VERSION 1.2 -Regards, +FAT/NTFS detection improvements. +The 'chown' now uses sets user's group. +MSDOS filesystem is now mounted with -m 644 -M 755 options by default. +Removed POPUP=YES option, just use USER + FM for simplicity. +NTFS filesystem, when mounted by mount_ntfs(8) uses -u and -g options. +Even more simplified 'detach' section. + +------------------------------------------------------------------------------ + +VERSION 1.1 + +I removed the state_lock and stat_unlock mechanisms as they appeared to be +not needed, I have shufled with 3 drives all the time and the 'integrity' +has not been lost, at it was a lot faster, because the lock always had to +wait for the 'slowest' drive (in term of initializing the device, like USB +hard drive). + +I simplified the 'attach' section a lot, now each filesystem contains only +check/fsck (if possible), mount and log info. + +I also simplified and improved the 'detach' section a little. + +I added an option to automatically launch the set-up in config file manager. + +These are options that I currently successfully use for NAUTILUS file +manager. You need to set-up all three of them to make it work. + +| POPUP=YES +| FM="nautilus --browser --no-desktop" +| USER=vermaden + +My whole config looks like that now: + +| USERUMOUNT=YES +| POPUP=YES +| FM="nautilus --browser --no-desktop" +| USER=vermaden +| ENCODING=pl_PL.ISO8859-2 +| CODEPAGE=cp852 + +All latest updates are available at GITHUB repository: +https://github.com/vermaden/automount + +------------------------------------------------------------------------------ + +VERSION 1.0 + +AUTOMOUNT is devd(8) based flexible yet very simple automounter for FreeBSD. + +Currently it supports these file systems: + -- NTFS requires sysutils/fusefs-ntfs for R/W + -- FAT/FAT32 + -- exFAT requires sysutils/fusefs-exfat + -- EXT2 + -- EXT3 + -- EXT4 requires sysutils/fusefs-ext4fuse + -- UFS + +It keeps state of the mounted devices at /var/run/automount.state and logs +all activities to /var/log/automount.log file. + +The place for the script is at /usr/local/sbin/automount.sh executable. + +The only additional configuration it requires is to add these lines as +/usr/local/etc/devd/automount_devd.conf file, which would allow it to work. + +Remember to restart /etc/rc.d/devd daemon after adding +/usr/local/etc/devd/automount_devd.conf file. + +INSTALL: + +# cp automount.sh /usr/local/sbin/automount.sh +# cp automount.conf /usr/local/etc/automount.conf +# cp automount_devd.conf /usr/local/etc/devd/automount_devd.conf +# /etc/rc.d/devd restart + +Now plugin Your USB thumb drive ;) + +Have Fun ;) vermaden - diff --git a/automount b/automount index 2d22d13..88acda9 100755 --- a/automount +++ b/automount @@ -143,6 +143,11 @@ __state_remove() { # 1=MNT sed -i '' "/${BSMNT}\$/d" ${STATE} } +__remove_dir() { # 1=TARGET + [ "${REMOVEDIRS}" = YES ] \ + && find "${1}" -type d -empty -maxdepth 1 -exec rm -r {} '+' +} + __log() { # @=MESSAGE echo $( date +"${DATEFMT}" ) ${@} >> ${LOG} } @@ -217,20 +222,23 @@ case ${2} in ;; (detach) - grep -E "${PREFIX}/${1}$" ${STATE} \ + grep -E "${MNTPREFIX}/${1}$" ${STATE} \ | while read DEV PROVIDER MNT do TARGET=$( mount | grep -E "^${PROVIDER} " | awk '{print $3}' ) __state_remove ${MNT} [ -z ${TARGET} ] && continue - ( # put entire umount and find/rm block into background + ( # put entire umount and find/rm block into background umount -f ${TARGET} - [ "${REMOVEDIRS}" = YES ] && find ${TARGET} -type d -empty -maxdepth 1 -exec rm -r {} '+' - ) & + __remove_dir "${TARGET}" + __log "${DEV}:removed '${TARGET}'" + ) & unset TARGET __log "${DEV}:umount" done __log "${DEV}:detach" + __remove_dir "${MNTPREFIX}/${1}" + __log "${DEV}:removed '${MNTPREFIX}/${1}'" ;; esac diff --git a/port/distfiles/automount-1.3.1.tar.gz b/port/distfiles/automount-1.3.1.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..b8e10b65a6e9ae6af25f7e356f406d6aa0e27836 GIT binary patch literal 3532 zcmV;-4Kwl|iwFQHI8#pm1MOOEQ`<-q-p~FOy@D*Ti|`vHyUu!RjV*$zjLlhc5^A}l zgd~G5vgOkYfld71@97yymK`A3Y&LgSr!ET1nwjorp6==Ck!&S#Fb$Gftk(CMd-du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Xy`HicIwLNtR;pF(J#|sCipeOr zZM}U%TkqyzHlEOCeSuxLlA+J5&Ls(%=8TZEZ!!0NE0ZsviMvN9%X`Z$5v@@|>M||c zgfrs}zq>i@ch1_anmCUvd6$Gqd!U6Y9eKc)a0_+sT8&dIf;0Q?dH3@9fh*#OE9tzB zmNlsqCnz{cR*4@H3X}gR(z3=WZ8i&(7HLgSb}KYWD%Ia{SK3>oho^ua5+`mk))9g8 z1X&U-D2vkL6hA@Z8nuer^U@FOH&`Gzo^j#KCoJ)FaVhB_b+WX#7Qf4KnVC)dD31iW z93T!2Y45FK_Z|AK@J&8V%-YI^LIk67E z;`{#xfBzw#3GGGVq1KiK4xU|I!kFOcjrF^nHxc)Er-Lgmmf7-^!*8l!f`TMU% zW4}>9c*^U)-YD1qR}uc{(BzKlfXr3i)QWN9R^;0mg%oUDM~3oz*}@N`aKAg!Q0){O zY{Uy1wjJyJbZSS=&TlpKr@#Lox>(}504Zy~bXW!(ZSruE&y_G_ft~O(k@Ymg91YLD zG_-W@m(c#xPWyuL`2PQ8Y /dev/null 2> /dev/null && { + __log "${DEV}:already mounted (ntfs)" + exit 0 + } +} + +__state_add() { # 1=DEV 2=PROVIDER 3=MNT + grep -E "${3}$" ${STATE} 1> /dev/null 2> /dev/null && { + __log "${1}:duplicated '${STATE}'" + exit 0 + } + echo "${1} ${2} ${3}" >> ${STATE} +} + +__state_remove() { # 1=MNT + BSMNT=$( echo ${1} | sed 's/\//\\\//g' ) # backslash the slashes ;) + sed -i '' "/${BSMNT}\$/d" ${STATE} +} + +__remove_dir() { # 1=TARGET + [ "${REMOVEDIRS}" = YES ] \ + && find "${1}" -type d -empty -maxdepth 1 -exec rm -r {} '+' +} + +__log() { # @=MESSAGE + echo $( date +"${DATEFMT}" ) ${@} >> ${LOG} +} + +DEV=/dev/${1} + +case ${2} in + (attach) + ADD=0 + MNT="${MNTPREFIX}/${1}" + __check_already_mounted ${MNT} + [ "${ATIME}" = NO ] && OPTS="noatime" + case $( file -b -L -s ${DEV} | sed -E 's/label:\ \".*\"//g' ) in + (*FAT*) # must be before NTFS section: newfs_msdos -O NTFS -L NTFS + __create_mount_point ${DEV} + fsck_msdosfs -y ${DEV} + mount_msdosfs -o large -D ${CODEPAGE} -L ${ENCODING} \ + -m 644 -M 755 ${DEV} ${MNT} && ADD=1 + __log "${DEV}:mount (fat)" + ;; + (*NTFS*) # must be after FAT section: newfs_msdos -O NTFS -L NTFS + __create_mount_point ${DEV} + which ntfs-3g 1> /dev/null 2> /dev/null && { + ntfs-3g -o ${OPTS} ${DEV} ${MNT} && ADD=1 # sysutils/fusefs-ntfs + } || { + [ "${USER}" = 0 ] || OPTS="-u ${USER} -g $( id -g -n ${USER} )" + mount_ntfs ${OPTS} -o noatime ${DEV} ${MNT} && ADD=1 + } + __log "${DEV}:mount (ntfs)" + ;; + (*ext2*) + __create_mount_point ${DEV} + fsck.ext2 -y ${DEV} + mount -t ext2fs -o ${OPTS} ${DEV} ${MNT} && ADD=1 + __log "${DEV}:mount (ext2)" + ;; + (*ext3*) + __create_mount_point ${DEV} + fsck.ext3 -y ${DEV} + mount -t ext2fs -o ${OPTS} ${DEV} ${MNT} && ADD=1 + __log "${DEV}:mount (ext3)" + ;; + (*ext4*) + __create_mount_point ${DEV} + fsck.ext4 -y ${DEV} + ext4fuse ${DEV} ${MNT} && ADD=1 # sysutils/fusefs-ext4fuse + __log "${DEV}:mount (ext4)" + ;; + (*Unix\ Fast\ File*) + __create_mount_point ${DEV} + fsck_ufs -C -y ${DEV} + mount -o ${OPTS} ${DEV} ${MNT} && ADD=1 + __log "${DEV}:mount (ufs)" + ;; + (*) + case $( dd < ${DEV} count=1 2> /dev/null | strings | head -1 ) in + (*EXFAT*) + __create_mount_point ${DEV} + mount.exfat -o ${OPTS} ${DEV} ${MNT} && ADD=1 # sysutils/fusefs-exfat + __log "${DEV}:mount (exfat)" + ;; + esac + ;; + esac + [ ${ADD} -eq 1 ] && { + ADD=0 + PROVIDER=$( mount | grep -m 1 " ${MNT} " | awk '{printf $1}' ) + __state_add ${DEV} ${PROVIDER} ${MNT} + [ "${USER}" != 0 ] && [ "${FM}" != 0 ] \ + && su - ${USER} -c "env DISPLAY=:0 ${FM} ${MNT} &" + } + ;; + + (detach) + grep -E "${MNTPREFIX}/${1}$" ${STATE} \ + | while read DEV PROVIDER MNT + do + TARGET=$( mount | grep -E "^${PROVIDER} " | awk '{print $3}' ) + __state_remove ${MNT} + [ -z ${TARGET} ] && continue + ( # put entire umount and find/rm block into background + umount -f ${TARGET} + __remove_dir "${TARGET}" + __log "${DEV}:removed '${TARGET}'" + ) & + unset TARGET + __log "${DEV}:umount" + done + __log "${DEV}:detach" + __remove_dir "${MNTPREFIX}/${1}" + __log "${DEV}:removed '${MNTPREFIX}/${1}'" + ;; + +esac diff --git a/port/distfiles/automount-1.3.1/automount.conf b/port/distfiles/automount-1.3.1/automount.conf new file mode 100644 index 0000000..1ba5f6c --- /dev/null +++ b/port/distfiles/automount-1.3.1/automount.conf @@ -0,0 +1,7 @@ +USERUMOUNT=YES +ATIME=NO +REMOVEDIRS=YES +FM="nautilus --browser --no-desktop" +USER=vermaden +ENCODING=pl_PL.ISO8859-2 +CODEPAGE=cp852 diff --git a/port/distfiles/automount-1.3.1/automount.conf.sample b/port/distfiles/automount-1.3.1/automount.conf.sample new file mode 100644 index 0000000..a2d89cd --- /dev/null +++ b/port/distfiles/automount-1.3.1/automount.conf.sample @@ -0,0 +1,5 @@ +USERUMOUNT=YES +FM="nautilus --browser --no-desktop" +USER=vermaden +ENCODING=pl_PL.ISO8859-2 +CODEPAGE=cp852 diff --git a/port/distfiles/automount-1.3.1/automount_devd.conf b/port/distfiles/automount-1.3.1/automount_devd.conf new file mode 100644 index 0000000..2614c98 --- /dev/null +++ b/port/distfiles/automount-1.3.1/automount_devd.conf @@ -0,0 +1,14 @@ +notify 100 { + match "system" "DEVFS"; + match "type" "CREATE"; + match "cdev" "(da|mmcsd)[0-9]+"; + action "/usr/local/sbin/automount $cdev attach"; +}; + +notify 100 { + match "system" "DEVFS"; + match "type" "DESTROY"; + match "cdev" "(da|mmcsd)[0-9]+"; + action "/usr/local/sbin/automount $cdev detach"; +}; + diff --git a/port/sysutils/automount/Makefile b/port/sysutils/automount/Makefile index 5a23225..cac09f4 100644 --- a/port/sysutils/automount/Makefile +++ b/port/sysutils/automount/Makefile @@ -6,7 +6,7 @@ # PORTNAME= automount -PORTVERSION= 1.3 +PORTVERSION= 1.3.1 CATEGORIES= sysutils MASTER_SITES= https://github.com/vermaden/automount/port/distfiles/ diff --git a/port/sysutils/automount/distinfo b/port/sysutils/automount/distinfo index b37b7d4..c1949e3 100644 --- a/port/sysutils/automount/distinfo +++ b/port/sysutils/automount/distinfo @@ -1,2 +1,2 @@ -SHA256 (automount-1.3.tar.gz) = 50f403681725f8bc59f35190c520dbce9c965608a8d61a46bcbef52f28d58d72 -SIZE (automount-1.3.tar.gz) = 3492 +SHA256 (automount-1.3.1.tar.gz) = 3f37c223d33d6e830f693d3ff57a516d14dbd32a0ee854beb1e2a1d848528663 +SIZE (automount-1.3.1.tar.gz) = 3532