pastebin - collaborative debugging tool
kpaste.net RSS


mount script
Posted by z0TK on Thu 8th Jul 2010 01:00
raw | new post

  1. #!/bin/bash
  2.  
  3. ip=10.0.0.2
  4. drives="F G H Z"
  5.  
  6. case $1 in
  7.         mount)
  8.                 ping -c1 $ip &>/dev/null
  9.  
  10.                 if [[ $? -eq 0 ]]; then
  11.  
  12.                 for drive in $drives; do
  13.  
  14.                 sudo mount -t cifs //${ip}/${drive} -o username=USER,password=PASS /mnt/${drive}
  15.  
  16.                 if [[ $? -eq 0 ]]; then
  17.  
  18.                         printf 'Successfully mounted //%s/%s to /mnt/%s\n' "$ip" "$drive" "$drive"
  19.                 else
  20.  
  21.                         printf 'Could not mount //%s/%s to /mnt/%s\n' "$ip" "$drive" "$drive"
  22.                 fi
  23.                 done
  24.                 else
  25.  
  26.                 printf 'Could not get a response from %s\n' "$ip"
  27.                 fi
  28.         ;;
  29.         umount)
  30.                 for drive in $drives; do
  31.  
  32.                 sudo umount /mnt/${drive}
  33.  
  34.                 if [[ $? -eq 0 ]]; then
  35.  
  36.                         printf 'Successfully unmounted /mnt/%s\n' "$drive"
  37.                 else
  38.  
  39.                         printf 'Could not unmount /mnt/%s\n' "$drive"
  40.                 fi
  41.                 done
  42.         ;;
  43.         status)
  44.                 mount -t cifs
  45.         ;;
  46. esac

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at