Advertisement
Guest User

Untitled

a guest
Nov 26th, 2015
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. #!/usr/bin/env sh
  2.  
  3. # check if share is mounted, attempt recovery and remount
  4.  
  5. if [ -z "$1" ]; then
  6. echo "Usage: $0 /mount/point/to/check"
  7. exit 0
  8. fi
  9.  
  10. DIR="$1"
  11. if grep -qs "$DIR" /proc/mounts; then
  12. # echo "$DIR is mounted."
  13. exit 0
  14. else
  15. echo "$DIR is not mounted."
  16. if [ "$(ls -A $DIR)" ]; then
  17. NEWDIR="$DIR-`date +%F-%k-%M-%S`"
  18. echo "Files exist so renaming $DIR -> $NEWDIR"
  19. mv "$DIR" "$NEWDIR"
  20. mkdir -p "$DIR"
  21. fi
  22. echo "Attempt remount..."
  23. mount -a
  24. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement