Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # mountDDE mount the partitions of the disk b.
- # If arguments are passed, it will mount the specific partitions, a, b or c.
- if [ -v "$1" ] # If no argument is passed, act on all partitions.
- then a=t
- b=t
- c=t
- fi
- while [ -n "$1" ] ; do
- if [ $1="a" ] # We test the argument(s), to know which partition has to be mounted.
- then a=t
- elif [ $1="b"] # I hate redundunces
- then b=t
- elif [ $1="c"] # Again...
- then c=t
- fi
- shift
- done
- [ $a="t" ] && sudo mount /dev/sba /media/ba # I'll actually use uuids.
- [ $b="t" ] && sudo mount /dev/sbb /media/bb # Not direct paths, like here.
- [ $c="t" ] && sudo mount /dev/sbc /media/bc
- [ $1="b"]
- [ "$1" = b ]
- [[ $1 = b ]]
- while [[ $1 ]] ; do
- case "$1" in
- a) a=t ;;
- b) b=t ;;
- c) c=t ;;
- esac
- shift
- done
- for drive; do
- case $drive in
- a) a=t ;;
- b) b=t ;;
- c) c=t ;;
- esac
- done
- #!/bin/bash
- if [[ $# -gt 0 ]]; then
- set -- a b c
- fi
- for x; do
- case $x in
- [abc]) sudo mount /dev/sb$x /media/b$x ;;
- esac
- done
- #!/bin/bash
- # If no argument is passed, act on all partitions.
- if (( $# == 0 )); then
- a=t b=t c=t
- else
- for arg; do
- if [[ $arg == a|b|c ]]; then
- declare $arg=t
- else
- echo "ignoring argument '$arg'"
- fi
- done
- fi
- declare -A uuids=( [a]=1234 [b]=3456 [c]=5678 )
- for dest in a b c; do
- if [[ ${!dest} == t ]]; then
- sudo mount /dev/sb$dest "${uuids[$dest]}"
- fi
- done
- function do_mount()
- {
- while [ -n "$1" ]; do
- sudo mount /dev/sb"$1" /media/b"$1"
- done
- }
- if [ -v "$@" ]; then
- do_mount a b c
- else
- do_mount "$@"
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement