Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- export LC_ALL=C
- declare -A DISKS
- declare -a A
- DISKS["0x01b2e156"]="/mnt/LEEF iocharset=cp866,uid=1000"
- T=$(mktemp)
- /sbin/fdisk -l >$T
- sed -rni '\~^Disk /dev/sd[a-z]:.*~{
- N;N;N;N;N
- s~^Disk (/dev/sd[a-z]):.*\nDisk identifier: (0x[[:xdigit:]]+)$~\1 \2~p
- }' $T
- while read DEV ID
- do
- echo "Device: '$DEV' disk ID: '$ID'"
- if mount | grep -Eqo "^$DEV"; then
- echo "Device '$DEV' already mounted"
- continue
- fi
- if [ -z "${DISKS[$ID]}" ]; then
- echo "Device not found"
- continue
- fi
- V=${DISKS[$ID]}
- A=( $V )
- TARGET=${A[0]}
- OPTIONS=${A[1]}
- echo "Target: '$TARGET' Options: '$OPTIONS'"
- if [ ! -d $TARGET ]; then
- mkdir -v -p $TARGET || exit
- fi
- mount -v -t vfat -o $OPTIONS ${DEV}1 $TARGET || exit
- done <$T
- rm $T
Advertisement
Add Comment
Please, Sign In to add comment