WizardKit/.linux_items/include/live/airootfs/usr/local/bin/mount-all-volumes
2017-12-13 10:56:13 -08:00

28 lines
1.1 KiB
Bash
Executable file

#!/bin/bash
#
## Mount all volumes read-only
# Mount all volumes
echo "Mounting all volumes"
regex="/dev/((h|s)d[a-z]|md)[0-9]+"
for volume in $(inxi -Dopxx | grep -E "$regex" | sed -r "s#.*($regex).*#\1#" | sort); do
if grep -q "$volume" /proc/mounts; then
if ! mount | grep "/run/archiso/bootmnt" | grep -q "$volume"; then
# Show what's already mounted except the WK_ARCH boot device
echo "$volume: (Already) mounted $(mount | grep "$volume" | sed -r 's/^\S+ (on.*) type .*/\1/') ($(df -h "$volume" | tail -1 | awk '{print $3, $4}' | sed -r 's/(K|M|G|T|) (.*[0-9])(K|M|G|T|)$/ \1b used, \2 \3b free/'))"
fi
else
if udevil mount -o ro $volume >/dev/null 2>&1; then
echo "$volume: Mounted $(mount | grep "$volume" | sed -r 's/^\S+ (on.*) type .*/\1/') ($(df -h "$volume" | tail -1 | awk '{print $3, $4}' | sed -r 's/(K|M|G|T|) (.*[0-9])(K|M|G|T|)$/ \1b used, \2 \3b free/'))"
else
echo "$volume: Failed to mount"
fi
fi
done
# Open folder?
if echo "$0" | grep -iq foh; then
thunar /media
fi
echo "Done."