Run nmount in a loop

This commit is contained in:
Arun Prakash Jana 2019-05-05 23:05:46 +05:30
parent 0e8cb05045
commit 747490a180
No known key found for this signature in database
GPG Key ID: A75979F35C080412
1 changed files with 19 additions and 17 deletions

View File

@ -12,22 +12,24 @@ echo
echo -n "device (e.g. sdc2): "
read dev
if [ -z "$dev" ]; then
exit 1
fi
echo
if grep -qs "$dev " /proc/mounts; then
sync
pumount "$dev"
if [ "$?" -eq "0" ]; then
udisksctl power-off -b /dev/"$dev"
echo $dev ejected.
while ! [ -z "$dev" ]
do
if grep -qs "$dev " /proc/mounts; then
sync
pumount "$dev"
if [ "$?" -eq "0" ]; then
echo "$dev" unmounted.
udisksctl power-off -b /dev/"$dev"
if [ "$?" -eq "0" ]; then
echo "$dev" ejected.
fi
fi
else
pmount "$dev"
echo "$dev" mounted to "$(lsblk -n /dev/"$dev" | rev | cut -d' ' -f1 | rev)".
fi
else
pmount "$dev"
echo "$dev" mounted to "$(lsblk -n /dev/"$dev" | rev | cut -d' ' -f1 | rev)".
fi
read dummy
echo
echo -n "next device: "
read dev
done