From 71b43f2a32f4005814836f17cdf0fe6c530d6aae Mon Sep 17 00:00:00 2001 From: "Slawomir Wojciech Wojtczak (vermaden)" Date: Sun, 4 Mar 2012 09:29:44 +0100 Subject: [PATCH] 1.3 --- automount | 40 +-- port/distfiles/automount-1.3.tar.gz | Bin 0 -> 3492 bytes port/distfiles/automount-1.3/automount | 236 ++++++++++++++++++ port/distfiles/automount-1.3/automount.conf | 7 + .../automount-1.3/automount.conf.sample | 5 + .../automount-1.3/automount_devd.conf | 14 ++ port/sysutils/automount/Makefile | 2 +- port/sysutils/automount/distinfo | 4 +- 8 files changed, 287 insertions(+), 21 deletions(-) create mode 100644 port/distfiles/automount-1.3.tar.gz create mode 100755 port/distfiles/automount-1.3/automount create mode 100644 port/distfiles/automount-1.3/automount.conf create mode 100644 port/distfiles/automount-1.3/automount.conf.sample create mode 100644 port/distfiles/automount-1.3/automount_devd.conf diff --git a/automount b/automount index ed913cd..2d22d13 100755 --- a/automount +++ b/automount @@ -1,4 +1,4 @@ -#! /bin/sh +#! /bin/sh -x # Copyright (c) 2012 Slawomir Wojciech Wojtczak (vermaden) # All rights reserved. @@ -154,44 +154,45 @@ case ${2} in ADD=0 MNT="${MNTPREFIX}/${1}" __check_already_mounted ${MNT} - __create_mount_point ${DEV} [ "${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 - dd < ${DEV} count=1 2> /dev/null | strings | grep "FAT32" && { - fsck_msdosfs -y ${DEV} - mount_msdosfs -o large -D ${CODEPAGE} -L ${ENCODING} \ - -m 644 -M 755 ${DEV} ${MNT} && ADD=1 - __log "${DEV}:mount (fat)" - } + __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 - dd < ${DEV} count=1 2> /dev/null | strings | head -1 | grep "NTFS" && { - 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)" + __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)" @@ -199,6 +200,7 @@ case ${2} in (*) 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)" ;; @@ -221,12 +223,14 @@ case ${2} in TARGET=$( mount | grep -E "^${PROVIDER} " | awk '{print $3}' ) __state_remove ${MNT} [ -z ${TARGET} ] && continue - umount -f ${TARGET} & + ( # put entire umount and find/rm block into background + umount -f ${TARGET} + [ "${REMOVEDIRS}" = YES ] && find ${TARGET} -type d -empty -maxdepth 1 -exec rm -r {} '+' + ) & unset TARGET __log "${DEV}:umount" done __log "${DEV}:detach" - [ "${REMOVEDIRS}" = YES ] && find ${MNTPREFIX} -type d -empty -maxdepth 1 -delete ;; esac diff --git a/port/distfiles/automount-1.3.tar.gz b/port/distfiles/automount-1.3.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..2f5a90eeadd4600892037c4c6696d6e3bea8aac9 GIT binary patch literal 3492 zcmV;V4O{XbiwFR~CsR)V1MOP>~V0*mc%hXKWEvWo*uplTgdO zl#pc5MYjCvgTN*J-`}TaBw2PK+0AD6?&?(+g=Ni5_cPCQ_w-1%k~o+J$vjr;2hHj? ze~8p-wWGsB!e{;HuvYxch3fUAMze*6#v#?}hqc4!-_YS717}^5D7HdCxpTvr<+$^w z`hBiFok#xpUn17p`sd%is*O*tfBmRguZ#6>J#RFh;~KYWt>!mW`>H6OkpJiFzx7wD zUVHOubW7@erLsl6VDS)oH@7kE+I!Tf)f;5^*1KTlh4ec3r|r4+Enmd;zpS^ko6)j| zpoy1-+Cu{Cd61n8fDGHL%cEuf_u)+tL2H`B) zr*~d_OF<|;gCvHMS>Sk6&$d{_K3Snl3)uGJ*mY|pMA zJRlMSW^UYuruxAKqKJZN2E`5>bc9!64zUG@@h$LO2Y1|*QUe{3c@TTHyN?cDL_XB9 zmZHVEBL=VFz^3h6-pmcb3pGB50doZ!G8mYhlK|Quf`sH0r6MP=lbJh@t!$mDSb_k} zABHV&($|MC z_X#R!I5KIVpXnyLnWKGSD;)-1tAR8+p)+mVJH^-Tu|Ckv3t{s_H-~KPgu&5ycWmmt z$)G!?^U3&pWB~YBgQC7}^afr1OzR&20j!etN*kJFoOTC;;so)xHos#H@VdtXO|!XdCG$TT@|2mM(fESZG8cmUe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e0f6%wzQd%XjI(15)-lfEVgHLy=RNBRv=GlEo>#~)u;v#gX-n|$!7$M_U?<`h+ zQ&5X<>F_PWwe&$AV3=J~ONWHXyf6f(@z}+nEwYm^#8HIAoz>7)ir?5{a-duA*J=-b z>{wz%G4mqhe>9<+;;?jjJ8s-aln(a_qZ6_wPN0Q_5@koe!o)_S3FCl7`9@xk~06O z->rN*^=^@LgnJ{ah_D)+o5&t%R#DOuDZ|;7F{)mZIv_P7>2xWza1gNTTi34NzNAa# z;JZsDWm!ytW%oN2*xxbj;z`%Fi$A0bR~#jw#pYt5jWg%FX>>Jc&myPk!D@{|$)ox&+?Dp0>DeXVXS9i1`3uV~Ja3U8JK`qF zq4Xfb&#tE4+^L2$y2dg7Edm1vBQ9C_Y$KlQtt1_!PFJSZ+Qqu9&WGzqDK=ApsKyTq zmk^Eekf_eAd&gbitXapcd)Fo)QbT&bq@C|~#1sf&`)$FVe5xn)tx;7B9tl|~EYIA1 zaAMqdGnBJ zje4VbRQ~?s&yd37Dg=M!S3SxW&w(;N@^?R-jaM%D3zv>~;ZX+Yf22GS|5yBGStNn4 zVB>S~-+F#1;=j>oHR^}Y5&yNL=Vko=DZ)P;nm$k+kh#X3SuxK0ihMhxkb?d8#86(W zTDTCv{oYtZxm9ei;W22~b*vAwnH@QMztq$p|M9)(Vu_~`q-^}sVdZYL&BIAP)xwY^ zcJ(hr*4GSkJi7SW(9)ViLi=|w+EU{QIq?B /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} +} + +__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 "${PREFIX}/${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} + [ "${REMOVEDIRS}" = YES ] && find ${TARGET} -type d -empty -maxdepth 1 -exec rm -r {} '+' + ) & + unset TARGET + __log "${DEV}:umount" + done + __log "${DEV}:detach" + ;; + +esac diff --git a/port/distfiles/automount-1.3/automount.conf b/port/distfiles/automount-1.3/automount.conf new file mode 100644 index 0000000..1ba5f6c --- /dev/null +++ b/port/distfiles/automount-1.3/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/automount.conf.sample b/port/distfiles/automount-1.3/automount.conf.sample new file mode 100644 index 0000000..a2d89cd --- /dev/null +++ b/port/distfiles/automount-1.3/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/automount_devd.conf b/port/distfiles/automount-1.3/automount_devd.conf new file mode 100644 index 0000000..2614c98 --- /dev/null +++ b/port/distfiles/automount-1.3/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 7799df0..5a23225 100644 --- a/port/sysutils/automount/Makefile +++ b/port/sysutils/automount/Makefile @@ -6,7 +6,7 @@ # PORTNAME= automount -PORTVERSION= 1.2.1 +PORTVERSION= 1.3 CATEGORIES= sysutils MASTER_SITES= https://github.com/vermaden/automount/port/distfiles/ diff --git a/port/sysutils/automount/distinfo b/port/sysutils/automount/distinfo index 8337a25..b37b7d4 100644 --- a/port/sysutils/automount/distinfo +++ b/port/sysutils/automount/distinfo @@ -1,2 +1,2 @@ -SHA256 (automount-1.2.1.tar.gz) = cfb646a24c06630f29979a6834096587a0b564e2343502dcd0563c306d93b291 -SIZE (automount-1.2.1.tar.gz) = 3455 +SHA256 (automount-1.3.tar.gz) = 50f403681725f8bc59f35190c520dbce9c965608a8d61a46bcbef52f28d58d72 +SIZE (automount-1.3.tar.gz) = 3492