Advertisement
Guest User

Untitled

a guest
Sep 17th, 2014
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. #!/bin/bash
  2. # mountDDE mount the partitions of the disk b.
  3. # If arguments are passed, it will mount the specific partitions, a, b or c.
  4.  
  5. if [ -v "$1" ] # If no argument is passed, act on all partitions.
  6. then a=t
  7. b=t
  8. c=t
  9. fi
  10.  
  11. while [ -n "$1" ] ; do
  12. if [ $1="a" ] # We test the argument(s), to know which partition has to be mounted.
  13. then a=t
  14. elif [ $1="b"] # I hate redundunces
  15. then b=t
  16. elif [ $1="c"] # Again...
  17. then c=t
  18. fi
  19. shift
  20. done
  21.  
  22. [ $a="t" ] && sudo mount /dev/sba /media/ba # I'll actually use uuids.
  23. [ $b="t" ] && sudo mount /dev/sbb /media/bb # Not direct paths, like here.
  24. [ $c="t" ] && sudo mount /dev/sbc /media/bc
  25.  
  26. [ $1="b"]
  27.  
  28. [ "$1" = b ]
  29.  
  30. [[ $1 = b ]]
  31.  
  32. while [[ $1 ]] ; do
  33. case "$1" in
  34. a) a=t ;;
  35. b) b=t ;;
  36. c) c=t ;;
  37. esac
  38. shift
  39. done
  40.  
  41. for drive; do
  42. case $drive in
  43. a) a=t ;;
  44. b) b=t ;;
  45. c) c=t ;;
  46. esac
  47. done
  48.  
  49. #!/bin/bash
  50.  
  51. if [[ $# -gt 0 ]]; then
  52. set -- a b c
  53. fi
  54.  
  55. for x; do
  56. case $x in
  57. [abc]) sudo mount /dev/sb$x /media/b$x ;;
  58. esac
  59. done
  60.  
  61. #!/bin/bash
  62.  
  63. # If no argument is passed, act on all partitions.
  64. if (( $# == 0 )); then
  65. a=t b=t c=t
  66. else
  67. for arg; do
  68. if [[ $arg == a|b|c ]]; then
  69. declare $arg=t
  70. else
  71. echo "ignoring argument '$arg'"
  72. fi
  73. done
  74. fi
  75.  
  76. declare -A uuids=( [a]=1234 [b]=3456 [c]=5678 )
  77.  
  78. for dest in a b c; do
  79. if [[ ${!dest} == t ]]; then
  80. sudo mount /dev/sb$dest "${uuids[$dest]}"
  81. fi
  82. done
  83.  
  84. function do_mount()
  85. {
  86. while [ -n "$1" ]; do
  87. sudo mount /dev/sb"$1" /media/b"$1"
  88. done
  89. }
  90.  
  91. if [ -v "$@" ]; then
  92. do_mount a b c
  93. else
  94. do_mount "$@"
  95. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement