source: bootscripts-standard/bootscripts/cblfs/init.d/netfs@ 2167cfe

Last change on this file since 2167cfe was 2167cfe, checked in by William Harrington <kb0iic@…>, 11 years ago

bootscripts are the scripts used for the sysvinit book.

  • Property mode set to 100644
File size: 2.5 KB
RevLine 
[2167cfe]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# netfs script written by Nathan Coulson - conathan@conet.dyndns.org
7# and by DJ Lucas - dj@lucasit.com
8
9#$LastChangedBy: bdubbs $
10#$Date: 2006-04-11 02:14:41 -0500 (Tue, 11 Apr 2006) $
11
12. /etc/sysconfig/rc
13. $rc_functions
14
15case "$1" in
16 start)
17 # The following line mounts all entries in fstab that
18 # have the _netdev option. This is required for network
19 # filesystems to be mounted at boot time.
20 boot_mesg "Mounting network volumes..."
21 /bin/mount -a -O _netdev
22 evaluate_retval
23 ;;
24
25 stop)
26 boot_mesg -n "Unmounting network volumes..."
27
28 # The following line obtains a list from the output of
29 # mount for all netfs types and anything that was
30 # mounted with the _netdev option.
31 NETMOUNTS=`/bin/mount \
32 | /bin/grep '_netdev\|smbfs\|ncpfs\|coda\|nfs' \
33 | /usr/bin/cut -d " " -f 3 | /bin/sed ':a;$!N;s/\n/ /;ta'`
34
35 # Check to see if anything was listed from above
36 # (see if anything is actually needs to be unmounted)
37 if [ x"$NETMOUNTS" != x ]
38 then
39 # There is something mounted
40 # terminate the echo -n above
41 echo ""
42
43 # Try and stop processes the nice way
44 # (probably won't work in most cases)
45 /bin/fuser -SIGTERM -km $NETMOUNTS > /dev/null
46
47 # Check and see if it found anything. If it
48 # did, then give 3 seconds for things to exit
49 # the nice way before killing them off.
50 # This one will work all of the time!
51 if [ $? = 0 ]
52 then
53 /bin/sleep 3
54 /bin/fuser -km $NETMOUNTS > /dev/null
55 fi
56
57 # We now need to unmount all network filesystems.
58 # We will do this with two umount commands to allow
59 # for broken behavior of smbmount, and also to make
60 # certain that netmounts without the _netdev option
61 # will still get unmounted.
62 /bin/umount -a -O _netdev
63 # save the retval
64 if [ $? != 0 ]
65 then
66 NERRVAL=1
67 fi
68
69 # Now catch the rest of the network filesystems
70 # by fstype. This list can be extended later as
71 # more network filesystems are supported by mount.
72 /bin/umount -a -t coda,ncpfs,nfs,smbfs
73 if [ $? = 0 ]
74 then
75 [ -z $NERRVAL ]
76 evaluate_retval
77 else
78 # make certain that we return an error
79 /bin/false
80 evaluate_retval
81 fi
82 else
83 # There is nothing mounted
84 boot_mesg "No network volumes mounted!"
85 # print a nice '[ OK ]' message
86 echo_ok
87 fi
88 ;;
89
90*)
91 echo "Usage: $0 {start|stop}"
92 exit 1
93 ;;
94esac
95
96# End $rc_base/init.d/netfs
Note: See TracBrowser for help on using the repository browser.