3 # Copyright (c) 2008, 2009 NTT COMWARE CORPORATION
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of version 2 of the GNU General Public License as
8 # published by the Free Software Foundation.
10 # This program is distributed in the hope that it would be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 # Further, this software is distributed without any warranty that it is
15 # free of the rightful claim of any third person regarding infringement
16 # or the like. Any license provided herein, whether implied or
17 # otherwise, applies only to this software file. Patent licenses, if
18 # any, provided herein do not apply to combinations of this program with
19 # other software, or any other product whatsoever.
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write the Free Software Foundation,
23 # Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
26 #######################################################################
29 #. ${OCF_ROOT}/resource.d/heartbeat/.ocf-shellfuncs
30 . /usr/lib/ocf/resource.d/heartbeat/.ocf-shellfuncs
32 #######################################################################
37 <!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
38 <resource-agent name="SSLProxy" version="1.0">
39 <version>1.0</version>
42 This is a SSLProxy Resource Agent.
44 <shortdesc lang="en">SSLProxy resource agent</shortdesc>
47 <parameter name="state" unique="1">
49 Location to store the resource state in.
51 <shortdesc lang="en">State file</shortdesc>
52 <content type="string" default="" />
58 <action name="start" timeout="60" />
59 <action name="stop" timeout="60" />
60 <action name="monitor" timeout="60" interval="10" depth="0" start-delay="0" />
61 <action name="meta-data" timeout="5" />
67 #######################################################################
71 usage: $0 {start|stop|monitor|meta-data}
75 ###############################
77 ###############################
83 ocf_log $MODE "[$0 ${__OCF_ACTION}] NG;return=$RET" "$@";;
87 ###############################
89 ###############################
92 ocf_log info "kill sslproxy process!"
98 if [ $RET -eq 0 ]; then
100 ocf_log info "sslproxy process stopped!"
101 return ${OCF_SUCCESS}
106 ###############################
107 # Resource Running Check Method
108 ###############################
111 RET=`ps -ef | grep "/usr/sbin/sslproxy" | grep -v grep | wc -l`
115 ###############################
116 # Get Resource Status Method
117 ###############################
119 T_ID=`/usr/sbin/sslproxyadm status | grep "TargetID" | wc -l`
120 RET=`/usr/sbin/sslproxyadm status | grep "Starting. PID =" | wc -l`
121 if [ $RET -eq 0 ]; then
122 MSG="sslproxy status ERROR!."
123 outputLog err ${OCF_ERR_GENERIC} ${MSG}
124 return ${OCF_ERR_GENERIC}
125 elif [ $RET -lt $T_ID ]; then
126 MSG="sslproxy status ERROR!(Target is insufficient)."
127 outputLog err ${OCF_ERR_GENERIC} ${MSG}
128 return ${OCF_ERR_GENERIC}
129 # elif [ $RET -gt $T_ID ]; then
130 # MSG="sslproxy status ERROR!(Target_ID exceeds a set value)."
131 # outputLog err ${OCF_ERR_GENERIC} ${MSG}
132 # return ${OCF_ERR_GENERIC}
134 return ${OCF_SUCCESS}
137 ###############################
138 # Get Resource Monitor Method
139 ###############################
143 if [ $RET -eq 0 ]; then
144 MSG="sslproxy is not running."
145 outputLog err ${OCF_NOT_RUNNING} ${MSG}
146 return ${OCF_NOT_RUNNING}
148 # sslproxy is running
150 if [ $? -eq ${OCF_SUCCESS} ]; then
152 return ${OCF_SUCCESS}
157 MSG="sslproxy does not work."
158 outputLog err ${OCF_ERR_GENERIC} ${MSG}
159 return ${OCF_ERR_GENERIC}
162 ###############################
163 # Resource start Method
164 ###############################
166 ocf_log info "sslproxy is starting ..."
169 if [ $RET -eq ${OCF_SUCCESS} ]; then
170 ocf_log info "sslproxy is already running."
173 /usr/sbin/sslproxyadm start > /dev/null 2>&1
175 if [ $RET -ne 0 ];then
176 MSG="sslproxy start error!."
177 outputLog err ${OCF_ERR_GENERIC} $MSG
178 return ${OCF_ERR_GENERIC}
184 if [ $RET -ne 0 ]; then
185 # sslproxy is running
186 ocf_log info "sslproxy starts."
187 return ${OCF_SUCCESS}
193 ###############################
194 # Resource stop Method
195 ###############################
197 ocf_log info "sslproxy is stopping ..."
200 if [ $RET -eq 0 ]; then
201 ocf_log info "sslproxy stopped."
202 return ${OCF_SUCCESS}
204 /usr/sbin/sslproxyadm stop > /dev/null 2>&1
206 while [ $count -le 10 ]
210 if [ $RET -eq 0 ]; then
211 ocf_log info "sslproxy stopped."
212 return ${OCF_SUCCESS}
214 $count=`expr $count + 1`
224 case $__OCF_ACTION in
227 start) sslproxy_start ;;
228 stop) sslproxy_stop ;;
229 monitor) sslproxy_monitor ;;
230 usage|help) sslproxy_usage
234 exit $OCF_ERR_UNIMPLEMENTED
238 ocf_log debug "${OCF_RESOURCE_INSTANCE} $__OCF_ACTION : $rc"