]> arthur.barton.de Git - ocf-ra.git/blob - OCFS2_DRBD
OCFS2_DRBD: Fix order of longdesc, shortdesc, and content
[ocf-ra.git] / OCFS2_DRBD
1 #!/bin/sh
2 #
3 # OCF RA for OCFS2 on DRBD
4 #
5 # Copyright (c) 2008,2009 Barton IT-Consulting
6 # Copyright (c) 2004 SUSE LINUX AG, Lars Marowsky-BrĂ©e
7 #                    All Rights Reserved.
8 #
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of version 2 of the GNU General Public License as
11 # published by the Free Software Foundation.
12 #
13 # This program is distributed in the hope that it would be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 #
17 # Further, this software is distributed without any warranty that it is
18 # free of the rightful claim of any third person regarding infringement
19 # or the like.  Any license provided herein, whether implied or
20 # otherwise, applies only to this software file.  Patent licenses, if
21 # any, provided herein do not apply to combinations of this program with
22 # other software, or any other product whatsoever.
23 #
24 # You should have received a copy of the GNU General Public License
25 # along with this program; if not, write the Free Software Foundation,
26 # Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
27 #
28
29 # Initialization:
30 . ${OCF_ROOT}/resource.d/heartbeat/.ocf-shellfuncs
31
32 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
33
34 meta_data() {
35         cat <<END
36 <?xml version="1.0"?>
37 <!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
38 <resource-agent name="OCFS2_DRBD">
39 <version>1.5</version>
40
41 <longdesc lang="en">
42 This Resource Agent starts and stops OCFS2 file systems located on DRBD devices.
43 </longdesc>
44 <shortdesc lang="en">OCFS2 on DRBD resource agent</shortdesc>
45
46 <parameters>
47 <parameter name="drbd" unique="1">
48 <longdesc lang="en">ID of the DRBD resource</longdesc>
49 <shortdesc lang="en">ID of the DRBD resource</shortdesc>
50 <content type="string" default="" />
51 </parameter>
52 <parameter name="drbd_dev" unique="1">
53 <longdesc lang="en">DRBD device</longdesc>
54 <shortdesc lang="en">DRBD device</shortdesc>
55 <content type="string" default="" />
56 </parameter>
57 <parameter name="mountpoint" unique="1">
58 <longdesc lang="en">Mountpoint for OCFS2 filesystem</longdesc>
59 <shortdesc lang="en">Mountpoint for OCFS2 filesystem</shortdesc>
60 <content type="string" default="" />
61 </parameter>
62 <parameter name="reload_cron" unique="1">
63 <longdesc lang="en">Reload CRON configuration after mounting OCFS2 filesystem</longdesc>
64 <shortdesc lang="en">Reload CRON configuration</shortdesc>
65 <content type="boolean" default="0" />
66 </parameter>
67 </parameters>
68
69 <actions>
70 <action name="start" timeout="90" />
71 <action name="stop" timeout="90" />
72 <action name="monitor" timeout="20" interval="30" depth="0" start-delay="10" />
73 <action name="meta-data" timeout="5" />
74 <action name="verify-all" timeout="30" />
75 </actions>
76 </resource-agent>
77 END
78 }
79
80 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
81
82 ClusterFS_usage() {
83         echo "usage: $0 {start|stop|monitor|validate-all|meta-data}"
84 }
85
86 ClusterFS_start() {
87         mkdir -p "$OCF_RESKEY_mountpoint"
88         drbdadm primary "$OCF_RESKEY_drbd"
89         if [ $? -ne 0 ]; then
90                 return $OCF_ERR_GENERIC
91         fi
92         mount -t ocfs2 "$OCF_RESKEY_drbd_dev" "$OCF_RESKEY_mountpoint"
93         if [ $? -ne 0 ]; then
94                 return $OCF_ERR_GENERIC
95         fi
96         if [ "$OCF_RESKEY_reload_cron" = "1" ]; then
97                 [ -d /etc/cron.d ] && touch /etc/cron.d
98         fi
99         return $OCF_SUCCESS
100 }
101
102 ClusterFS_stop() {
103         mount | grep "$OCF_RESKEY_drbd_dev on " >/dev/null
104         if [ $? -eq 0 ]; then
105                 umount "$OCF_RESKEY_mountpoint"
106                 if [ $? -ne 0 ]; then
107                         # try harder, kill processes on this filesystem
108                         pids=$(ps ax|awk "{print \$1}"|grep -v PID)
109                         for p in $pids; do
110                                 lsof -p $p -n | grep " $OCF_RESKEY_mountpoint" \
111                                  >/dev/null 2>&1
112                                 [ $? -eq 0 ] || continue
113                                 kill $p
114                         done
115                         sleep 3
116                         pids=$(ps ax|awk "{print \$1}"|grep -v PID)
117                         for p in $pids; do
118                                 lsof -p $p -n | grep " $OCF_RESKEY_mountpoint" \
119                                  >/dev/null 2>&1
120                                 [ $? -eq 0 ] || continue
121                                 kill -9 $p
122                         done
123                         sleep 1
124                         umount "$OCF_RESKEY_mountpoint"
125                         if [ $? -ne 0 ]; then
126                                 return $OCF_ERR_GENERIC
127                         fi
128                 fi
129         fi
130         drbdadm secondary "$OCF_RESKEY_drbd"
131         if [ "$OCF_RESKEY_reload_cron" = "1" ]; then
132                 [ -d /etc/cron.d ] && touch /etc/cron.d
133         fi
134         return $OCF_SUCCESS
135 }
136
137 ClusterFS_monitor() {
138         mount | grep "$OCF_RESKEY_drbd_dev on " >/dev/null
139         if [ $? -eq 0 ]; then
140                 return $OCF_SUCCESS
141         fi
142         return $OCF_NOT_RUNNING
143 }
144
145 ClusterFS_validate() {
146         if [ -z "$OCF_RESKEY_drbd" ]; then
147                 return $OCF_ERR_ARGS
148         fi
149         if [ -z "$OCF_RESKEY_drbd_dev" ]; then
150                 return $OCF_ERR_ARGS
151         fi
152         if [ -z "$OCF_RESKEY_mountpoint" ]; then
153                 return $OCF_ERR_ARGS
154         fi
155         return $OCF_SUCCESS
156 }
157
158 case $__OCF_ACTION in
159         meta-data)
160                 meta_data
161                 exit $OCF_SUCCESS
162                 ;;
163         start)
164                 ClusterFS_start
165                 ;;
166         stop)
167                 ClusterFS_stop
168                 ;;
169         monitor)
170                 ClusterFS_monitor
171                 ;;
172         validate-all)
173                 ClusterFS_validate
174                 ;;
175         usage|help)
176                 ClusterFS_usage
177                 exit $OCF_SUCCESS
178                 ;;
179         *)
180                 ClusterFS_usage
181                 exit $OCF_ERR_UNIMPLEMENTED
182                 ;;
183 esac
184
185 rc=$?
186 ocf_log debug "${OCF_RESOURCE_INSTANCE} $__OCF_ACTION : $rc"
187 exit $rc
188
189 # -eof-