]> git.pld-linux.org Git - packages/ocfs2-tools.git/blob - ocfs2.init
- added, needs PLDification
[packages/ocfs2-tools.git] / ocfs2.init
1 #! /bin/bash
2 # Copyright (c) 2005 Oracle
3 # All rights reserved.
4 #
5 # chkconfig: 2345 25 19
6 # description: Mount OCFS2 volumes at boot.
7 #
8 ### BEGIN INIT INFO
9 # Provides: ocfs2
10 # Required-Start: $network o2cb
11 # Required-Stop: 
12 # X-UnitedLinux-Should-Start:
13 # X-UnitedLinux-Should-Stop:
14 # Default-Start:  2 3 5
15 # Default-Stop:
16 # Description:  Mount OCFS2 volumes at boot.
17 ### END INIT INFO
18
19 if [ -f /etc/redhat-release ]
20 then
21 . /etc/init.d/functions
22
23 init_status()
24 {
25     return 0
26 }
27
28 success_status()
29 {
30     success
31     echo
32 }
33
34 failure_status()
35 {
36     failure $1
37     echo
38 }
39
40 exit_status()
41 {
42     exit $?
43 }
44 elif [ -f /etc/SuSE-release -o -f /etc/UnitedLinux-release ]
45 then
46 . /etc/rc.status
47
48 init_status()
49 {
50     rc_reset
51 }
52
53 success_status()
54 {
55     /bin/true
56     rc_status -v
57 }
58
59 failure_status()
60 {
61     /bin/false
62     rc_status -v
63 }
64
65 exit_status()
66 {
67     rc_exit
68 }
69 else
70 init_status()
71 {
72     return 0
73 }
74
75 success_status()
76 {
77     echo "OK"
78     return 0
79 }
80
81 failure_status()
82 {
83     echo "Failed"
84     return 0
85 }
86
87 exit_status()
88 {
89     exit $?
90 }
91 fi
92
93 ocfs2mounts()
94 {
95     LC_ALL=C awk '$3 == "ocfs2"  { print $2 }' /proc/mounts
96 }
97
98 ocfs2fstab()
99 {
100     LC_ALL=C awk '!/^#/ && $3 == "ocfs2" && $4 !~ /noauto/ { print $2 }' /etc/fstab
101 }
102
103 init_status
104
105 FUSER=`which fuser`
106
107 case "$1" in
108     start|reload)
109         if [ -n "`ocfs2fstab`" ] ; then
110             echo -n "Starting Oracle Cluster File System (OCFS2) "
111             mount -at ocfs2
112             if [ $? = 0 ]
113             then
114                 success_status
115             else
116                 failure_status "Unable to mount OCFS2 filesystems"
117             fi
118         fi
119         ;;
120     stop)
121         echo -n "Stopping Oracle Cluster File System (OCFS2) "
122         remaining="`ocfs2mounts`"
123         sig=
124         retry=3
125         while [ -n "$remaining" -a "$retry" -gt 0 ]
126         do
127             if [ "$retry" -lt 3 ]; then
128                 echo -n "Retry stopping Oracle Cluster File System (OCFS2) "
129             fi
130             umount -a -t ocfs2 2>/dev/null
131             sleep 1
132
133             remaining="`ocfs2mounts`"
134             [ -z "$remaining" ] && break
135             failure_status "Unable to unmount OCFS2 filesystems"
136
137             $FUSER -km $sig $remaining >/dev/null
138             sleep 5
139             retry=$(($retry - 1))
140             sig=-9
141         done
142         [ -z "$remaining" ] && success_status
143         ;;
144     restart|force-reload)
145         $0 stop
146         $0 start
147         ;;
148     status)
149         if [ -f /proc/mounts ] ; then
150             [ -n "`ocfs2fstab`" ] && {
151                 echo "Configured OCFS2 mountpoints: " `ocfs2fstab`
152             }
153
154             [ -n "`ocfs2mounts`" ] && {
155                 echo "Active OCFS2 mountpoints: " `ocfs2mounts`
156             }
157         else
158             echo -n "Checking OCFS2 mountpoints: "
159             failure_status
160         fi
161         ;;
162     try-restart|condrestart)
163         $0 status
164         if test $? = 0; then
165             $0 restart
166         fi
167         ;;
168     *)
169         echo "Usage: $0 {start|stop|status|reload|force-reload|restart|try-restart}"
170         exit 1
171 esac
172
173 exit_status
This page took 0.041421 seconds and 3 git commands to generate.