1 | #!/bin/bash
|
---|
2 | # Begin $rc_base/init.d/netfs
|
---|
3 |
|
---|
4 | # Based on sysklogd script from LFS-3.1 and earlier.
|
---|
5 | # Rewritten by Gerard Beekmans - gerard@linuxfromscratch.org
|
---|
6 |
|
---|
7 | source /etc/sysconfig/rc
|
---|
8 | source $rc_functions
|
---|
9 |
|
---|
10 | case "$1" in
|
---|
11 | start)
|
---|
12 | echo "Mounting network volumes..."
|
---|
13 | mount -at nfs,sbmfs,coda,ncpfs
|
---|
14 | evaluate_retval
|
---|
15 | ;;
|
---|
16 |
|
---|
17 |
|
---|
18 | stop)
|
---|
19 | # The following variables NFSMOUNTS, SMBMOUNTS, CODAMOUNTS
|
---|
20 | # and NCPMOUNTS determine what is actually printed to the
|
---|
21 | # screen. If there are no mounts of a given FS in the
|
---|
22 | # /etc/mtab file, then no message is needed or displayed.
|
---|
23 | # This makes the stop portion of the script generic for BLFS.
|
---|
24 |
|
---|
25 | NFSMOUNTS=$(awk 'BEGIN { ORS=" "} $3 ~ /nfs/ { print $2 }' \
|
---|
26 | /etc/mtab)
|
---|
27 | SMBMOUNTS=$(awk 'BEGIN { ORS=" "} $3 ~ /smbfs/ { print $2 }' \
|
---|
28 | /etc/mtab)
|
---|
29 | CODAMOUNTS=$(awk 'BEGIN { ORS=" "} $3 ~ /coda/ { print $2 }' \
|
---|
30 | /etc/mtab)
|
---|
31 | NCPMOUNTS=$(awk 'BEGIN { ORS=" "} $3 ~ /ncpfs/ { print $2 }' \
|
---|
32 | /etc/mtab)
|
---|
33 |
|
---|
34 | if [ "$NFSMOUNTS" != "" ]
|
---|
35 | then
|
---|
36 | echo "Unmounting NFS volumes..."
|
---|
37 | fuser -km $NFSMOUNTS >> /dev/null
|
---|
38 | umount $NFSMOUNTS >> /dev/null
|
---|
39 | evaluate_retval
|
---|
40 | fi
|
---|
41 |
|
---|
42 | if [ "$SMBMOUNTS" != "" ]
|
---|
43 | then
|
---|
44 | echo "Unmounting Samba shares..."
|
---|
45 | fusrer -km $SMBMOUNTS >> /dev/null
|
---|
46 | umount $SMBMOUNTS >> /dev/null
|
---|
47 | evaluate_retval
|
---|
48 | fi
|
---|
49 |
|
---|
50 | if [ "$CODAMOUNTS" != "" ]
|
---|
51 | then
|
---|
52 | echo "Unmounting Coda volumes..."
|
---|
53 | fuser -km $CODAMOUNTS >> /dev/null
|
---|
54 | umount $CODAMOUNTS /dev/null
|
---|
55 | evaluate_retval
|
---|
56 | fi
|
---|
57 |
|
---|
58 | if [ "$NCPMOUNTS" != "" ]
|
---|
59 | then
|
---|
60 | echo "Unmounting Netware volumes..."
|
---|
61 | fuser -km $NCPMOUNTS >> /dev/null
|
---|
62 | umount $NCPMOUNTS /dev/null
|
---|
63 | evaluate_retval
|
---|
64 | fi
|
---|
65 |
|
---|
66 | # The following list of if-then's prints a message onscreen,
|
---|
67 | # so you know the script ran when no netfs's are mounted.
|
---|
68 |
|
---|
69 | if [ "$NFSMOUNTS" == "" ]
|
---|
70 | then
|
---|
71 | if [ "$SMBMOUNTS" == "" ]
|
---|
72 | then
|
---|
73 | if [ "$CODAMOUNTS" == "" ]
|
---|
74 | then
|
---|
75 | if [ "$NCPMOUNTS" == "" ]
|
---|
76 | then
|
---|
77 | echo "Unmounting network volumes...No network volumes mounted!"
|
---|
78 | evaluate_retval
|
---|
79 | fi
|
---|
80 | fi
|
---|
81 | fi
|
---|
82 | fi
|
---|
83 | ;;
|
---|
84 |
|
---|
85 | *)
|
---|
86 | echo "Usage: $0 {start|stop}"
|
---|
87 | exit 1
|
---|
88 | ;;
|
---|
89 | esac
|
---|
90 |
|
---|
91 | # End $rc_base/init.d/netfs
|
---|
92 |
|
---|