Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 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 | # |
| 11 | # Run in a subshell because of I/O redirection. |
| 12 | # |
| 13 | test -f /etc/fstab && ( |
| 14 | |
| 15 | # |
| 16 | # Read through fstab line by line. If it is NFS, set the flag |
| 17 | # for mounting NFS filesystems. If any NFS partition is found and it |
| 18 | # not mounted with the nolock option, we start the rpcbind. |
| 19 | # |
| 20 | rpcbind=no |
| 21 | mount_nfs=no |
| 22 | mount_smb=no |
| 23 | mount_ncp=no |
| 24 | mount_cifs=no |
| 25 | while read device mountpt fstype options |
| 26 | do |
| 27 | case "$device" in |
| 28 | ""|\#*) |
| 29 | continue |
| 30 | ;; |
| 31 | esac |
| 32 | |
| 33 | case "$options" in |
| 34 | *noauto*) |
| 35 | continue |
| 36 | ;; |
| 37 | esac |
| 38 | |
| 39 | if test "$fstype" = nfs |
| 40 | then |
| 41 | mount_nfs=yes |
| 42 | case "$options" in |
| 43 | *nolock*) |
| 44 | ;; |
| 45 | *) |
| 46 | rpcbind=yes |
| 47 | ;; |
| 48 | esac |
| 49 | fi |
| 50 | if test "$fstype" = smbfs |
| 51 | then |
| 52 | mount_smb=yes |
| 53 | fi |
| 54 | if test "$fstype" = ncpfs |
| 55 | then |
| 56 | mount_ncp=yes |
| 57 | fi |
| 58 | if test "$fstype" = cifs |
| 59 | then |
| 60 | mount_cifs=yes |
| 61 | fi |
| 62 | done |
| 63 | |
| 64 | exec 0>&1 |
| 65 | |
| 66 | if test "$rpcbind" = yes |
| 67 | then |
| 68 | if test -x /usr/sbin/rpcbind |
| 69 | then |
| 70 | echo -n "Starting rpcbind... " |
| 71 | start-stop-daemon --start --quiet --exec /usr/sbin/rpcbind |
| 72 | sleep 2 |
| 73 | fi |
| 74 | fi |
| 75 | |
| 76 | if test "$mount_nfs" = yes || test "$mount_smb" = yes || test "$mount_ncp" = yes || test "$mount_cifs" = yes |
| 77 | then |
| 78 | echo "Mounting remote filesystems..." |
| 79 | test "$mount_nfs" = yes && mount -a -t nfs |
| 80 | test "$mount_smb" = yes && mount -a -t smbfs |
| 81 | test "$mount_ncp" = yes && mount -a -t ncpfs |
| 82 | test "$mount_cifs" = yes && mount -a -t cifs |
| 83 | fi |
| 84 | |
| 85 | ) < /etc/fstab |
| 86 | |
| 87 | : exit 0 |
| 88 | |