#!/bin/bash ip=10.0.0.2 drives="F G H Z" case $1 in mount) ping -c1 $ip &>/dev/null if [[ $? -eq 0 ]]; then for drive in $drives; do sudo mount -t cifs //${ip}/${drive} -o username=USER,password=PASS /mnt/${drive} if [[ $? -eq 0 ]]; then printf 'Successfully mounted //%s/%s to /mnt/%s\n' "$ip" "$drive" "$drive" else printf 'Could not mount //%s/%s to /mnt/%s\n' "$ip" "$drive" "$drive" fi done else printf 'Could not get a response from %s\n' "$ip" fi ;; umount) for drive in $drives; do sudo umount /mnt/${drive} if [[ $? -eq 0 ]]; then printf 'Successfully unmounted /mnt/%s\n' "$drive" else printf 'Could not unmount /mnt/%s\n' "$drive" fi done ;; status) mount -t cifs ;; esac