]> git.pld-linux.org Git - packages/ocfs2-tools.git/blob - ocfs2.init
- release 2
[packages/ocfs2-tools.git] / ocfs2.init
1 #!/bin/sh
2 # Copyright (c) 2005 Oracle
3 # All rights reserved.
4 #
5 # chkconfig:    2345 25 19
6 # description:  Mount OCFS2 volumes at boot.
7 #
8
9 # Source function library
10 . /etc/rc.d/init.d/functions
11
12 # Get network config
13 . /etc/sysconfig/network
14
15 # Get service config
16 [ -f /etc/sysconfig/ocfs2 ] && . /etc/sysconfig/ocfs2
17
18 # Check that networking is up.
19 if is_yes "${NETWORKING}"; then
20         if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
21                 msg_network_down OCFS2
22         exit 1
23         fi
24 else
25         exit 0
26 fi
27
28 success_status()
29 {
30     success
31     echo
32 }
33
34 failure_status()
35 {
36     failure $1
37     echo
38 }
39
40 ocfs2mounts()
41 {
42     LC_ALL=C awk '$3 == "ocfs2"  { print $2 }' /proc/mounts
43 }
44
45 ocfs2fstab()
46 {
47     LC_ALL=C awk '!/^#/ && $3 == "ocfs2" && $4 !~ /noauto/ { print $2 }' /etc/fstab
48 }
49
50 RETVAL=0
51
52 case "$1" in
53     start|reload)
54         if [ ! -f /var/lock/subsys/ocfs2 ]; then
55                 if [ -n "`ocfs2fstab`" ] ; then
56                     run_cmd "Mounting OCFS2 filesystems" mount -a -t ocfs2
57                     touch /var/lock/subsys/ocfs2
58         fi
59         else
60                 msg_already_running "OCFS2 filesystems"
61         fi
62         ;;
63     stop)
64         show "Oracle Cluster File System (OCFS2) "
65         busy
66         remaining="`ocfs2mounts`"
67         sig=
68         retry=3
69         while [ -n "$remaining" -a "$retry" -gt 0 ]
70         do
71             if [ "$retry" -lt 3 ]; then
72                 echo -n "Retry stopping Oracle Cluster File System (OCFS2) "
73             fi
74             umount -a -t ocfs2 > /dev/null 2>&1
75             sleep 1
76
77             remaining="`ocfs2mounts`"
78             [ -z "$remaining" ] && break
79             failure_status "Unable to unmount OCFS2 filesystems"
80
81             /sbin/fuser -k -m $sig $remaining
82             sleep 5
83             retry=$(($retry - 1))
84             sig=-9
85         done
86         [ -z "$remaining" ] && ok
87         rm -f /var/lock/subsys/ocfs2
88         ;;
89     restart|force-reload)
90         $0 stop
91         $0 start
92         ;;
93     status)
94         if [ -f /proc/mounts ] ; then
95             [ -n "`ocfs2fstab`" ] && {
96                 echo "Configured OCFS2 mountpoints: " `ocfs2fstab`
97             }
98
99             [ -n "`ocfs2mounts`" ] && {
100                 echo "Active OCFS2 mountpoints: " `ocfs2mounts`
101             }
102         else
103             echo -n "Checking OCFS2 mountpoints: "
104             failure_status
105         fi
106         ;;
107     try-restart|condrestart)
108         $0 status
109         if test $? = 0; then
110             $0 restart
111         fi
112         ;;
113     *)
114         msg_usage "$0 {start|stop|status|reload|force-reload|restart|try-restart}"
115         exit 3
116 esac
117
118 exit $RETVAL
This page took 0.060674 seconds and 3 git commands to generate.