From dd8e2c7c581c3ff2ede01d020a9914b1f8236a49 Mon Sep 17 00:00:00 2001 From: "Slawomir Wojciech Wojtczak (vermaden)" Date: Tue, 28 Feb 2012 07:10:11 +0100 Subject: [PATCH] 1.2 --- automount | 1 - port/distfiles/automount-1.2.tar.gz | Bin 0 -> 3448 bytes port/distfiles/automount-1.2/automount | 233 ++++++++++++++++++ port/distfiles/automount-1.2/automount.conf | 7 + .../automount-1.2/automount.conf.sample | 5 + .../automount-1.2/automount_devd.conf | 14 ++ port/sysutils/automount/Makefile | 5 +- port/sysutils/automount/distinfo | 4 +- 8 files changed, 264 insertions(+), 5 deletions(-) create mode 100644 port/distfiles/automount-1.2.tar.gz create mode 100755 port/distfiles/automount-1.2/automount create mode 100644 port/distfiles/automount-1.2/automount.conf create mode 100644 port/distfiles/automount-1.2/automount.conf.sample create mode 100644 port/distfiles/automount-1.2/automount_devd.conf diff --git a/automount b/automount index b4c3ce9..1935056 100755 --- a/automount +++ b/automount @@ -96,7 +96,6 @@ REMOVEDIRS (set to NO by default) example: REMOVEDIRS="YES" - EOF exit 0 } diff --git a/port/distfiles/automount-1.2.tar.gz b/port/distfiles/automount-1.2.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..ac7e673745eac038d620a4571d7f58275b0f0021 GIT binary patch literal 3448 zcmV-;4Ttg{iwFRAZ%j`B1MOOEQ`<-q-p~FOy@D)|Mfe2>iL>5XV~e0FV{?|Agj((> zA<3YNZ29y;!Y2Oj_wY}i$ndyG!>7Je*$yO2vlOUPKYJI0s{pL@R zTCH}lzfbtAAMDqPpSe)Ie$Z$f?CW``=LQi=ucy{?Glt_AON}y=gVN zu2j~j6U=Ty@9H|HO?!(PwR(dL-+CWRypY}m|F%8XzUGVA{>6Gnn;9ot7~1xI5j z-N+4ZTxX}UhK8Z*cu^dBmr3jeQ?jNGC6Pkio$0oCMJR6eJ|4C>1$@olM+mY-N6`!UX}ELz-Bz8+w)> zEyxx=V!g#lNROMxxW3q9 zFf?eRZJ_&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0bwK7a zbYjIgZY%NyjY10Q2OP>@E?T%A!2QlpLq%3>un{q6*mSHr9QDNSMAp>|b2vEr($LZxN<#aqo%RLgbNm07vhmpZZ`2wq zzyCcrD1ZO?b!27#moJ_AgTl+zvMwm4lu}A5rIb=iDW#NBN-3q3Qc5YMlu}A5rIb=i aDW#NBN-3q3QcC$d%YOmxlflRUPyhfYn(IaY literal 0 HcmV?d00001 diff --git a/port/distfiles/automount-1.2/automount b/port/distfiles/automount-1.2/automount new file mode 100755 index 0000000..b4c3ce9 --- /dev/null +++ b/port/distfiles/automount-1.2/automount @@ -0,0 +1,233 @@ +#! /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=${PATH}:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin + +__usage() { + cat << EOF +AUTOMOUNT is a devd(8) based automounter for FreeBSD. + +It supports following file systems: +UFS/FAT/exFAT/NTFS/EXT2/EXT3/EXT4 + +It needs these ports to mount NTFS/exFAT/EXT4 respectively: + o sysutils/fusefs-ntfs + o sysutils/fusefs-exfat + o sysutils/fusefs-ext4fuse + +By default it mounts/unmounts all removable media but +it is possible to set some additional options at the +/usr/local/etc/automount.conf config file. + +Below is a list of possible options with description. + +MNTPREFIX (set to /media by default) + With this options You can alter the default root + for mounting the removable media, for example to + the /mnt directory. + + example: MNTPREFIX="/media" + +ENCODING (set to en_US.ISO8859-1 by default) + Only used with FAT32 mounts, specifies which + encoding to use at the mount. + + example: ENCODING="pl_PL.ISO8859-2" + +CODEPAGE (set to cp437 by default) + Only used with FAT32 mounts, specifies which + code page to use at the mount. + + example: CODEPAGE="cp852" + +USER (unset by default) + If set to some username, the mount command will + chown(1) the mount directory with the user and + its primary user group. If used with FM option + allows to launch the specified file manager after + a successful mount. + + example: USER="vermaden" + +FM (unset by default) + If set to file manager command, the mount will + launch the specified command after successful + mount. Works only if USER parameter is also set. + + example: FM="nautilus --browser --no-desktop" + +USERUMOUNT (set to NO by default) + When set to YES it will 'chmod +s /sbin/umount' + which would allow an USER to unmount the file + system with their selected file manager. + + example: USERUMOUNT="YES" + +ATIME (set to YES by default) + When set to NO it will mount filesystems with + noatime options when possible. + + example: ATIME="NO" + +REMOVEDIRS (set to NO by default) + When set to YES it will remove empty directories + under the used ${MNTPREFIX} after device detach. + + example: REMOVEDIRS="YES" + + +EOF + exit 0 +} + +[ "${1}" = "-h" -o "${1}" = "--help" -o ${#} -eq 0 -o ${#} -eq 1 ] && __usage + +[ -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) +: ${ATIME="YES"} # when NO mount with noatime +: ${REMOVEDIRS="NO"} # remove empty dirs under ${MNTPREFIX} +: ${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} + [ "${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)" + } + ;; + (*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)" + } + ;; + (*ext2*) + fsck.ext2 -y ${DEV} + mount -t ext2fs -o ${OPTS} ${DEV} ${MNT} && ADD=1 + __log "${DEV}:mount (ext2)" + ;; + (*ext3*) + fsck.ext3 -y ${DEV} + mount -t ext2fs -o ${OPTS} ${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 -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) + 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 + umount -f ${TARGET} & + 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.2/automount.conf b/port/distfiles/automount-1.2/automount.conf new file mode 100644 index 0000000..1ba5f6c --- /dev/null +++ b/port/distfiles/automount-1.2/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.2/automount.conf.sample b/port/distfiles/automount-1.2/automount.conf.sample new file mode 100644 index 0000000..a2d89cd --- /dev/null +++ b/port/distfiles/automount-1.2/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.2/automount_devd.conf b/port/distfiles/automount-1.2/automount_devd.conf new file mode 100644 index 0000000..2614c98 --- /dev/null +++ b/port/distfiles/automount-1.2/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 f56b5d1..7cac632 100644 --- a/port/sysutils/automount/Makefile +++ b/port/sysutils/automount/Makefile @@ -7,12 +7,13 @@ PORTNAME= automount PORTVERSION= 1.2 -LICENSE= BSD CATEGORIES= sysutils MASTER_SITES= https://github.com/vermaden/automount/ MAINTAINER= vermaden@interia.pl -COMMENT= devd(8) based automount sollution +COMMENT= FreeBSD's devd(8) based automount sollution + +LICENSE= BSD PLIST_FILES= sbin/automount etc/devd/automount_devd.conf etc/automount.conf.sample diff --git a/port/sysutils/automount/distinfo b/port/sysutils/automount/distinfo index e953709..8fc047c 100644 --- a/port/sysutils/automount/distinfo +++ b/port/sysutils/automount/distinfo @@ -1,2 +1,2 @@ -SHA256 (automount-1.0.tar.gz) = 0cf4d5f306d9ca104a3a977fe630a499048e7d226bf980f86afd9e0c111b1b5f -SIZE (automount-1.0.tar.gz) = 3447 +SHA256 (automount-1.2.tar.gz) = 5cbb556a861e781312705e1696a495ec688f8581e00e9563d111670699024d5a +SIZE (automount-1.2.tar.gz) = 3448