:: Re: [DNG] For all you automounter p…
Página Inicial
Delete this message
Reply to this message
Autor: fsmithred
Data:  
Para: dng
Assunto: Re: [DNG] For all you automounter programmers
On 04/27/2016 01:27 PM, Steve Litt wrote:

>>
>> That's pretty much what my usb-mounter does. Inotifywait runs when
>> you log into the desktop, and when you plug in a thumb drive, it pops
>> up a window showing you the partitions on that device. You then
>> choose one to mount, and the script runs pmount in your name.
>
> That sounds *perfect* to me, always assuming the "window" is a CLI
> question and answer i X isn't running. Where's the source code? I'd like
> to start using it.
>
> Somebody suggested we package an automounter for Devuan. What you
> describe sounds like the right thing.
>


Source code? Here's a link to a tarball that contains the scripts and
instructions on what goes where. I haven't packaged it, because I didn't
think it was finished.
https://sourceforge.net/projects/refracta/files/testing/usbwait.tar.gz/download


>
>> Bypassing the popup window and automounting would be a simple edit,
>
> My no-user-confirmation version was problematic and vaguely disturbing.
> I'd leave the user in the loop.
>
>> as would making it work without a gui.
>
> Yes. This being Devuan, some facility for asking and recieving an
> answer should be provided even if X isn't runnnig.
>


Try the following for a no-gui solution.

Once you've mounted something(s) you can see what removable devices are
mounted by running pmount with no arguments. Then 'pumount sdd1' or
whatever to unmount it. If we worked labels into this somehow, you could
'pumount label'.

If you try to mount the same partition twice, pmount complains and the
script exits. No harm done.



#!/usr/bin/env bash
#
# thumb-pick.sh

usbdevlist=$(/usr/sbin/hwinfo --usb --short | awk '/dev\/sd/ {print $1}')
usbdevfulllist=$(/usr/sbin/hwinfo --usb --short | awk '/dev\/sd/ {print $0}')

if [[ $(echo "$usbdevlist" | wc -l) = 1 ]] ; then
    device="$usbdevlist"
else
    echo -e "\n\tLIST OF USB DRIVES\n$usbdevfulllist\n\nSelect a device:"
    select opt in $usbdevlist ; do
        device=$(echo "$opt" | awk '{ print $1 }')
        break
    done
fi



partition_list=$(lsblk -l | grep ${device##*/}[1-9] | awk '{ print $1 }')

echo -e "\n\nSelect a partition to mount:"
select part in $partition_list ; do
    pmount "$part" || exit 1
    df -h
    exit 0
done



Have fun with it.
-fsr