Compare commits
No commits in common. "master" and "1.4.1" have entirely different histories.
397
README
397
README
|
|
@ -1,287 +1,16 @@
|
||||||
|
automount is a devd(8) based automounter for FreeBSD.
|
||||||
___ /\ ___
|
|
||||||
__/ /_ / \ _\ \__
|
|
||||||
____ _____/_ __/__ / _/\ ___ ___ ____ ______ __\__ _\
|
|
||||||
/ \ / / // // \ /\_/ \ / / \ / \\ \ \ / \\ \
|
|
||||||
/ / // / // // / // \\ \ \ \\ \ \\ \ \\ \ \\ \_
|
|
||||||
\_____\\____/ \__\\____//__________\\__\__\__\\____/ \_____\\__\__\\___\
|
|
||||||
|
|
||||||
The 'automount' is a devd(8) based automounter for FreeBSD.
|
|
||||||
|
|
||||||
It supports most popular file systems:
|
It supports most popular file systems:
|
||||||
NTFS/MSDOS/exFAT/EXT2/EXT3/EXT4/UFS/XFS/HFS/MTP/ISO9660
|
NTFS/MSDOS/exFAT/EXT2/EXT3/EXT4/UFS
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
INSTALL:
|
||||||
|
|
||||||
|
|
||||||
I N S T A L L
|
|
||||||
===================
|
|
||||||
|
|
||||||
Use provided FreeBSD Ports/packages from here:
|
|
||||||
* sysutils/automount
|
|
||||||
|
|
||||||
.. or make manual unstallation:
|
|
||||||
|
|
||||||
|
# cp automount.sh /usr/local/sbin/automount.sh
|
||||||
# cp automount.conf /usr/local/etc/automount.conf
|
# cp automount.conf /usr/local/etc/automount.conf
|
||||||
# cp automount_devd.conf /usr/local/etc/devd/automount_devd.conf
|
# cp automount_devd.conf /usr/local/etc/devd/automount_devd.conf
|
||||||
# cp automount /usr/local/sbin/automount
|
|
||||||
# chmod +x /usr/local/sbin/automount
|
|
||||||
# /etc/rc.d/devd restart
|
# /etc/rc.d/devd restart
|
||||||
|
|
||||||
Now plugin Your USB thumb drive and have fun ;)
|
Now plugin Your USB thumb drive ;)
|
||||||
|
|
||||||
These ports/packages are needed for all filesystems:
|
|
||||||
|
|
||||||
* sysutils/e2fsprogs // EXT2/EXT3/EXT4 fsck(8)
|
|
||||||
* sysutils/xfsprogs // XFS fsck(8)
|
|
||||||
* sysutils/exfat-utils // exFAT exfatfsck(8)
|
|
||||||
* sysutils/fusefs-exfat // exFAT
|
|
||||||
* sysutils/fusefs-ntfs // NTFS (read write support)
|
|
||||||
* sysutils/fusefs-hfsfuse // HFS
|
|
||||||
* sysutils/fusefs-lkl // XFS/EXT2/EXT3/EXT4
|
|
||||||
* sysutils/fusefs-simple-mtpfs // MTP
|
|
||||||
|
|
||||||
All of the above are available as pkg(8) packages.
|
|
||||||
|
|
||||||
Shortcut:
|
|
||||||
|
|
||||||
# pkg install -y \
|
|
||||||
sysutils/e2fsprogs \
|
|
||||||
sysutils/xfsprogs \
|
|
||||||
sysutils/exfat-utils \
|
|
||||||
sysutils/fusefs-exfat \
|
|
||||||
sysutils/fusefs-ntfs \
|
|
||||||
sysutils/fusefs-hfsfuse \
|
|
||||||
sysutils/fusefs-lkl \
|
|
||||||
sysutils/fusefs-simple-mtpfs
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
C H A N G E L O G
|
|
||||||
=========================
|
|
||||||
|
|
||||||
VERSION 1.7.9 (CURRENT)
|
|
||||||
|
|
||||||
Fix XORG detection.
|
|
||||||
Implement proposed BLACKLIST_REGEX option.
|
|
||||||
Use 'sysutils/fusefs-lkl' for all ext2/ext3/ext4 mounts.
|
|
||||||
Fix exFAT detection.
|
|
||||||
Fix small problem with checking the mount state.
|
|
||||||
Implement better old directory cleanup.
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
VERSION 1.7.8
|
|
||||||
|
|
||||||
Fix harmless gpart(8) rant about ugen(4) devices.
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
VERSION 1.7.7
|
|
||||||
|
|
||||||
Add option to ignore system partitions like EFI or MSR.
|
|
||||||
Fix removal of dirs from unmounted filesystems.
|
|
||||||
Fix mount permissions for FAT filesystems.
|
|
||||||
Add spaces and comments in the code.
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
VERSION 1.7.6
|
|
||||||
|
|
||||||
Added UZIP images support.
|
|
||||||
Added another try to mount device in read only mode.
|
|
||||||
Added optional ada(4) disks support.
|
|
||||||
Added optional md(4) devices support.
|
|
||||||
Added automatic kernel modules loading.
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
VERSION 1.7.5
|
|
||||||
|
|
||||||
Add REMOVEDIRS option as default.
|
|
||||||
Add NICENAMES option to use labels instead of device names.
|
|
||||||
Use procstat(1) for faster DISPLAY environemnt searching.
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
VERSION 1.7.4
|
|
||||||
|
|
||||||
Add new logo.
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
VERSION 1.7.3
|
|
||||||
|
|
||||||
Use 755 permissions for FAT mounts.
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
VERSION 1.7.2
|
|
||||||
|
|
||||||
Phase out support for sysutils/fusefs-ext4fuse port.
|
|
||||||
Fix UMASK for exFAT filesystems.
|
|
||||||
Fix ISO9660 mount options.
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
VERSION 1.7.1
|
|
||||||
|
|
||||||
Fix exFAT mount rights.
|
|
||||||
Use USER option in config file.
|
|
||||||
Make MTP detection and mount better.
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
VERSION 1.7.0
|
|
||||||
|
|
||||||
The automount has now a new co-author - Rozhuk Ivan.
|
|
||||||
New options available in automount.conf config file.
|
|
||||||
Filesystem detection/mounting reworked totally with file(1)/dd(1)/fstyp(8) as backends.
|
|
||||||
Notifications are now possible with libnotify.
|
|
||||||
Automatic detection of DISPLAY variable.
|
|
||||||
New automatic wait for device appearance.
|
|
||||||
New detection if device is a block device.
|
|
||||||
Introduction of CD-ROM support.
|
|
||||||
Automatic detection of File Manager with exo-open(1).
|
|
||||||
Option REMOVEDIRS is deprecated now.
|
|
||||||
Handle '-o large' option for FAT under FreeBSD 11.x and 12.x versions.
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
VERSION 1.6.1
|
|
||||||
|
|
||||||
Fix MBR/msdosfs partition unmount issue.
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
VERSION 1.6.0
|
|
||||||
|
|
||||||
Fix long boot with devd(8) because of ugen(4) devices.
|
|
||||||
Add fsck.exfat to the exFAT filesystem.
|
|
||||||
Set fsck.ext2 instead of e2fsck to the ext2 filesystem.
|
|
||||||
Set fsck.ext3 instead of e2fsck to the ext3 filesystem.
|
|
||||||
Set fsck.ext4 instead of e2fsck to the ext4 filesystem.
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
VERSION 1.5.9
|
|
||||||
|
|
||||||
Decrease DELAY for sleep from '1' to '0.1' for faster mounting.
|
|
||||||
Remove __random_wait() at 'attach'.
|
|
||||||
Implement MTP mounting.
|
|
||||||
Added XFS and HFS support.
|
|
||||||
Various fixes and cleanups.
|
|
||||||
Remove '-o large' option for FAT (not supported on FreeBSD 12).
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
VERSION 1.5.8
|
|
||||||
|
|
||||||
Omit GVFS filesystem in the mount(8) listing.
|
|
||||||
Improve exFAT mount options.
|
|
||||||
Add mount_msdosfs(8) fallback fix.
|
|
||||||
Set caja as file manager in example config.
|
|
||||||
Add version argument.
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
VERSION 1.5.7
|
|
||||||
|
|
||||||
Fix FAT32 mount.
|
|
||||||
Add extended options for EXFAT mounts.
|
|
||||||
Add -version option.
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
VERSION 1.5.6
|
|
||||||
|
|
||||||
Implement --version option.
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
VERSION 1.5.5
|
|
||||||
|
|
||||||
Rework NTFS/MSDOS/FAT detection.
|
|
||||||
Check for NTFS before FAT.
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
VERSION 1.5.4
|
|
||||||
|
|
||||||
Added notification via notify-send/libnotify and wall(1). Minor bug fix.
|
|
||||||
Change 'boot sector' detection.
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
VERSION 1.5.3
|
|
||||||
|
|
||||||
Fix small harmless bug - variable WAIT without default value.
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
VERSION 1.5.2
|
|
||||||
|
|
||||||
Introduce smarter fstype() function to better determine filesystem.
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
VERSION 1.5.1
|
|
||||||
|
|
||||||
Add -k flag to file(1) command.
|
|
||||||
Set new --version and date(1).
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
VERSION 1.5.0
|
|
||||||
|
|
||||||
Add new NTFS options.
|
|
||||||
Add nested NTFS mount attempt.
|
|
||||||
Fix devd(8) config.
|
|
||||||
Improve log messages.
|
|
||||||
Use random wait only on ATTACH action, not needed on DETACH action.
|
|
||||||
Implement random wait to eliminate race.
|
|
||||||
Implement BOOTDELAY option to wait for boot process to complete.
|
|
||||||
Fix devd(8) config (LARKIND) to match all needed devices and their partitions.
|
|
||||||
Fix typo in NTFS error message.
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
VERSION 1.4.3
|
|
||||||
|
|
||||||
Only style(9) changes.
|
|
||||||
Force longnames option for msdosfs.
|
|
||||||
Remove -u option for debug.
|
|
||||||
Fix a bug when ATIME is enabled.
|
|
||||||
Add -o remove_hiberfile to NTFS-3G mount options.
|
|
||||||
Fix typo at /var/log/automount.log error message.
|
|
||||||
Use /sbin/e2fsck from FreeBSD base system.
|
|
||||||
Fix typo at /var/log/automount.log error message.
|
|
||||||
Force longnames option for msdosfs.
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
VERSION 1.4.2
|
|
||||||
|
|
||||||
Implement active sleep/wait for devices that could not appear.
|
|
||||||
Add more useful information to /var/log/automount.log file.
|
|
||||||
Implement BLACKLIST option to ignore problematic devices.
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
VERSION 1.4.1
|
|
||||||
|
|
||||||
Improved checking for already mounted devices.
|
|
||||||
More readable log format.
|
|
||||||
Added logging of fsck(8) output.
|
|
||||||
Added adding setuid also to /sbin/mount* when USERUMOUNT set to YES.
|
|
||||||
Added error logging of failed mounts.
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
VERSION 1.4.0
|
|
||||||
|
|
||||||
Wait for smartphone to attach device, rewrite all &&-|| into if-then-else-fi syntax.
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -308,19 +37,18 @@ Added the --help page.
|
||||||
Removed some small bugs.
|
Removed some small bugs.
|
||||||
Added more options to configure features.
|
Added more options to configure features.
|
||||||
|
|
||||||
% /usr/local/sbin/automount --help
|
|
||||||
|
|
||||||
|
% automount --help
|
||||||
AUTOMOUNT is a devd(8) based automounter for FreeBSD.
|
AUTOMOUNT is a devd(8) based automounter for FreeBSD.
|
||||||
|
|
||||||
It supports following file systems:
|
It supports following file systems:
|
||||||
UFS/FAT/exFAT/NTFS/EXT2/EXT3/EXT4/MTP/HFS/ISO9660
|
UFS/FAT/exFAT/NTFS/EXT2/EXT3/EXT4
|
||||||
|
|
||||||
Add these to mount NTFS/exFAT/EXT4/HFS/XFS/MTP respectively:
|
It needs these ports to mount NTFS/exFAT/EXT4 respectively:
|
||||||
o sysutils/fusefs-ntfs
|
o sysutils/fusefs-ntfs
|
||||||
o sysutils/fusefs-exfat
|
o sysutils/fusefs-exfat
|
||||||
o sysutils/fusefs-ext4fuse
|
o sysutils/fusefs-ext4fuse
|
||||||
o sysutils/fusefs-hfsfuse
|
|
||||||
o sysutils/fusefs-lkl
|
|
||||||
o sysutils/fusefs-simple-mtpfs
|
|
||||||
|
|
||||||
By default it mounts/unmounts all removable media but
|
By default it mounts/unmounts all removable media but
|
||||||
it is possible to set some additional options at the
|
it is possible to set some additional options at the
|
||||||
|
|
@ -328,86 +56,26 @@ it is possible to set some additional options at the
|
||||||
|
|
||||||
Below is a list of possible options with description.
|
Below is a list of possible options with description.
|
||||||
|
|
||||||
MNT_PREFIX (set to /media by default)
|
MNTPREFIX (set to /media by default)
|
||||||
With this options You can alter the default root
|
With this options You can alter the default root
|
||||||
for mounting the removable media, for example to
|
for mounting the removable media, for example to
|
||||||
the /mnt directory.
|
the /mnt directory.
|
||||||
|
|
||||||
example: MNT_PREFIX='/media'
|
example: MNTPREFIX="/media"
|
||||||
|
|
||||||
MNT_GROUP (wheel by default)
|
ENCODING (set to en_US.ISO8859-1 by default)
|
||||||
If set to some group name, the mount command will
|
|
||||||
chown(1) the mount directory with the group.
|
|
||||||
|
|
||||||
example: group='operator'
|
|
||||||
|
|
||||||
MNT_MODE (set to 775 by default)
|
|
||||||
Value for chmod on mount point.
|
|
||||||
|
|
||||||
FAT_ENCODING (set to en_US.UTF-8 by default)
|
|
||||||
Only used with FAT32 mounts, specifies which
|
Only used with FAT32 mounts, specifies which
|
||||||
encoding to use at the mount.
|
encoding to use at the mount.
|
||||||
|
|
||||||
example: FAT_ENCODING='en_US.ISO8859-1'
|
example: ENCODING="pl_PL.ISO8859-2"
|
||||||
|
|
||||||
FAT_CODEPAGE (set to CP866 by default)
|
CODEPAGE (set to cp437 by default)
|
||||||
Only used with FAT32 mounts, specifies which
|
Only used with FAT32 mounts, specifies which
|
||||||
code page to use at the mount.
|
code page to use at the mount.
|
||||||
|
|
||||||
example: FAT_CODEPAGE='cp437'
|
example: CODEPAGE="cp852"
|
||||||
|
|
||||||
ISO9660_CODEPAGE (set to UTF-8 by default)
|
USER (unset by default)
|
||||||
Only used with cd9660 mounts, specifies which
|
|
||||||
code page to use at the mount.
|
|
||||||
|
|
||||||
ATIME (set to NO by default)
|
|
||||||
When set to NO it will mount filesystems with
|
|
||||||
noatime option when possible.
|
|
||||||
|
|
||||||
example: ATIME='YES'
|
|
||||||
|
|
||||||
RETRY_COUNT (set to 3 by default)
|
|
||||||
How many times try to get file system type or try to mount.
|
|
||||||
|
|
||||||
example: RETRY_COUNT='1'
|
|
||||||
|
|
||||||
RETRY_DELAY (set to 1 second by default)
|
|
||||||
Delay beetwin retry attempt.
|
|
||||||
|
|
||||||
example: RETRY_DELAY='2.5'
|
|
||||||
|
|
||||||
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'
|
|
||||||
|
|
||||||
NOTIFY (set to NO by default)
|
|
||||||
Use 'notify-send' and 'libnotify' to show notifications
|
|
||||||
of mounting and unmounting devices on the desktop.
|
|
||||||
|
|
||||||
example: NOTIFY='YES'
|
|
||||||
|
|
||||||
WALL (set to NO by default)
|
|
||||||
Use wall(1) to show notifications of mounting and
|
|
||||||
unmounting devices on terminals of logged in users.
|
|
||||||
|
|
||||||
example: WALL='YES'
|
|
||||||
|
|
||||||
FM ('exo-open --launch FileManager' 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'
|
|
||||||
|
|
||||||
BLACKLIST (unset by default)
|
|
||||||
The automount will ignore devices defined here.
|
|
||||||
|
|
||||||
example: BLACKLIST='da0 da3s1a'
|
|
||||||
|
|
||||||
USER (root by default)
|
|
||||||
If set to some username, the mount command will
|
If set to some username, the mount command will
|
||||||
chown(1) the mount directory with the user and
|
chown(1) the mount directory with the user and
|
||||||
its primary user group. If used with FM option
|
its primary user group. If used with FM option
|
||||||
|
|
@ -416,6 +84,32 @@ USER (root by default)
|
||||||
|
|
||||||
example: USER="vermaden"
|
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 after device detach.
|
||||||
|
|
||||||
|
example: REMOVEDIRS="YES"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
|
|
||||||
VERSION 1.2
|
VERSION 1.2
|
||||||
|
|
@ -489,11 +183,6 @@ The only additional configuration it requires is to add these lines as
|
||||||
Remember to restart /etc/rc.d/devd daemon after adding
|
Remember to restart /etc/rc.d/devd daemon after adding
|
||||||
/usr/local/etc/devd/automount_devd.conf file.
|
/usr/local/etc/devd/automount_devd.conf file.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
Have Fun ;)
|
Have Fun ;)
|
||||||
vermaden
|
vermaden
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
844
automount
844
automount
|
|
@ -1,7 +1,6 @@
|
||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
|
|
||||||
# Copyright (c) 2012-2024 Slawomir Wojciech Wojtczak <vermaden@interia.pl>
|
# Copyright (c) 2012 Slawomir Wojciech Wojtczak (vermaden)
|
||||||
# Copyright (c) 2019 Rozhuk Ivan <rozhuk.im@gmail.com>
|
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
|
@ -30,14 +29,12 @@ __usage() {
|
||||||
AUTOMOUNT is a devd(8) based automounter for FreeBSD.
|
AUTOMOUNT is a devd(8) based automounter for FreeBSD.
|
||||||
|
|
||||||
It supports following file systems:
|
It supports following file systems:
|
||||||
UFS/FAT/exFAT/NTFS/EXT2/EXT3/EXT4/MTP/HFS/ISO9660
|
UFS/FAT/exFAT/NTFS/EXT2/EXT3/EXT4
|
||||||
|
|
||||||
Add these to mount NTFS/exFAT/EXT4/HFS/XFS/MTP respectively:
|
It needs these ports to mount NTFS/exFAT/EXT4 respectively:
|
||||||
o sysutils/fusefs-ntfs
|
o sysutils/fusefs-ntfs
|
||||||
o sysutils/fusefs-exfat
|
o sysutils/fusefs-exfat
|
||||||
o sysutils/fusefs-hfsfuse
|
o sysutils/fusefs-ext4fuse
|
||||||
o sysutils/fusefs-lkl
|
|
||||||
o sysutils/fusefs-simple-mtpfs
|
|
||||||
|
|
||||||
By default it mounts/unmounts all removable media but
|
By default it mounts/unmounts all removable media but
|
||||||
it is possible to set some additional options at the
|
it is possible to set some additional options at the
|
||||||
|
|
@ -45,95 +42,26 @@ it is possible to set some additional options at the
|
||||||
|
|
||||||
Below is a list of possible options with description.
|
Below is a list of possible options with description.
|
||||||
|
|
||||||
MNT_PREFIX (set to /media by default)
|
MNTPREFIX (set to /media by default)
|
||||||
With this options You can alter the default root
|
With this options You can alter the default root
|
||||||
for mounting the removable media, for example to
|
for mounting the removable media, for example to
|
||||||
the /mnt directory.
|
the /mnt directory.
|
||||||
|
|
||||||
example: MNT_PREFIX='/media'
|
example: MNTPREFIX="/media"
|
||||||
|
|
||||||
MNT_GROUP (wheel by default)
|
ENCODING (set to en_US.ISO8859-1 by default)
|
||||||
If set to some group name, the mount command will
|
|
||||||
chown(1) the mount directory with the group.
|
|
||||||
|
|
||||||
example: group='operator'
|
|
||||||
|
|
||||||
MNT_MODE (set to 775 by default)
|
|
||||||
Value for chmod on mount point.
|
|
||||||
|
|
||||||
FAT_ENCODING (set to en_US.UTF-8 by default)
|
|
||||||
Only used with FAT32 mounts, specifies which
|
Only used with FAT32 mounts, specifies which
|
||||||
encoding to use at the mount.
|
encoding to use at the mount.
|
||||||
|
|
||||||
example: FAT_ENCODING='en_US.ISO8859-1'
|
example: ENCODING="pl_PL.ISO8859-2"
|
||||||
|
|
||||||
FAT_CODEPAGE (set to CP866 by default)
|
CODEPAGE (set to cp437 by default)
|
||||||
Only used with FAT32 mounts, specifies which
|
Only used with FAT32 mounts, specifies which
|
||||||
code page to use at the mount.
|
code page to use at the mount.
|
||||||
|
|
||||||
example: FAT_CODEPAGE='cp437'
|
example: CODEPAGE="cp852"
|
||||||
|
|
||||||
ISO9660_CODEPAGE (set to UTF-8 by default)
|
USER (unset by default)
|
||||||
Only used with cd9660 mounts, specifies which
|
|
||||||
code page to use at the mount.
|
|
||||||
|
|
||||||
ATIME (set to NO by default)
|
|
||||||
When set to NO it will mount filesystems with
|
|
||||||
noatime option when possible.
|
|
||||||
|
|
||||||
example: ATIME='YES'
|
|
||||||
|
|
||||||
RETRY_COUNT (set to 3 by default)
|
|
||||||
How many times try to get file system type or try to mount.
|
|
||||||
|
|
||||||
example: RETRY_COUNT='1'
|
|
||||||
|
|
||||||
RETRY_DELAY (set to 1 second by default)
|
|
||||||
Delay beetwin retry attempt.
|
|
||||||
|
|
||||||
example: RETRY_DELAY='2.5'
|
|
||||||
|
|
||||||
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'
|
|
||||||
|
|
||||||
NOTIFY (set to NO by default)
|
|
||||||
Use 'notify-send' and 'libnotify' to show notifications
|
|
||||||
of mounting and unmounting devices on the desktop.
|
|
||||||
|
|
||||||
example: NOTIFY='YES'
|
|
||||||
|
|
||||||
WALL (set to NO by default)
|
|
||||||
Use wall(1) to show notifications of mounting and
|
|
||||||
unmounting devices on terminals of logged in users.
|
|
||||||
|
|
||||||
example: WALL='YES'
|
|
||||||
|
|
||||||
FM ('exo-open --launch FileManager' 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'
|
|
||||||
|
|
||||||
BLACKLIST (unset by default)
|
|
||||||
The automount will ignore devices defined here.
|
|
||||||
|
|
||||||
example: BLACKLIST='da0 da3s1a'
|
|
||||||
|
|
||||||
|
|
||||||
BLACKLIST_REGEX (unset by default)
|
|
||||||
The boolean flag option complements the above BLACKLIST option
|
|
||||||
if one wants regex match instead of exact match for ignoring devices.
|
|
||||||
Below will ignore all partitions ada0p1/ada0p2/... of ada0 device.
|
|
||||||
|
|
||||||
example: BLACKLIST='ada0'
|
|
||||||
BLACKLIST_REGEX=true
|
|
||||||
|
|
||||||
USER (root by default)
|
|
||||||
If set to some username, the mount command will
|
If set to some username, the mount command will
|
||||||
chown(1) the mount directory with the user and
|
chown(1) the mount directory with the user and
|
||||||
its primary user group. If used with FM option
|
its primary user group. If used with FM option
|
||||||
|
|
@ -142,638 +70,294 @@ USER (root by default)
|
||||||
|
|
||||||
example: USER="vermaden"
|
example: USER="vermaden"
|
||||||
|
|
||||||
REMOVEDIRS (set to YES by default)
|
FM (unset by default)
|
||||||
If set to YES the automount(8) will remove /media dir after unmount.
|
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: REMOVEDIRS=NO
|
example: FM="nautilus --browser --no-desktop"
|
||||||
|
|
||||||
NICENAMES (set to NO by default)
|
USERUMOUNT (set to NO by default)
|
||||||
If set to YES the device/filesystem label will be used for /media dir name.
|
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: NICENAMES=YES
|
example: USERUMOUNT="YES"
|
||||||
|
|
||||||
IGNORE_SYS_PARTS (set to NO by default)
|
ATIME (set to YES by default)
|
||||||
If set to YES automount(8) will ignore system partitions like EFI or MSR.
|
When set to NO it will mount filesystems with
|
||||||
|
noatime options when possible.
|
||||||
|
|
||||||
example: IGNORE_SYS_PARTS=YES
|
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
|
EOF
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# display version if needed
|
if [ "${1}" = "-h" -o "${1}" = "--help" -o ${#} -eq 0 -o ${#} -eq 1 ]
|
||||||
if [ "${1}" = '--version' -o \
|
|
||||||
"${1}" = '-version' -o \
|
|
||||||
"${1}" = 'version' -o \
|
|
||||||
"${1}" = '-v' ]
|
|
||||||
then
|
|
||||||
echo
|
|
||||||
echo " ___ /\ ___ "
|
|
||||||
echo " __/ /_ / \ _\ \__ "
|
|
||||||
echo " ____ _____/_ __/__ / _/\ ___ ___ ____ ______ __\__ _\ "
|
|
||||||
echo " / \ / / // // \ /\_/ \ / / \ / \\\ \ \ / \\\ \ "
|
|
||||||
echo " / / // / // // / // \\\ \ \ \\\ \ \\\ \ \\\ \ \\\ \_ "
|
|
||||||
echo " \_____\\\____/ \__\\\____//__________\\\__\__\__\\\____/ \_____\\\__\__\\\___\ "
|
|
||||||
echo
|
|
||||||
echo "automount 1.8.0 2024/03/05"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# display help if needed
|
|
||||||
if [ "${1}" = "-h" -o \
|
|
||||||
"${1}" = "--h" -o \
|
|
||||||
"${1}" = "-help" -o \
|
|
||||||
"${1}" = "--help" -o \
|
|
||||||
"${#}" -eq "0" -o \
|
|
||||||
"${#}" -eq "1" ]
|
|
||||||
then
|
then
|
||||||
__usage
|
__usage
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# read configuration file
|
if [ -f /usr/local/etc/automount.conf ]
|
||||||
if [ -f /usr/local/etc/automount.conf ] ; then
|
then
|
||||||
. /usr/local/etc/automount.conf
|
. /usr/local/etc/automount.conf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# default values for global variables
|
: ${MNTPREFIX="/media"} # mount prefix
|
||||||
: ${MNT_PREFIX='/media'} # mount prefix
|
: ${LOG="/var/log/automount.log"} # log file
|
||||||
: ${MNT_GROUP='wheel'} # use WHEEL group for popup
|
|
||||||
: ${MNT_MODE='775'} # mount point mode
|
|
||||||
: ${FAT_ENCODING='en_US.UTF-8'} # US/Canada
|
|
||||||
: ${FAT_CODEPAGE='cp437'} # US/Canada
|
|
||||||
: ${ISO9660_CODEPAGE='UTF-8'} # UTF-8
|
|
||||||
: ${ATIME='NO'} # when NO mount with noatime
|
|
||||||
: ${RETRY_COUNT='5'} # retry count
|
|
||||||
: ${RETRY_DELAY='2'} # retry delay time
|
|
||||||
: ${USERUMOUNT='NO'} # when YES add suid bit to umount(8)
|
|
||||||
: ${NOTIFY='NO'} # use notify-send(1) (devel/libnotify)
|
|
||||||
: ${WALL='NO'} # use wall(1)
|
|
||||||
: ${FM='exo-open --launch FileManager'} # which file manager to use
|
|
||||||
: ${LOG_FILE='/var/log/automount.log'} # log file
|
|
||||||
: ${LOG_DATEFMT='%Y-%m-%d %H:%M:%S'} # 2012-02-20 07:49:09
|
|
||||||
: ${STATE="/var/run/automount.state"} # current state file
|
: ${STATE="/var/run/automount.state"} # current state file
|
||||||
: ${USER="root"} # which user to use for popup
|
: ${ENCODING="en_US.ISO8859-1"} # US/Canada
|
||||||
: ${REMOVEDIRS='YES'} # remove /media dir after unmount
|
: ${CODEPAGE="cp437"} # US/Canada
|
||||||
: ${NICENAMES='NO'} # use device label for /media dir name
|
: ${DATEFMT="%Y-%m-%d %H:%M:%S"} # 2012-02-20 07:49:09
|
||||||
: ${IGNORE_SYS_PARTS='NO'} # ignore system partitions like EFI or MSR
|
: ${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
|
||||||
|
|
||||||
# init of main variables
|
if [ "${USERUMOUNT}" = YES ]
|
||||||
DEV="/dev/${1}"
|
|
||||||
UID=$( id -u ${USER} )
|
|
||||||
GID=$( pw group show -n ${MNT_GROUP} | awk -F':' '{print $3}' )
|
|
||||||
if [ ${?} -ne 0 ]
|
|
||||||
then
|
then
|
||||||
__log "${MNT_GROUP}: invalid group"
|
chmod u+s /sbin/umount 1> /dev/null 2> /dev/null # WHEEL group member
|
||||||
exit 1
|
chmod u+s /sbin/mount* 1> /dev/null 2> /dev/null # WHEEL group member
|
||||||
|
sysctl vfs.usermount=1 1> /dev/null 2> /dev/null # allow USER to mount
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# process ${USERUMOUNT} option
|
__create_mount_point() { # 1=DEV
|
||||||
case ${USERUMOUNT} in
|
mkdir -p ${MNT}
|
||||||
([Yy][Ee][Ss])
|
if [ "${USER}" != 0 ]
|
||||||
chmod u+s /sbin/umount 1> /dev/null 2>&1 # WHEEL group member
|
then
|
||||||
chmod u+s /sbin/mount* 1> /dev/null 2>&1 # WHEEL group member
|
chown ${USER}:$( id -g -n ${USER} ) ${MNT}
|
||||||
sysctl -q vfs.usermount=1 1> /dev/null 2>&1 # allow user to mount
|
fi
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# read only filesystem types for __guess_fs_type() function
|
|
||||||
readonly FS_TYPE_UNKNOWN=0
|
|
||||||
readonly FS_TYPE_ISO9660=1
|
|
||||||
readonly FS_TYPE_UFS=8
|
|
||||||
readonly FS_TYPE_EXT2=9
|
|
||||||
readonly FS_TYPE_EXT3=10
|
|
||||||
readonly FS_TYPE_EXT4=11
|
|
||||||
readonly FS_TYPE_XFS=12
|
|
||||||
readonly FS_TYPE_HFS=13
|
|
||||||
readonly FS_TYPE_FAT=32
|
|
||||||
readonly FS_TYPE_EXFAT=33
|
|
||||||
readonly FS_TYPE_NTFS=34
|
|
||||||
readonly FS_TYPE_MTP=128
|
|
||||||
|
|
||||||
# FUNCTION: guess filesystem type from device
|
|
||||||
__guess_fs_type() { # 1=DEV
|
|
||||||
# first time guess with file(1) tool
|
|
||||||
unset FS_TYPE
|
|
||||||
local FS_TYPE=$( file -r -b -L -s ${1} 2> /dev/null | sed -E 's/label:\ \".*\"//g' )
|
|
||||||
case ${FS_TYPE} in
|
|
||||||
(*ISO\ 9660*) return ${FS_TYPE_ISO9660} ;;
|
|
||||||
(*Unix\ Fast\ File*) return ${FS_TYPE_UFS} ;;
|
|
||||||
(*ext2*) return ${FS_TYPE_EXT2} ;;
|
|
||||||
(*ext3*) return ${FS_TYPE_EXT3} ;;
|
|
||||||
(*ext4*) return ${FS_TYPE_EXT4} ;;
|
|
||||||
(*SGI\ XFS*) return ${FS_TYPE_XFS} ;;
|
|
||||||
(*Macintosh\ HFS*) return ${FS_TYPE_HFS} ;;
|
|
||||||
esac
|
|
||||||
# second time guess with file(1) tool with -k option
|
|
||||||
# (do not stop at the first match and keep going)
|
|
||||||
unset FS_TYPE
|
|
||||||
local FS_TYPE=$( file -k -r -b -L -s ${1} 2> /dev/null | tr '\n' ' ' | sed -E 's/label:\ \".*\"//g' )
|
|
||||||
case ${FS_TYPE} in
|
|
||||||
(*Unix\ Fast\ File*) return ${FS_TYPE_UFS} ;;
|
|
||||||
(*NTFS*) return ${FS_TYPE_NTFS} ;;
|
|
||||||
(*ExFAT*) return ${FS_TYPE_EXFAT} ;;
|
|
||||||
(*\ FAT\ *|*MSDOS*) return ${FS_TYPE_FAT} ;;
|
|
||||||
esac
|
|
||||||
# try with fstyp(8) last (exFAT on UFS issue)
|
|
||||||
unset FS_TYPE
|
|
||||||
local FS_TYPE=$( fstyp ${1} 2> /dev/null )
|
|
||||||
case ${FS_TYPE} in
|
|
||||||
(cd9660) return ${FS_TYPE_ISO9660} ;;
|
|
||||||
(ufs) return ${FS_TYPE_UFS} ;;
|
|
||||||
(ext2fs) return ${FS_TYPE_EXT2} ;;
|
|
||||||
(msdosfs) return ${FS_TYPE_FAT} ;;
|
|
||||||
(exfat) return ${FS_TYPE_EXFAT} ;;
|
|
||||||
(ntfs) return ${FS_TYPE_NTFS} ;;
|
|
||||||
esac
|
|
||||||
# magic detection code with dd(8)
|
|
||||||
unset FS_TYPE
|
|
||||||
local FS_TYPE=$( dd if="${1}" conv=sync count=1 bs=1k 2> /dev/null | strings | head -1 )
|
|
||||||
case ${FS_TYPE} in
|
|
||||||
(*EXFAT*) return ${FS_TYPE_EXFAT} ;;
|
|
||||||
esac
|
|
||||||
return ${FS_TYPE_UNKNOWN}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# FUNCTION: add state to the ${STATE} file
|
|
||||||
__state_add() { # 1=DEV 2=PROVIDER 3=MNT
|
__state_add() { # 1=DEV 2=PROVIDER 3=MNT
|
||||||
if [ -f ${STATE} ]
|
|
||||||
then
|
|
||||||
if grep -E "${3}$" ${STATE} 1> /dev/null 2> /dev/null
|
if grep -E "${3}$" ${STATE} 1> /dev/null 2> /dev/null
|
||||||
then
|
then
|
||||||
__log "${1}: duplicated '${STATE}'"
|
__log "${1}: duplicated '${STATE}'"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
echo "${1} ${2} ${3}" >> ${STATE}
|
echo "${1} ${2} ${3}" >> ${STATE}
|
||||||
if [ "${NOTIFY}" = YES ]
|
|
||||||
then
|
|
||||||
__show_message "Device '${1}' mounted on '${3}' directory."
|
|
||||||
fi
|
|
||||||
if [ "${WALL}" = YES ]
|
|
||||||
then
|
|
||||||
echo "automount: Device '${1}' mounted on '${3}' directory." | wall
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# FUNCTION: remove state from the ${STATE} file
|
|
||||||
__state_remove() { # 1=MNT
|
__state_remove() { # 1=MNT
|
||||||
if [ -f ${STATE} ]
|
BSMNT=$( echo ${1} | sed 's/\//\\\//g' ) # backslash the slashes ;)
|
||||||
then
|
|
||||||
# backslash the slashes ;)
|
|
||||||
BSMNT=$( echo ${1} | sed 's/\//\\\//g' )
|
|
||||||
sed -i '' "/${BSMNT}\$/d" ${STATE}
|
sed -i '' "/${BSMNT}\$/d" ${STATE}
|
||||||
if [ "${NOTIFY}" = YES ]
|
|
||||||
then
|
|
||||||
__show_message "Device '${1}' unmounted from '${3}' directory."
|
|
||||||
fi
|
|
||||||
if [ "${WALL}" = YES ]
|
|
||||||
then
|
|
||||||
echo "automount: Device '${1}' unmounted from '${3}' directory." | wall
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# FUNCTION: add message to the ${LOG_FILE} file
|
|
||||||
__log() { # @=MESSAGE
|
|
||||||
echo $( date +"${LOG_DATEFMT}" ) "${@}" >> "${LOG_FILE}"
|
|
||||||
}
|
|
||||||
|
|
||||||
# FUNCTION: remove temp mount dir from ${MNT_PREFIX} path (like /media/da0 dir)
|
|
||||||
__remove_dir() { # 1=TARGET
|
__remove_dir() { # 1=TARGET
|
||||||
if [ "${REMOVEDIRS}" = YES ]
|
if [ "${REMOVEDIRS}" = YES ]
|
||||||
then
|
then
|
||||||
if [ -d "${1}" ]
|
find "${1}" -type d -empty -maxdepth 1 -exec rm -r {} '+' 2> /dev/null
|
||||||
then
|
|
||||||
sleep 1
|
|
||||||
# find "${1}" -type d -empty -maxdepth 1 -exec rm -r {} '+' 2> /dev/null
|
|
||||||
find "${MNT_PREFIX}" -depth 1 -empty -prune -delete 2> /dev/null
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# FUNCTION: display wall(1) and/or notify-send(1) message
|
__log() { # @=MESSAGE
|
||||||
__show_message() { # 1=MESSAGE
|
echo $( date +"${DATEFMT}" ) "${@}" >> ${LOG}
|
||||||
case ${WALL} in
|
|
||||||
([Yy][Ee][Ss])
|
|
||||||
echo "automount: ${1}" | wall
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
case ${NOTIFY} in
|
|
||||||
([Yy][Ee][Ss])
|
|
||||||
local __DISPLAY_IDS=$( ps aew | sed -n 's|.*DISPLAY=\([-_a-zA-Z0-9:.]*\).*|\1|p' | sort -u | tr '\n' ' ' )
|
|
||||||
for __DISPLAY_ID in ${__DISPLAY_IDS}
|
|
||||||
do
|
|
||||||
local __USER=$( ps aewj | grep "DISPLAY=${__DISPLAY_ID}" | awk '{print $1;}' | sort -u | tr -cd '[:print:]' )
|
|
||||||
if [ -z "${__USER}" ]
|
|
||||||
then
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
su -l "${__USER}" -c "env DISPLAY=${__DISPLAY_ID} notify-send automount '${1}' &" 1> /dev/null 2>&1
|
|
||||||
done
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# FUNCTION: check if device or mountpoint not already mounted
|
__check_already_mounted() { # 1=(-d|-m) 2=(DEV|MNT)
|
||||||
__check_already_mounted() { # 1=DEV 2=MNT
|
local MOUNT="$( mount )"
|
||||||
local MOUNT=$( mount )
|
case ${1} in
|
||||||
if echo "${MOUNT}" | grep -q "^${1} on "
|
(-d)
|
||||||
|
if echo "${MOUNT}" | grep -q "^${2} on "
|
||||||
then
|
then
|
||||||
local MOUNT_POINT=$( echo "${MOUNT}" | grep "^${1} on " | cut -d ' ' -f 3-255 | cut -d '(' -f 1 | sed s/.$// )
|
local MOUNT="$( echo "${MOUNT}" | grep "^${2} on " | cut -d ' ' -f 3-255 | cut -d '(' -f 1 | sed s/.$// )"
|
||||||
__log "${DEV}: already mounted on '${MOUNT_POINT}' mount point"
|
__log "${DEV}: -d already mounted on '${MOUNT}' mount point"
|
||||||
exit 1
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
;;
|
||||||
|
(-m)
|
||||||
if echo "${MOUNT}" | grep -q " on ${2} "
|
if echo "${MOUNT}" | grep -q " on ${2} "
|
||||||
then
|
then
|
||||||
local DEVICE=$( echo "${MOUNT}" | grep " on ${2} " | awk '{print $1}' )
|
local DEVICE="$( echo "${MOUNT}" | grep " on ${2} " | awk '{print $1}' )"
|
||||||
__log "${DEVICE}: already mounted on '${2}' mount point"
|
__log "${DEVICE}: -m already mounted on '${2}' mount point"
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# FUNCTION: wait for device to appear (sometimes needed)
|
|
||||||
__wait_for_device() { # 1=DEV
|
|
||||||
# do not wait for MTP and CD-ROM devices
|
|
||||||
case ${1} in
|
|
||||||
(*ugen*|iso9660*)
|
|
||||||
return
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
# try to read from device to ensure that it alive
|
|
||||||
local COUNT=0
|
|
||||||
while ! dd if="${1}" of=/dev/null conv=sync count=1 bs=8k 1> /dev/null 2>&1
|
|
||||||
do
|
|
||||||
if [ ! -e "${1}" ]
|
|
||||||
then
|
|
||||||
__log "${1}: device gone"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
COUNT=$(( ${COUNT} + 1 ))
|
|
||||||
if [ ${COUNT} -ge ${RETRY_COUNT} ]
|
|
||||||
then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
sleep "${RETRY_DELAY}"
|
|
||||||
__log "${1}: wait for device retry ${COUNT}/${RETRY_COUNT}"
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
# FUNCTION: check if device is a block device
|
|
||||||
__check_block_device() { # 1=DEV
|
|
||||||
# first check if its block device
|
|
||||||
if ! fstyp ${1} 1> /dev/null 2>&1
|
|
||||||
then
|
|
||||||
__log "${DEV}: not a block device"
|
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
# main ATTACH/DETACH block
|
DEV=/dev/${1}
|
||||||
|
|
||||||
case ${2} in
|
case ${2} in
|
||||||
(attach)
|
(attach)
|
||||||
# check if device still exists
|
ADD=0
|
||||||
if [ ! -e "${DEV}" ]
|
MNT="${MNTPREFIX}/${1}"
|
||||||
|
__check_already_mounted -d ${DEV}
|
||||||
|
__check_already_mounted -m ${MNT}
|
||||||
|
if [ "${ATIME}" = NO ]
|
||||||
then
|
then
|
||||||
__log "${DEV}: device does not exist"
|
OPTS="noatime"
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
__log "${DEV}: attach"
|
while ! head -c 1 ${DEV} 1> /dev/null 2> /dev/null
|
||||||
|
|
||||||
# ignore system partitions like EFI or MSR
|
|
||||||
if [ "${IGNORE_SYS_PARTS}" = 'YES' ]
|
|
||||||
then
|
|
||||||
SYS_DEV=$( echo ${1} | grep -E -o '^[a-z]+[0-9]+' )
|
|
||||||
SYS_GPART=$( gpart show -p -r ${SYS_DEV} 2> /dev/null | sed 's@=>@@g' | grep " ${1} " | awk '{print $4}' )
|
|
||||||
case ${SYS_GPART} in
|
|
||||||
(c12a7328-f81f-11d2-ba4b-00a0c93ec93b) exit 0 ;;
|
|
||||||
(e3c9e316-0b5c-4db8-817d-f92df00215ae) exit 0 ;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
|
|
||||||
# code for NICENAMES mounting instead of the /dev/${DEV} default
|
|
||||||
MNT_CANDIDATE=$( fstyp -l "/dev/${1}" 2> /dev/null | cut -d " " -f 2-99 | tr ' ' '-' )
|
|
||||||
if [ "${NICENAMES}" = "YES" -a -n "${MNT_CANDIDATE}" ]
|
|
||||||
then
|
|
||||||
# check if dir exists
|
|
||||||
if [ -e "${MNT_PREFIX}/${MNT_CANDIDATE}" ]
|
|
||||||
then
|
|
||||||
# check if something is already mounted there and increment if it is
|
|
||||||
if mount | grep -q " ${MNT_PREFIX}/${MNT_CANDIDATE} "
|
|
||||||
then
|
|
||||||
COUNT=1
|
|
||||||
while true
|
|
||||||
do
|
do
|
||||||
COUNT=$(( ${COUNT} + 1 ))
|
sleep 0.2
|
||||||
[ ! -e "${MNT_PREFIX}/${MNT_CANDIDATE}-${COUNT}" ] && break
|
|
||||||
done
|
done
|
||||||
MNT="${MNT_PREFIX}/${MNT_CANDIDATE}-${COUNT}"
|
case $( file -b -L -s ${DEV} | sed -E 's/label:\ \".*\"//g' ) in
|
||||||
else
|
(*FAT*) # must be before NTFS section: newfs_msdos -O NTFS -L NTFS
|
||||||
# dir exists but its not mounted
|
__create_mount_point ${DEV}
|
||||||
MNT="${MNT_PREFIX}/${MNT_CANDIDATE}"
|
fsck_msdosfs -y ${DEV} \
|
||||||
fi
|
|
||||||
else
|
|
||||||
# dir does not exist
|
|
||||||
MNT="${MNT_PREFIX}/${MNT_CANDIDATE}"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
# device/filesystem without label
|
|
||||||
MNT="${MNT_PREFIX}/${1}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# blacklist check
|
|
||||||
if [ -n "${BLACKLIST}" ]
|
|
||||||
then
|
|
||||||
for I in ${BLACKLIST}
|
|
||||||
do
|
|
||||||
if [ "${1}" = "${I}" ]
|
|
||||||
then
|
|
||||||
__log "${DEV}: device blocked by BLACKLIST option"
|
|
||||||
exit 0
|
|
||||||
elif [ -n "${BLACKLIST_REGEX}" ] && echo ${DEV} | grep -q "${I}" 1> /dev/null 2> /dev/null
|
|
||||||
then
|
|
||||||
__log "${DEV}: device blocked by BLACKLIST_REGEX option"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
# check is device already mounted
|
|
||||||
__check_already_mounted "${DEV}" "${MNT}"
|
|
||||||
|
|
||||||
# make sure that data can be read from device
|
|
||||||
__wait_for_device "${DEV}"
|
|
||||||
|
|
||||||
# load needed kernel modules
|
|
||||||
kldload fusefs 1> /dev/null 2> /dev/null
|
|
||||||
kldload geom_uzip 1> /dev/null 2> /dev/null
|
|
||||||
|
|
||||||
# detect filesysytem type
|
|
||||||
case ${1} in
|
|
||||||
(iso9660*)
|
|
||||||
FS_TYPE=${FS_TYPE_ISO9660}
|
|
||||||
;;
|
|
||||||
(ugen*)
|
|
||||||
FS_TYPE=${FS_TYPE_MTP}
|
|
||||||
;;
|
|
||||||
(cd*)
|
|
||||||
__guess_fs_type "${DEV}"
|
|
||||||
FS_TYPE=${?}
|
|
||||||
;;
|
|
||||||
(md*.uzip|md*|ada*|da*|mmcsd*)
|
|
||||||
__check_block_device "${DEV}"
|
|
||||||
__guess_fs_type "${DEV}"
|
|
||||||
FS_TYPE=${?}
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# process ATIME option
|
|
||||||
case ${ATIME} in
|
|
||||||
([Nn][Oo]) OPTS="-o noatime" ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# filesystem options abstraction layer
|
|
||||||
case ${FS_TYPE} in
|
|
||||||
(${FS_TYPE_ISO9660})
|
|
||||||
FS_CHECK_CMD=''
|
|
||||||
FS_CHECK_ARGS=''
|
|
||||||
FS_MOUNT_CMD='mount'
|
|
||||||
FS_MOUNT_ARGS="-t cd9660 -o -e,-C=${ISO9660_CODEPAGE} ${DEV} ${MNT}"
|
|
||||||
;;
|
|
||||||
(${FS_TYPE_UFS})
|
|
||||||
FS_CHECK_CMD='fsck_ufs'
|
|
||||||
FS_CHECK_ARGS="-C -y"
|
|
||||||
FS_MOUNT_CMD='mount'
|
|
||||||
FS_MOUNT_ARGS="-t ufs ${OPTS} ${DEV} ${MNT}"
|
|
||||||
;;
|
|
||||||
(${FS_TYPE_EXT2})
|
|
||||||
FS_CHECK_PORT='sysutils/e2fsprogs'
|
|
||||||
FS_CHECK_CMD='fsck.ext2'
|
|
||||||
FS_CHECK_ARGS="-y"
|
|
||||||
FS_MOUNT_PORT='sysutils/fusefs-lkl'
|
|
||||||
FS_MOUNT_CMD='lklfuse'
|
|
||||||
FS_MOUNT_ARGS="-o type=ext2 -o allow_other -o intr -o uid=${UID} -o gid=${GID} -o umask=002 ${DEV} ${MNT}"
|
|
||||||
;;
|
|
||||||
(${FS_TYPE_EXT3})
|
|
||||||
FS_CHECK_PORT='sysutils/e2fsprogs'
|
|
||||||
FS_CHECK_CMD='fsck.ext3'
|
|
||||||
FS_CHECK_ARGS="-y"
|
|
||||||
FS_MOUNT_PORT='sysutils/fusefs-lkl'
|
|
||||||
FS_MOUNT_CMD='lklfuse'
|
|
||||||
FS_MOUNT_ARGS="-o type=ext3 -o allow_other -o intr -o uid=${UID} -o gid=${GID} -o umask=002 ${DEV} ${MNT}"
|
|
||||||
;;
|
|
||||||
(${FS_TYPE_EXT4})
|
|
||||||
FS_CHECK_PORT='sysutils/e2fsprogs'
|
|
||||||
FS_CHECK_CMD='fsck.ext4'
|
|
||||||
FS_CHECK_ARGS="-y"
|
|
||||||
FS_MOUNT_PORT='sysutils/fusefs-lkl'
|
|
||||||
FS_MOUNT_CMD='lklfuse'
|
|
||||||
FS_MOUNT_ARGS="-o type=ext4 -o allow_other -o intr -o uid=${UID} -o gid=${GID} -o umask=002 ${DEV} ${MNT}"
|
|
||||||
;;
|
|
||||||
(${FS_TYPE_XFS})
|
|
||||||
FS_CHECK_PORT='sysutils/xfsprogs'
|
|
||||||
FS_CHECK_CMD='xfs_repair'
|
|
||||||
FS_CHECK_ARGS="-d"
|
|
||||||
FS_MOUNT_CMD='lklfuse'
|
|
||||||
FS_MOUNT_ARGS="-o type=xfs -o allow_other -o uid=${UID} -o gid=${GID} ${DEV} ${MNT}"
|
|
||||||
FS_MOUNT_PORT='sysutils/fusefs-lkl'
|
|
||||||
;;
|
|
||||||
(${FS_TYPE_HFS})
|
|
||||||
FS_CHECK_CMD=''
|
|
||||||
FS_CHECK_ARGS=''
|
|
||||||
FS_MOUNT_CMD='hfsfuse'
|
|
||||||
FS_MOUNT_ARGS="--force ${OPTS} ${DEV} ${MNT}"
|
|
||||||
FS_MOUNT_PORT='sysutils/fusefs-hfsfuse'
|
|
||||||
;;
|
|
||||||
(${FS_TYPE_FAT})
|
|
||||||
# FreeBSD 12.x and later does not support/need '-o large' option
|
|
||||||
case $( sysctl -n kern.osrelease ) in
|
|
||||||
(10*) LARGE="-o large" ;;
|
|
||||||
(11*) LARGE="-o large" ;;
|
|
||||||
(*) LARGE="" ;;
|
|
||||||
esac
|
|
||||||
FS_CHECK_CMD='fsck_msdosfs'
|
|
||||||
FS_CHECK_ARGS="-C -y"
|
|
||||||
FS_MOUNT_CMD='mount_msdosfs'
|
|
||||||
FS_MOUNT_ARGS="-o longnames -m ${MNT_MODE} -M ${MNT_MODE} -D ${FAT_CODEPAGE} -L ${FAT_ENCODING} -u ${UID} -g ${GID} ${OPTS} ${LARGE} ${DEV} ${MNT}"
|
|
||||||
;;
|
|
||||||
(${FS_TYPE_EXFAT})
|
|
||||||
FS_CHECK_PORT='sysutils/exfat-utils'
|
|
||||||
FS_CHECK_CMD='fsck.exfat'
|
|
||||||
FS_CHECK_ARGS="-y"
|
|
||||||
FS_MOUNT_CMD='mount.exfat'
|
|
||||||
FS_MOUNT_UMASK=$( printf "%03o" $((~0775&0777)) )
|
|
||||||
FS_MOUNT_ARGS="-o uid=${UID} -o gid=${GID} -o umask=${FS_MOUNT_UMASK} ${OPTS} ${DEV} ${MNT}"
|
|
||||||
FS_MOUNT_PORT='sysutils/fusefs-exfat'
|
|
||||||
;;
|
|
||||||
(${FS_TYPE_NTFS})
|
|
||||||
FS_CHECK_CMD=''
|
|
||||||
FS_CHECK_ARGS=''
|
|
||||||
if /usr/bin/which -s ntfs-3g
|
|
||||||
then
|
|
||||||
FS_MOUNT_CMD='ntfs-3g'
|
|
||||||
FS_MOUNT_ARGS="-o recover ${OPTS} ${DEV} ${MNT}"
|
|
||||||
FS_MOUNT_PORT='sysutils/fusefs-ntfs'
|
|
||||||
else
|
|
||||||
FS_MOUNT_CMD='mount_ntfs'
|
|
||||||
FS_MOUNT_ARGS="-u root -g ${MNT_GROUP} ${OPTS} ${DEV} ${MNT}"
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
(${FS_TYPE_MTP})
|
|
||||||
FS_PORT='sysutils/fusefs-simple-mtpfs'
|
|
||||||
FS_CHECK_CMD=''
|
|
||||||
FS_CHECK_ARGS=''
|
|
||||||
FS_MOUNT_CMD='simple-mtpfs'
|
|
||||||
if ! /usr/bin/which -s "${FS_MOUNT_CMD}"
|
|
||||||
then
|
|
||||||
__log "command '${FS_MOUNT_CMD}' not found"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
PHONEDEV=$( simple-mtpfs --list-devices -d ${DEV} 2> /dev/null )
|
|
||||||
if [ "${PHONEDEV}" = "No raw devices found." ]
|
|
||||||
then
|
|
||||||
__log "${DEV}: no raw devices found"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
PHONEDEV=$( echo "${PHONEDEV}" | awk '{print $1}' | tr -d ':' )
|
|
||||||
if [ ! ${PHONEDEV} ]
|
|
||||||
then
|
|
||||||
__log "${DEV}: no MTP devices found"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
FS_MOUNT_ARGS="--device ${PHONEDEV} ${MNT} -o allow_other -o uid=${UID} -o gid=${GID}"
|
|
||||||
;;
|
|
||||||
(*)
|
|
||||||
__log "${DEV}: filesystem not supported or no filesystem"
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# create mount point
|
|
||||||
mkdir -m "${MNT_MODE}" -p "${MNT}"
|
|
||||||
__log "${DEV}: create '${MNT}' dir"
|
|
||||||
|
|
||||||
# check file system before mount
|
|
||||||
if [ -n "${FS_CHECK_CMD}" ]
|
|
||||||
then
|
|
||||||
if ! /usr/bin/which -s "${FS_CHECK_CMD}"
|
|
||||||
then
|
|
||||||
__log "command '${FS_CHECK_CMD}' not found"
|
|
||||||
__log "please install '${FS_CHECK_PORT}' port or package"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
${FS_CHECK_CMD} ${FS_CHECK_ARGS} ${DEV} \
|
|
||||||
| while read LINE
|
| while read LINE
|
||||||
do
|
do
|
||||||
__log "${DEV}: ${FS_CHECK_CMD} ${LINE}"
|
__log "${DEV}: fsck_msdosfs ${LINE}"
|
||||||
done
|
done
|
||||||
fi
|
if mount_msdosfs -o large -D ${CODEPAGE} -L ${ENCODING} \
|
||||||
|
-m 644 -M 755 ${DEV} ${MNT}
|
||||||
# check is device already mounted
|
|
||||||
__check_already_mounted "${DEV}" "${MNT}"
|
|
||||||
|
|
||||||
# try to mount
|
|
||||||
if ! /usr/bin/which -s "${FS_MOUNT_CMD}"
|
|
||||||
then
|
then
|
||||||
__log "command '${FS_MOUNT_CMD}' not found"
|
ADD=1
|
||||||
__log "please install '${FS_MOUNT_PORT}' port or package"
|
else
|
||||||
|
__log "${DEV}: mount failed (fat) 'mount_msdosfs -o large -D ${CODEPAGE} -L ${ENCODING} -m 644 -M 755 ${DEV} ${MNT}'"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
__wait_for_device "${DEV}"
|
__log "${DEV}: mount (fat)"
|
||||||
|
;;
|
||||||
# execute appropriate mount(8) command
|
(*NTFS*) # must be after FAT section: newfs_msdos -O NTFS -L NTFS
|
||||||
COUNT=0
|
__create_mount_point ${DEV}
|
||||||
while ! ${FS_MOUNT_CMD} ${FS_MOUNT_ARGS} 2> /dev/null
|
if which ntfs-3g 1> /dev/null 2> /dev/null # sysutils/fusefs-ntfs
|
||||||
|
then
|
||||||
|
if ntfs-3g -o ${OPTS} ${DEV} ${MNT}
|
||||||
|
then
|
||||||
|
ADD=1
|
||||||
|
else
|
||||||
|
__log "${DEV}: mount failed (ntfs) 'ntfs-3g -o ${OPTS} ${DEV} ${MNT}'"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if ! [ "${USER}" = 0 ]
|
||||||
|
then
|
||||||
|
OPTS="-u ${USER} -g $( id -g -n ${USER} )"
|
||||||
|
fi
|
||||||
|
if mount_ntfs ${OPTS} -o noatime ${DEV} ${MNT}
|
||||||
|
then
|
||||||
|
ADD=1
|
||||||
|
else
|
||||||
|
__log "${DEV}: mount failed (ntfs) 'ntfs-3g -o ${OPTS} ${DEV} ${MNT}'"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
__log "${DEV}: mount (ntfs)"
|
||||||
|
;;
|
||||||
|
(*ext2*)
|
||||||
|
__create_mount_point ${DEV}
|
||||||
|
fsck.ext2 -y ${DEV} \
|
||||||
|
| while read LINE
|
||||||
do
|
do
|
||||||
if [ ! -e "${DEV}" ]
|
__log "${DEV}: fsck.ext2 ${LINE}"
|
||||||
then
|
|
||||||
__log "${DEV}: device gone"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
COUNT=$(( ${COUNT} + 1 ))
|
|
||||||
if [ ${COUNT} -gt ${RETRY_COUNT} ]
|
|
||||||
then
|
|
||||||
|
|
||||||
# BEGIN | try to mount read only
|
|
||||||
FS_MOUNT_ARGS="-o ro ${FS_MOUNT_ARGS}"
|
|
||||||
${FS_MOUNT_CMD} ${FS_MOUNT_ARGS}
|
|
||||||
|
|
||||||
if [ ${?} -eq 0 ]
|
|
||||||
then
|
|
||||||
__log "${DEV}: mount OK: '${FS_MOUNT_CMD} ${FS_MOUNT_ARGS}'"
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
# END | try to mount read only
|
|
||||||
|
|
||||||
__log "${DEV}: mount FAIL: '${FS_MOUNT_CMD} ${FS_MOUNT_ARGS}'"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
sleep "${RETRY_DELAY}"
|
|
||||||
__log "${DEV}: filesystem mount retry: ${COUNT}/${RETRY_COUNT}"
|
|
||||||
done
|
done
|
||||||
__log "${DEV}: mount OK: '${FS_MOUNT_CMD} ${FS_MOUNT_ARGS}'"
|
if mount -t ext2fs -o ${OPTS} ${DEV} ${MNT}
|
||||||
|
then
|
||||||
# add needed rights
|
ADD=1
|
||||||
chown "${USER}:${MNT_GROUP}" "${MNT}"
|
else
|
||||||
__log "${DEV}: chown '${MNT}' dir with '${USER}:${MNT_GROUP}' rights"
|
__log "${DEV}: mount failed (ext2) 'mount -t ext2fs -o ${OPTS} ${DEV} ${MNT}'"
|
||||||
|
exit 1
|
||||||
# add state
|
fi
|
||||||
|
__log "${DEV}: mount (ext2)"
|
||||||
|
;;
|
||||||
|
(*ext3*)
|
||||||
|
__create_mount_point ${DEV}
|
||||||
|
fsck.ext3 -y ${DEV} \
|
||||||
|
| while read LINE
|
||||||
|
do
|
||||||
|
__log "${DEV}: fsck.ext3 ${LINE}"
|
||||||
|
done
|
||||||
|
if mount -t ext2fs -o ${OPTS} ${DEV} ${MNT}
|
||||||
|
then
|
||||||
|
ADD=1
|
||||||
|
else
|
||||||
|
__log "${DEV}: mount failed (ext3) 'mount -t ext2fs -o ${OPTS} ${DEV} ${MNT}'"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
__log "${DEV}: mount (ext3)"
|
||||||
|
;;
|
||||||
|
(*ext4*)
|
||||||
|
__create_mount_point ${DEV}
|
||||||
|
fsck.ext4 -y ${DEV} \
|
||||||
|
| while read LINE
|
||||||
|
do
|
||||||
|
__log "${DEV}: fsck.ext4 ${LINE}"
|
||||||
|
done
|
||||||
|
if ext4fuse ${DEV} ${MNT} # sysutils/fusefs-ext4fuse
|
||||||
|
then
|
||||||
|
ADD=1
|
||||||
|
else
|
||||||
|
__log "${DEV}: mount failed (ext4) 'ext4fuse ${DEV} ${MNT}'"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
__log "${DEV}: mount (ext4)"
|
||||||
|
;;
|
||||||
|
(*Unix\ Fast\ File*)
|
||||||
|
__create_mount_point ${DEV}
|
||||||
|
fsck_ufs -C -y ${DEV} \
|
||||||
|
| while read LINE
|
||||||
|
do
|
||||||
|
__log "${DEV}: fsck_ufs ${LINE}"
|
||||||
|
done
|
||||||
|
if mount -t ufs -o ${OPTS} ${DEV} ${MNT}
|
||||||
|
then
|
||||||
|
ADD=1
|
||||||
|
else
|
||||||
|
__log "${DEV}: mount failed (ufs) 'mount -t ufs -o ${OPTS} ${DEV} ${MNT}'"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
__log "${DEV}: mount (ufs)"
|
||||||
|
;;
|
||||||
|
(*)
|
||||||
|
case $( dd < ${DEV} count=1 2> /dev/null | strings | head -1 ) in
|
||||||
|
(*EXFAT*)
|
||||||
|
__create_mount_point ${DEV}
|
||||||
|
if mount.exfat -o ${OPTS} ${DEV} ${MNT} # sysutils/fusefs-exfat
|
||||||
|
then
|
||||||
|
ADD=1
|
||||||
|
else
|
||||||
|
__log "${DEV}: mount failed (exfat) 'mount.exfat -o ${OPTS} ${DEV} ${MNT}'"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
__log "${DEV}: mount (exfat)"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
if [ ${ADD} -eq 1 ]
|
||||||
|
then
|
||||||
|
ADD=0
|
||||||
PROVIDER=$( mount | grep -m 1 " ${MNT} " | awk '{printf $1}' )
|
PROVIDER=$( mount | grep -m 1 " ${MNT} " | awk '{printf $1}' )
|
||||||
__state_add ${DEV} ${PROVIDER} ${MNT}
|
__state_add ${DEV} ${PROVIDER} ${MNT}
|
||||||
|
if [ "${USER}" != 0 -a "${FM}" != 0 ]
|
||||||
# open file manager and display message
|
|
||||||
__show_message "Device '${DEV}' mounted on '${MNT}' directory."
|
|
||||||
if [ -n "${FM}" ]
|
|
||||||
then
|
then
|
||||||
GROUP_USERS=$( pw group show ${MNT_GROUP} | sed -e 's|.*:||' -e 's|,| |g' )
|
# su - ${USER} -c "env DISPLAY=:0 ${FM} ${MNT} &"
|
||||||
for I in ${GROUP_USERS}
|
su - ${USER} -c "env DISPLAY=:0 ${FM} &"
|
||||||
do
|
fi
|
||||||
[ "${I}" = "root" ] && continue
|
|
||||||
XORG_PID=$( pgrep Xorg )
|
|
||||||
[ "${XORG_PID}" = "" ] && continue
|
|
||||||
DISPLAY_ID=$( procstat pargs ${XORG_PID} | grep "^argv\[1\]:" | awk '{print $NF}' )
|
|
||||||
[ -z "${DISPLAY_ID}" ] && continue
|
|
||||||
__log "${DEV}: starting '${FM}' file manager"
|
|
||||||
su -l "${I}" -c "env DISPLAY=${DISPLAY_ID} ${FM} ${MNT} &" 1> /dev/null 2>&1
|
|
||||||
done
|
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
(detach)
|
(detach)
|
||||||
__log "${DEV}: detach"
|
grep -E "${MNTPREFIX}/${1}$" ${STATE} \
|
||||||
if [ -f ${STATE} ]
|
|
||||||
then
|
|
||||||
grep -E "^/dev/${1} " ${STATE} \
|
|
||||||
| while read DEV PROVIDER MNT
|
| while read DEV PROVIDER MNT
|
||||||
do
|
do
|
||||||
TARGET=$( mount | grep -v \.gvfs | grep -m 1 -E "^${PROVIDER} " | awk '{print $3}' )
|
TARGET=$( mount | grep -E "^${PROVIDER} " | awk '{print $3}' )
|
||||||
__state_remove ${MNT}
|
__state_remove ${MNT}
|
||||||
if [ -z ${TARGET} ]
|
if [ -z ${TARGET} ]
|
||||||
then
|
then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
( # put entire umount/find/rm block into background
|
( # put entire umount/find/rm block into background
|
||||||
# umount(8) two times to make sure its unmounted
|
umount -f ${TARGET}
|
||||||
umount -f "${TARGET}" 1> /dev/null 2>&1
|
__remove_dir "${TARGET}"
|
||||||
umount -f "${TARGET}" 1> /dev/null 2>&1
|
__log "${DEV}: removed '${TARGET}'"
|
||||||
__log "${DEV}: (state) umount '${TARGET}'"
|
|
||||||
__remove_dir "${TARGET}" &
|
|
||||||
__log "${DEV}: (state) mount point '${TARGET}' removed"
|
|
||||||
) &
|
) &
|
||||||
unset TARGET
|
unset TARGET
|
||||||
|
__log "${DEV}: umount"
|
||||||
done
|
done
|
||||||
|
__log "${DEV}: detach"
|
||||||
# code for NICENAMES mounting instead of the /dev/${DEV} default
|
__remove_dir "${MNTPREFIX}/${1}"
|
||||||
if [ "${NICENAMES}" != YES ]
|
__log "${DEV}: mount point '${MNTPREFIX}/${1}' removed"
|
||||||
then
|
|
||||||
# umount(8) two times to make sure its unmounted
|
|
||||||
umount -f "${MNT_PREFIX}/${1}" 1> /dev/null 2>&1
|
|
||||||
umount -f "${MNT_PREFIX}/${1}" 1> /dev/null 2>&1
|
|
||||||
__log "${DEV}: (direct) umount '${MNT_PREFIX}/${1}'"
|
|
||||||
__remove_dir "${MNT_PREFIX}/${1}" &
|
|
||||||
__log "${DEV}: (direct) mount point '${MNT_PREFIX}/${1}' removed"
|
|
||||||
fi
|
|
||||||
__show_message "Device '${DEV}' unmounted from '${MNT}' directory."
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
|
|
@ -1,3 +1,7 @@
|
||||||
USERUMOUNT=YES
|
USERUMOUNT=YES
|
||||||
|
ATIME=NO
|
||||||
|
REMOVEDIRS=YES
|
||||||
|
FM="nautilus --browser --no-desktop"
|
||||||
|
USER=vermaden
|
||||||
|
ENCODING=pl_PL.ISO8859-2
|
||||||
|
CODEPAGE=cp852
|
||||||
|
|
|
||||||
|
|
@ -1,45 +1,14 @@
|
||||||
|
|
||||||
# PENDRIVE/PHONE/SDCARD insert
|
|
||||||
notify 100 {
|
notify 100 {
|
||||||
match "system" "DEVFS";
|
match "system" "DEVFS";
|
||||||
match "type" "CREATE";
|
match "type" "CREATE";
|
||||||
match "cdev" "(da|mmcsd|ugen)[0-9]+.*";
|
match "cdev" "(da|mmcsd)[0-9]+";
|
||||||
action "/usr/local/sbin/automount $cdev attach &";
|
action "/usr/local/sbin/automount $cdev attach";
|
||||||
};
|
};
|
||||||
|
|
||||||
# PENDRIVE/PHONE/SDCARD remove
|
|
||||||
notify 100 {
|
notify 100 {
|
||||||
match "system" "DEVFS";
|
match "system" "DEVFS";
|
||||||
match "type" "DESTROY";
|
match "type" "DESTROY";
|
||||||
match "cdev" "(da|mmcsd|ugen)[0-9]+.*";
|
match "cdev" "(da|mmcsd)[0-9]+";
|
||||||
action "/usr/local/sbin/automount $cdev detach &";
|
action "/usr/local/sbin/automount $cdev detach";
|
||||||
};
|
|
||||||
|
|
||||||
# CD-ROM media inject
|
|
||||||
notify 100 {
|
|
||||||
match "system" "DEVFS";
|
|
||||||
match "type" "CREATE|MEDIACHANGE";
|
|
||||||
match "cdev" "(cd)[0-9]+.*";
|
|
||||||
action "/usr/local/sbin/automount $cdev attach &";
|
|
||||||
};
|
|
||||||
|
|
||||||
# CD-ROM media eject
|
|
||||||
notify 100 {
|
|
||||||
match "system" "DEVFS";
|
|
||||||
match "type" "DESTROY";
|
|
||||||
match "cdev" "(cd)[0-9]+.*";
|
|
||||||
action "/usr/local/sbin/automount $cdev detach &";
|
|
||||||
};
|
|
||||||
|
|
||||||
# CD-ROM no media
|
|
||||||
notify 100 {
|
|
||||||
match "system" "CAM";
|
|
||||||
match "subsystem" "periph";
|
|
||||||
match "type" "error";
|
|
||||||
match "cam_status" "0xcc";
|
|
||||||
match "scsi_status" "2";
|
|
||||||
match "scsi_sense" "70 02 3a 02";
|
|
||||||
match "device" "(cd)[0-9]+.*";
|
|
||||||
action "/usr/local/sbin/automount $device detach &";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
notify 200 {
|
notify 200 {
|
||||||
match "system" "DEVFS";
|
match "system" "DEVFS";
|
||||||
match "type" "CREATE";
|
match "type" "CREATE";
|
||||||
match "cdev" "(da|mmcsd)[0-9]+.*";
|
match "cdev" "(da|mmcsd)[0-9]+";
|
||||||
action "/bin/sh -xe /usr/local/sbin/automount $cdev attach >> /root/DEBUG.$cdev.attach 2>&1";
|
action "/usr/local/sbin/automount $cdev attach >> /root/DEBUG.$cdev.attach 2>&1";
|
||||||
};
|
};
|
||||||
|
|
||||||
notify 200 {
|
notify 200 {
|
||||||
match "system" "DEVFS";
|
match "system" "DEVFS";
|
||||||
match "type" "DESTROY";
|
match "type" "DESTROY";
|
||||||
match "cdev" "(da|mmcsd)[0-9]+.*";
|
match "cdev" "(da|mmcsd)[0-9]+";
|
||||||
action "/bin/sh -xe /usr/local/sbin/automount $cdev detach >> /root/DEBUG.$cdev.detach 2>&1";
|
action "/usr/local/sbin/automount $cdev detach >> /root/DEBUG.$cdev.detach 2>&1";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
# SUPPORT md(4) IMAGES/DISKS attach
|
|
||||||
notify 100 {
|
|
||||||
match "system" "DEVFS";
|
|
||||||
match "type" "CREATE";
|
|
||||||
match "cdev" "(md)[0-9]+.*";
|
|
||||||
action "/usr/local/sbin/automount $cdev attach &";
|
|
||||||
};
|
|
||||||
|
|
||||||
# SUPPORT md(4) IMAGES/DISKS detach
|
|
||||||
notify 100 {
|
|
||||||
match "system" "DEVFS";
|
|
||||||
match "type" "DESTROY";
|
|
||||||
match "cdev" "(md)[0-9]+.*";
|
|
||||||
action "/usr/local/sbin/automount $cdev detach &";
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
|
|
||||||
# LOCAL DISKS attach
|
|
||||||
notify 100 {
|
|
||||||
match "system" "DEVFS";
|
|
||||||
match "type" "CREATE";
|
|
||||||
match "cdev" "(ada)[0-9]+.*";
|
|
||||||
action "/usr/local/sbin/automount $cdev attach &";
|
|
||||||
};
|
|
||||||
|
|
||||||
# LOCAL DISKS remove
|
|
||||||
notify 100 {
|
|
||||||
match "system" "DEVFS";
|
|
||||||
match "type" "DESTROY";
|
|
||||||
match "cdev" "(ada)[0-9]+.*";
|
|
||||||
action "/usr/local/sbin/automount $cdev detach &";
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,81 @@
|
||||||
|
# This is a shell archive. Save it in a file, remove anything before
|
||||||
|
# this line, and then unpack it by entering "sh file". Note, it may
|
||||||
|
# create directories; files and directories will be owned by you and
|
||||||
|
# have default permissions.
|
||||||
|
#
|
||||||
|
# This archive contains:
|
||||||
|
#
|
||||||
|
# automount
|
||||||
|
# automount/pkg-install
|
||||||
|
# automount/Makefile
|
||||||
|
# automount/distinfo
|
||||||
|
# automount/pkg-descr
|
||||||
|
#
|
||||||
|
echo c - automount
|
||||||
|
mkdir -p automount > /dev/null 2>&1
|
||||||
|
echo x - automount/pkg-install
|
||||||
|
sed 's/^X//' >automount/pkg-install << '251e9ad33f5651c05228156a36207e92'
|
||||||
|
X#!/bin/sh
|
||||||
|
X
|
||||||
|
Xcase ${2} in
|
||||||
|
X (POST-INSTALL)
|
||||||
|
X /etc/rc.d/devd restart
|
||||||
|
X echo
|
||||||
|
X echo
|
||||||
|
X echo "Check /usr/local/sbin/automount --help for available options."
|
||||||
|
X echo
|
||||||
|
X echo
|
||||||
|
X ;;
|
||||||
|
X (PRE-INSTALL)
|
||||||
|
X :
|
||||||
|
X ;;
|
||||||
|
Xesac
|
||||||
|
X
|
||||||
|
251e9ad33f5651c05228156a36207e92
|
||||||
|
echo x - automount/Makefile
|
||||||
|
sed 's/^X//' >automount/Makefile << 'a684d750ccdf9f4d6ffa6a1936b8d432'
|
||||||
|
X# New ports collection Makefile for: automount
|
||||||
|
X# Date created: 04 March 2012
|
||||||
|
X# Whom: Slawomir Wojciech Wojtczak <vermaden@interia.pl>
|
||||||
|
X#
|
||||||
|
X# $FreeBSD$
|
||||||
|
X#
|
||||||
|
X
|
||||||
|
XPORTNAME= automount
|
||||||
|
XPORTVERSION= 1.3.1
|
||||||
|
XCATEGORIES= sysutils
|
||||||
|
XMASTER_SITES= https://raw.github.com/vermaden/automount/master/
|
||||||
|
X
|
||||||
|
XMAINTAINER= vermaden@interia.pl
|
||||||
|
XCOMMENT= FreeBSD's devd(8) based automount sollution
|
||||||
|
X
|
||||||
|
XLICENSE= BSD
|
||||||
|
X
|
||||||
|
XPLIST_FILES= sbin/automount etc/devd/automount_devd.conf etc/automount.conf.sample
|
||||||
|
X
|
||||||
|
XNO_BUILD= yes
|
||||||
|
X
|
||||||
|
Xdo-install:
|
||||||
|
X ${INSTALL_SCRIPT} ${WRKSRC}/automount ${PREFIX}/sbin
|
||||||
|
X ${INSTALL_DATA} ${WRKSRC}/automount_devd.conf ${PREFIX}/etc/devd/automount_devd.conf
|
||||||
|
X ${INSTALL_DATA} ${WRKSRC}/automount.conf.sample ${PREFIX}/etc/automount.conf.sample
|
||||||
|
X ${SH} ${PKGINSTALL} ${PKGNAME} POST-INSTALL
|
||||||
|
X
|
||||||
|
X.include <bsd.port.mk>
|
||||||
|
a684d750ccdf9f4d6ffa6a1936b8d432
|
||||||
|
echo x - automount/distinfo
|
||||||
|
sed 's/^X//' >automount/distinfo << 'f9168fc754e2bffcb12d5eb7f25848ec'
|
||||||
|
XSHA256 (automount-1.3.1.tar.gz) = 1bc38c82b513c03bdd9e1f65edf552e3d1b74a64a90d628bad39a35d07ff0f7d
|
||||||
|
XSIZE (automount-1.3.1.tar.gz) = 3636
|
||||||
|
f9168fc754e2bffcb12d5eb7f25848ec
|
||||||
|
echo x - automount/pkg-descr
|
||||||
|
sed 's/^X//' >automount/pkg-descr << 'beeed37ba9f50e251d50bf9bd7dcb079'
|
||||||
|
Xautomount is a devd(8) based automounter for FreeBSD.
|
||||||
|
X
|
||||||
|
XIt supports most popular file systems:
|
||||||
|
XNTFS/MSDOS/exFAT/EXT2/EXT3/EXT4/UFS
|
||||||
|
X
|
||||||
|
XWWW: https://github.com/vermaden/automount/
|
||||||
|
beeed37ba9f50e251d50bf9bd7dcb079
|
||||||
|
exit
|
||||||
|
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
# New ports collection Makefile for: automount
|
||||||
|
# Date created: 04 March 2012
|
||||||
|
# Whom: Slawomir Wojciech Wojtczak <vermaden@interia.pl>
|
||||||
|
#
|
||||||
|
# $FreeBSD$
|
||||||
|
#
|
||||||
|
|
||||||
|
PORTNAME= automount
|
||||||
|
PORTVERSION= 1.3.1
|
||||||
|
CATEGORIES= sysutils
|
||||||
|
MASTER_SITES= https://raw.github.com/vermaden/automount/master/
|
||||||
|
|
||||||
|
MAINTAINER= vermaden@interia.pl
|
||||||
|
COMMENT= FreeBSD's devd(8) based automount sollution
|
||||||
|
|
||||||
|
LICENSE= BSD
|
||||||
|
|
||||||
|
PLIST_FILES= sbin/automount etc/devd/automount_devd.conf etc/automount.conf.sample
|
||||||
|
|
||||||
|
NO_BUILD= yes
|
||||||
|
|
||||||
|
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
|
||||||
|
${SH} ${PKGINSTALL} ${PKGNAME} POST-INSTALL
|
||||||
|
|
||||||
|
.include <bsd.port.mk>
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
SHA256 (automount-1.3.1.tar.gz) = 1bc38c82b513c03bdd9e1f65edf552e3d1b74a64a90d628bad39a35d07ff0f7d
|
||||||
|
SIZE (automount-1.3.1.tar.gz) = 3636
|
||||||
|
|
@ -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/
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
case ${2} in
|
||||||
|
(POST-INSTALL)
|
||||||
|
/etc/rc.d/devd restart
|
||||||
|
echo
|
||||||
|
echo
|
||||||
|
echo "Check /usr/local/sbin/automount --help for available options."
|
||||||
|
echo
|
||||||
|
echo
|
||||||
|
;;
|
||||||
|
(PRE-INSTALL)
|
||||||
|
:
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
Loading…
Reference in New Issue