3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of version 2 of the GNU General Public License as
5 # published by the Free Software Foundation.
7 # This program is distributed in the hope that it would be useful, but
8 # WITHOUT ANY WARRANTY; without even the implied warranty of
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 # Further, this software is distributed without any warranty that it is
12 # free of the rightful claim of any third person regarding infringement
13 # or the like. Any license provided herein, whether implied or
14 # otherwise, applies only to this software file. Patent licenses, if
15 # any, provided herein do not apply to combinations of this program with
16 # other software, or any other product whatsoever.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write the Free Software Foundation,
20 # Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
23 #######################################################################
26 #. ${OCF_ROOT}/resource.d/heartbeat/.ocf-shellfuncs
27 . /usr/lib/ocf/resource.d/heartbeat/.ocf-shellfuncs
29 #######################################################################
34 <!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
35 <resource-agent name="SSLProxy" version="1.0">
36 <version>1.0</version>
39 This is a SSLProxy Resource Agent.
41 <shortdesc lang="en">SSLProxy resource agent</shortdesc>
44 <parameter name="state" unique="1">
46 Location to store the resource state in.
48 <shortdesc lang="en">State file</shortdesc>
49 <content type="string" default="" />
55 <action name="start" timeout="60" />
56 <action name="stop" timeout="60" />
57 <action name="monitor" timeout="60" interval="10" depth="0" start-delay="0" />
58 <action name="meta-data" timeout="5" />
64 #######################################################################
68 usage: $0 {start|stop|monitor|meta-data}
72 ###############################
74 ###############################
80 ocf_log $MODE "[$0 ${__OCF_ACTION}] NG;return=$RET" "$@";;
84 ###############################
86 ###############################
89 ocf_log info "kill sslproxy process!"
95 if [ $RET -eq 0 ]; then
97 ocf_log info "sslproxy process stopped!"
103 ###############################
104 # Resource Running Check Method
105 ###############################
108 RET=`pgrep -fox '/usr/sbin/sslproxy .*' | wc -l`
112 ###############################
113 # Get Resource Status Method
114 ###############################
116 T_ID=`/usr/sbin/sslproxyadm status | grep "TargetID" | wc -l`
117 RET=`/usr/sbin/sslproxyadm status | grep "Starting. PID =" | wc -l`
118 if [ $RET -eq 0 ]; then
119 MSG="sslproxy status ERROR!."
120 outputLog err ${OCF_ERR_GENERIC} ${MSG}
121 return ${OCF_ERR_GENERIC}
122 elif [ $RET -lt $T_ID ]; then
123 MSG="sslproxy status ERROR!(Target is insufficient)."
124 outputLog err ${OCF_ERR_GENERIC} ${MSG}
125 return ${OCF_ERR_GENERIC}
126 # elif [ $RET -gt $T_ID ]; then
127 # MSG="sslproxy status ERROR!(Target_ID exceeds a set value)."
128 # outputLog err ${OCF_ERR_GENERIC} ${MSG}
129 # return ${OCF_ERR_GENERIC}
131 return ${OCF_SUCCESS}
134 ###############################
135 # Get Resource Monitor Method
136 ###############################
140 if [ $RET -eq 0 ]; then
141 MSG="sslproxy is not running."
142 outputLog err ${OCF_NOT_RUNNING} ${MSG}
143 return ${OCF_NOT_RUNNING}
145 # sslproxy is running
147 if [ $? -eq ${OCF_SUCCESS} ]; then
149 return ${OCF_SUCCESS}
154 MSG="sslproxy does not work."
155 outputLog err ${OCF_ERR_GENERIC} ${MSG}
156 return ${OCF_ERR_GENERIC}
159 ###############################
160 # Resource start Method
161 ###############################
163 ocf_log info "sslproxy is starting ..."
166 if [ $RET -eq ${OCF_SUCCESS} ]; then
167 ocf_log info "sslproxy is already running."
170 /usr/sbin/sslproxyadm start > /dev/null 2>&1
172 if [ $RET -ne 0 ];then
173 MSG="sslproxy start error!."
174 outputLog err ${OCF_ERR_GENERIC} $MSG
175 return ${OCF_ERR_GENERIC}
181 if [ $RET -ne 0 ]; then
182 # sslproxy is running
183 ocf_log info "sslproxy starts."
184 return ${OCF_SUCCESS}
190 ###############################
191 # Resource stop Method
192 ###############################
194 ocf_log info "sslproxy is stopping ..."
197 if [ $RET -eq 0 ]; then
198 ocf_log info "sslproxy stopped."
199 return ${OCF_SUCCESS}
201 /usr/sbin/sslproxyadm stop > /dev/null 2>&1
203 while [ $count -le 10 ]
207 if [ $RET -eq 0 ]; then
208 ocf_log info "sslproxy stopped."
209 return ${OCF_SUCCESS}
211 $count=`expr $count + 1`
221 case $__OCF_ACTION in
224 start) sslproxy_start ;;
225 stop) sslproxy_stop ;;
226 monitor) sslproxy_monitor ;;
227 usage|help) sslproxy_usage
231 exit $OCF_ERR_UNIMPLEMENTED
235 ocf_log debug "${OCF_RESOURCE_INSTANCE} $__OCF_ACTION : $rc"