Advertisement
Guest User

Untitled

a guest
Jan 13th, 2015
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # This file must be executable to work! chmod 755!
  4.  
  5. # Look at what a host is exporting to determine what we can mount.
  6. # This is very simple, but it appears to work surprisingly well
  7.  
  8. key="$1"
  9.  
  10. # add "nosymlink" here if you want to suppress symlinking local filesystems
  11. # add "nonstrict" to make it OK for some filesystems to not mount
  12. # choose one of the two lines below depending on the NFS version in your
  13. # environment
  14. opts="-fstype=nfs,hard,intr,nodev,nosuid"
  15. #opts="-fstype=nfs4,hard,intr,nodev,nosuid,async"
  16.  
  17. # Showmount comes in a number of names and varieties. "showmount" is
  18. # typically an older version which accepts the '--no-headers' flag
  19. # but ignores it. "kshowmount" is the newer version installed with knfsd,
  20. # which both accepts and acts on the '--no-headers' flag.
  21. #SHOWMOUNT="kshowmount --no-headers -e $key"
  22. #SHOWMOUNT="showmount -e $key | tail -n +2"
  23.  
  24. for P in /bin /sbin /usr/bin /usr/sbin
  25. do
  26. for M in showmount kshowmount
  27. do
  28. if [ -x $P/$M ]
  29. then
  30. SMNT=$P/$M
  31. break
  32. fi
  33. done
  34. done
  35.  
  36. [ -x $SMNT ] || exit 1
  37.  
  38. # Newer distributions get this right
  39. SHOWMOUNT="$SMNT --no-headers -e $key"
  40.  
  41. $SHOWMOUNT | LC_ALL=C cut -d' ' -f1 | LC_ALL=C sort -u | \
  42. awk -v key="$key" -v opts="$opts" -- '
  43. BEGIN { ORS=""; first=1 }
  44. { if (first) { print opts; first=0 }; print " \\\n\t" $1, key ":" $1 }
  45. END { if (!first) print "\n"; else exit 1 }
  46. ' | sed 's/#/\\#/g'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement