blob: c08597e725a4f07baf8ac6e292b9b461ab37fcf7 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001#!/bin/sh
Patrick Williams45852732022-04-02 08:58:32 -05002#
3# SPDX-License-Identifier: GPL-2.0-only
4#
5
Patrick Williamsc124f4f2015-09-15 14:41:29 -05006### BEGIN INIT INFO
7# Provides: mountnfs
8# Required-Start: $local_fs $network $rpcbind
9# Required-Stop:
10# Default-Start: S
11# Default-Stop:
12### END INIT INFO
13
14#
15# Run in a subshell because of I/O redirection.
16#
17test -f /etc/fstab && (
18
19#
20# Read through fstab line by line. If it is NFS, set the flag
21# for mounting NFS filesystems. If any NFS partition is found and it
22# not mounted with the nolock option, we start the rpcbind.
23#
24rpcbind=no
25mount_nfs=no
26mount_smb=no
27mount_ncp=no
28mount_cifs=no
29while read device mountpt fstype options
30do
31 case "$device" in
32 ""|\#*)
33 continue
34 ;;
35 esac
36
37 case "$options" in
38 *noauto*)
39 continue
40 ;;
41 esac
42
43 if test "$fstype" = nfs
44 then
45 mount_nfs=yes
46 case "$options" in
47 *nolock*)
48 ;;
49 *)
50 rpcbind=yes
51 ;;
52 esac
53 fi
54 if test "$fstype" = smbfs
55 then
56 mount_smb=yes
57 fi
58 if test "$fstype" = ncpfs
59 then
60 mount_ncp=yes
61 fi
62 if test "$fstype" = cifs
63 then
64 mount_cifs=yes
65 fi
66done
67
68exec 0>&1
69
70if test "$rpcbind" = yes
71then
72 if test -x /usr/sbin/rpcbind
73 then
Brad Bishopd5ae7d92018-06-14 09:52:03 -070074 service rpcbind status > /dev/null
75 if [ $? != 0 ]; then
76 echo -n "Starting rpcbind..."
77 start-stop-daemon --start --quiet --exec /usr/sbin/rpcbind
78 sleep 2
79 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -050080 fi
81fi
82
83if test "$mount_nfs" = yes || test "$mount_smb" = yes || test "$mount_ncp" = yes || test "$mount_cifs" = yes
84then
85 echo "Mounting remote filesystems..."
86 test "$mount_nfs" = yes && mount -a -t nfs
87 test "$mount_smb" = yes && mount -a -t smbfs
88 test "$mount_ncp" = yes && mount -a -t ncpfs
89 test "$mount_cifs" = yes && mount -a -t cifs
90fi
91
92) < /etc/fstab
93
94: exit 0
95