mountnfs.sh 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #!/bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides: mountnfs
  4. # Required-Start: $local_fs $network $rpcbind
  5. # Required-Stop:
  6. # Default-Start: S
  7. # Default-Stop:
  8. ### END INIT INFO
  9. #
  10. # Run in a subshell because of I/O redirection.
  11. #
  12. test -f /etc/fstab && (
  13. #
  14. # Read through fstab line by line. If it is NFS, set the flag
  15. # for mounting NFS filesystems. If any NFS partition is found and it
  16. # not mounted with the nolock option, we start the rpcbind.
  17. #
  18. rpcbind=no
  19. mount_nfs=no
  20. mount_smb=no
  21. mount_ncp=no
  22. mount_cifs=no
  23. while read device mountpt fstype options
  24. do
  25. case "$device" in
  26. ""|\#*)
  27. continue
  28. ;;
  29. esac
  30. case "$options" in
  31. *noauto*)
  32. continue
  33. ;;
  34. esac
  35. if test "$fstype" = nfs
  36. then
  37. mount_nfs=yes
  38. case "$options" in
  39. *nolock*)
  40. ;;
  41. *)
  42. rpcbind=yes
  43. ;;
  44. esac
  45. fi
  46. if test "$fstype" = smbfs
  47. then
  48. mount_smb=yes
  49. fi
  50. if test "$fstype" = ncpfs
  51. then
  52. mount_ncp=yes
  53. fi
  54. if test "$fstype" = cifs
  55. then
  56. mount_cifs=yes
  57. fi
  58. done
  59. exec 0>&1
  60. if test "$rpcbind" = yes
  61. then
  62. if test -x /usr/sbin/rpcbind
  63. then
  64. echo -n "Starting rpcbind... "
  65. start-stop-daemon --start --quiet --exec /usr/sbin/rpcbind
  66. sleep 2
  67. fi
  68. fi
  69. if test "$mount_nfs" = yes || test "$mount_smb" = yes || test "$mount_ncp" = yes || test "$mount_cifs" = yes
  70. then
  71. echo "Mounting remote filesystems..."
  72. test "$mount_nfs" = yes && mount -a -t nfs
  73. test "$mount_smb" = yes && mount -a -t smbfs
  74. test "$mount_ncp" = yes && mount -a -t ncpfs
  75. test "$mount_cifs" = yes && mount -a -t cifs
  76. fi
  77. ) < /etc/fstab
  78. : exit 0