From 5f95b7cf0315b9184689d91b69eaf481928f6c18 Mon Sep 17 00:00:00 2001 From: "Slawomir Wojciech Wojtczak (vermaden)" Date: Tue, 21 Feb 2012 09:57:27 +0100 Subject: [PATCH] 1.0 --- README | 9 + automount.sh => automount | 0 automount_devd.conf | 4 +- automount_devd_DEBUG.conf | 4 +- port/distfiles/automount-1.0.tar.gz | Bin 0 -> 2553 bytes port/distfiles/automount-1.0/automount | 155 ++++++++++++++++++ .../automount-1.0/automount.conf.sample | 5 + .../automount-1.0/automount_devd.conf | 15 ++ port/sysutils/automount/Makefile | 26 +++ port/sysutils/automount/distinfo | 3 + port/sysutils/automount/pkg-descr | 6 + 11 files changed, 223 insertions(+), 4 deletions(-) rename automount.sh => automount (100%) create mode 100644 port/distfiles/automount-1.0.tar.gz create mode 100755 port/distfiles/automount-1.0/automount create mode 100644 port/distfiles/automount-1.0/automount.conf.sample create mode 100644 port/distfiles/automount-1.0/automount_devd.conf create mode 100644 port/sysutils/automount/Makefile create mode 100644 port/sysutils/automount/distinfo create mode 100644 port/sysutils/automount/pkg-descr diff --git a/README b/README index 892d602..c0dd94c 100644 --- a/README +++ b/README @@ -83,3 +83,12 @@ Even more simplified 'detach' section. Regards, vermaden + +------------------------------------------------------------------------------- + +Latest changes ... + +Added PORT ;) + +Regards, +vermaden diff --git a/automount.sh b/automount similarity index 100% rename from automount.sh rename to automount diff --git a/automount_devd.conf b/automount_devd.conf index 2e8c08f..c651bbb 100644 --- a/automount_devd.conf +++ b/automount_devd.conf @@ -2,14 +2,14 @@ notify 200 { match "system" "DEVFS"; match "type" "CREATE"; match "cdev" "(da|mmcsd)[0-9]+"; - action "/usr/local/sbin/automount.sh $cdev attach"; + action "/usr/local/sbin/automount $cdev attach"; }; notify 200 { match "system" "DEVFS"; match "type" "DESTROY"; match "cdev" "(da|mmcsd)[0-9]+"; - action "/usr/local/sbin/automount.sh $cdev detach"; + action "/usr/local/sbin/automount $cdev detach"; }; diff --git a/automount_devd_DEBUG.conf b/automount_devd_DEBUG.conf index 357fd31..ff7f2b3 100644 --- a/automount_devd_DEBUG.conf +++ b/automount_devd_DEBUG.conf @@ -2,13 +2,13 @@ notify 200 { match "system" "DEVFS"; match "type" "CREATE"; match "cdev" "(da|mmcsd)[0-9]+"; - action "/usr/local/sbin/automount.sh $cdev attach >> /root/DEBUG.$cdev.attach 2>&1"; + action "/usr/local/sbin/automount $cdev attach >> /root/DEBUG.$cdev.attach 2>&1"; }; notify 200 { match "system" "DEVFS"; match "type" "DESTROY"; match "cdev" "(da|mmcsd)[0-9]+"; - action "/usr/local/sbin/automount.sh $cdev detach >> /root/DEBUG.$cdev.detach 2>&1"; + action "/usr/local/sbin/automount $cdev detach >> /root/DEBUG.$cdev.detach 2>&1"; }; diff --git a/port/distfiles/automount-1.0.tar.gz b/port/distfiles/automount-1.0.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..7228a94307357d8981c76efd42fd3332f91ca0b5 GIT binary patch literal 2553 zcmVj!iH@9kIj;r|0^Z}%6Hekh6u+W)!#*M6nSh38kI zt5Ru=TEX--^e(Sr+Oo@3gKx+fTQ|YP3+XiY!}eVJiao^kpVkN3nsZWys5~AM7mX-% zBR9Nuot@Ge26Wf)qB!&}lGqD;vV4b<$R*FGC`dxvc!b!AEH(q>2LCC*@ zB!-en;CLg?wwQ`-vO<@pu(Dd|u0012@s$-r#dsXtc>X2Xf$w-sAmRcOH*P>v zb>|MEh=S1^iXAwZh>*Y^cEM9dfYrw4KlPN^HkOq!gF8O-l}b-O^0U~R7f6}Cz?)juT3qjXX@(Vz|?eu zHf00TH~E0vJA*3aU0+uWgD_j|_B$$cK&dYGOjR+qN$s^dgSOf`-X^G^o@P=MDBc1V80NwWFG6+~$#L_L#LJ29El&ZmO+8N7ku7(EFMJ;JN}u zZPjRXWVNfbcYpv^NqMXEOfpX7PN%p){4K5TPysyou%o0F_zK&quCz?Hl*LmEWC2-c zn~c8FQrUy@PQgNC{cJnaYAF96U=jwYEqCQ(#elM{uMh%9vG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L7jvH#$Nk8SGt>{}_Ed>bSh4S}c$Y|77INZwFqTH1?-XCt;lcQJ>Jqk^ zJDJ9}Bs%Wcjos3t-~T>v|IhCdb|Pys9lL+qh9pU>Y6C73IMHt+$O9@f*1B7JsAr7WOiQj0<`6%UAIn(j5-^p)s zYNh+EaUKPwlDw P!`uG=_Pqta04M+eU&Rkt literal 0 HcmV?d00001 diff --git a/port/distfiles/automount-1.0/automount b/port/distfiles/automount-1.0/automount new file mode 100755 index 0000000..4e8db72 --- /dev/null +++ b/port/distfiles/automount-1.0/automount @@ -0,0 +1,155 @@ +#! /bin/sh + +# Copyright (c) 2012 Slawomir Wojciech Wojtczak (vermaden) +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that following conditions are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS 'AS IS' AND ANY +# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin + +[ -f /usr/local/etc/automount.conf ] && . /usr/local/etc/automount.conf + +: ${MNTPREFIX="/media"} # mount prefix +: ${LOG="/var/log/automount.log"} # log file +: ${STATE="/var/run/automount.state"} # current state file +: ${ENCODING="en_US.ISO8859-1"} # US/Canada +: ${CODEPAGE="cp437"} # US/Canada +: ${DATEFMT="%Y-%m-%d %H:%M:%S"} # 2012-02-20 07:49:09 +: ${USERUMOUNT="NO"} # when YES add suid bit to umount(8) +: ${USER="0"} # which user to use for popup +: ${FM="0"} # which file manager to use + +[ "${USERUMOUNT}" = YES ] && chmod u+s /sbin/umount # WHEEL group member + +__create_mount_point() { # 1=DEV + mkdir -p ${MNT} + [ "${USER}" = 0 ] || chown ${USER}:$( id -g -n ${USER} ) ${MNT} +} + +__check_already_mounted() { # 1=MNT + mount | grep " ${1} " 1> /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} + __create_mount_point ${DEV} + 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)" + } + ;; + (*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 ntfsfix 1> /dev/null 2> /dev/null && { + ntfsfix ${DEV} # sysutils/ntfsprogs + } + which ntfs-3g 1> /dev/null 2> /dev/null && { + ntfs-3g -o noatime ${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*) + fsck.ext2 -y ${DEV} + mount -t ext2fs -o noatime ${DEV} ${MNT} && ADD=1 + __log "${DEV}:mount (ext2)" + ;; + (*ext3*) + fsck.ext3 -y ${DEV} + mount -t ext2fs -o noatime ${DEV} ${MNT} && ADD=1 + __log "${DEV}:mount (ext3)" + ;; + (*ext4*) + fsck.ext4 -y ${DEV} + ext4fuse ${DEV} ${MNT} && ADD=1 # sysutils/fusefs-ext4fuse + __log "${DEV}:mount (ext4)" + ;; + (*Unix\ Fast\ File*) + fsck_ufs -y ${DEV} + mount -o noatime ${DEV} ${MNT} && ADD=1 + __log "${DEV}:mount (ufs)" + ;; + (*) + case $( dd < ${DEV} count=1 2> /dev/null | strings | head -1 ) in + (EXFAT) + mount.exfat -o noatime ${DEV} ${MNT} && ADD=1 # sysutils/fusefs-exfat + __log "${DEV}:mount (ufs)" + ;; + 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 + umount -f ${TARGET} & + unset TARGET + __log "${DEV}:umount" + done + __log "${DEV}:detach" + ;; + +esac + +find ${MNTPREFIX} -type d -empty -delete diff --git a/port/distfiles/automount-1.0/automount.conf.sample b/port/distfiles/automount-1.0/automount.conf.sample new file mode 100644 index 0000000..a2d89cd --- /dev/null +++ b/port/distfiles/automount-1.0/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.0/automount_devd.conf b/port/distfiles/automount-1.0/automount_devd.conf new file mode 100644 index 0000000..c651bbb --- /dev/null +++ b/port/distfiles/automount-1.0/automount_devd.conf @@ -0,0 +1,15 @@ +notify 200 { + match "system" "DEVFS"; + match "type" "CREATE"; + match "cdev" "(da|mmcsd)[0-9]+"; + action "/usr/local/sbin/automount $cdev attach"; +}; + +notify 200 { + 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 new file mode 100644 index 0000000..952c3dd --- /dev/null +++ b/port/sysutils/automount/Makefile @@ -0,0 +1,26 @@ +# New ports collection makefile for: automount +# Date created: 21 Febryaru 2012 +# Whom: vermaden +# +# $FreeBSD$ +# + +PORTNAME= automount +PORTVERSION= 1.0 +CATEGORIES= sysutils +MASTER_SITES= https://github.com/vermaden/automount/ + +MAINTAINER= vermaden@interia.pl +COMMENT= devd(8) based automount sollution + +PLIST_FILES= sbin/automount etc/devd/automount_devd.conf etc/automount.conf.sample + +do-build: + +do-install: + ${INSTALL_SCRIPT} ${WRKSRC}/automount ${PREFIX}/sbin + ${INSTALL_DATA} ${WRKSRC}/automount_devd.conf ${PREFIX}/etc/devd/automount_devd.conf + ${INSTALL_DATA} ${WRKSRC}/automount.conf.sample ${PREFIX}/etc/automount.conf.sample + /etc/rc.d/devd restart + +.include diff --git a/port/sysutils/automount/distinfo b/port/sysutils/automount/distinfo new file mode 100644 index 0000000..76098a2 --- /dev/null +++ b/port/sysutils/automount/distinfo @@ -0,0 +1,3 @@ +MD5 (automount-1.0.tar.gz) = 050d33273d952436b492eaa9c13bcfb5 +SHA256 (automount-1.0.tar.gz) = dcbe2f11742c92ad9c2bc7d7c33b73efb9148cac46507edd505b4a4fa7198253 +SIZE (automount-1.0.tar.gz) = 2553 diff --git a/port/sysutils/automount/pkg-descr b/port/sysutils/automount/pkg-descr new file mode 100644 index 0000000..36c1f39 --- /dev/null +++ b/port/sysutils/automount/pkg-descr @@ -0,0 +1,6 @@ +automount is a devd(8) based automounter for FreeBSD. + +It supports most popular file systems: +NTFS/MSDOS/exFAT/EXT2/EXT3/EXT4/UFS + +WWW: https://github.com/vermaden/automount/