3
# Copyright (C) 1997-2003 Sistina Software, Inc. All rights reserved.
4
# Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
6
# This program is free software; you can redistribute it and/or
7
# modify it under the terms of the GNU General Public License
8
# as published by the Free Software Foundation; either version 2
9
# of the License, or (at your option) any later version.
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU General Public License for more details.
16
# You should have received a copy of the GNU General Public License
17
# along with this program; if not, write to the Free Software
18
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21
declare RA_COMMON_pid_dir=/var/run/cluster
22
declare RA_COMMON_conf_dir=@CONFDIR@
27
generate_configTemplate()
31
# "$1" was created from the "$2"
33
# This template configuration was automatically generated, and will be
34
# automatically regenerated if removed. Once this file has been altered,
35
# automatic re-generation will stop. Remember to copy this file to all
36
# other cluster members after making changes, or your service will not
42
generate_configTemplateXML()
46
"$1" was created from the "$2"
48
This template configuration was automatically generated, and will be
49
automatically regenerated if removed. Once this file has been altered,
50
automatic re-generation will stop. Remember to copy this file to all
51
other cluster members after making changes, or your service will not
59
declare sha1line="# rgmanager-sha1 $(sha1sum "$1")"
60
echo $sha1line >> "$1"
65
declare sha1line="<!--# rgmanager-sha1 $(sha1sum "$1")-->"
66
echo $sha1line >> "$1"
71
declare sha1_new sha1_old
74
ocf_log debug "Checking: SHA1 checksum of config file $oldFile"
76
sha1_new=`cat "$oldFile" | grep -v "# rgmanager-sha1" | sha1sum | sed 's/^\([a-z0-9]\+\) .*$/\1/'`
77
sha1_old=`tail -n 1 "$oldFile" | sed 's/^\(<!--\)\?# rgmanager-sha1 \(.*\)$/\2/' | sed 's/^\([a-z0-9]\+\) .*$/\1/'`
79
if [ "$sha1_new" = "$sha1_old" ]; then
80
ocf_log debug "Checking: SHA1 checksum > succeed"
83
ocf_log debug "Checking: SHA1 checksum > failed - file changed"
96
[ -n "$1" ] || return $FAIL
100
outp=$(ccs_tool query "$key" 2>&1)
101
if [ $? -ne 0 ]; then
102
if [[ "$outp" =~ "Query failed: Invalid argument" ]]; then
103
# This usually means that element does not exist
104
# e.g. when checking for IP address
108
if [ "$outp" = "${outp/No data available/}" ] || [ "$outp" = "${outp/Operation not permitted/}" ]; then
109
ocf_log err "$outp ($key)"
113
# no real error, just no data available
123
# Build a list of service IP keys; traverse refs if necessary
124
# Usage: get_service_ip_keys desc serviceName
126
get_service_ip_keys()
134
# Find service-local IP keys
138
key="/cluster/rm/service[@name=\"$svc\"]/ip[$x]"
143
outp=$(ccs_get "$key/@address")
144
if [ $? -ne 0 ]; then
151
if [ -z "$outp" ]; then
152
outp=$(ccs_get "$key/@ref")
153
if [ $? -ne 0 ]; then
156
key="/cluster/rm/resources/ip[@address=\"$outp\"]"
159
if [ -z "$outp" ]; then
163
#ocf_log debug "IP $outp found @ $key"
171
ocf_log debug "$y IP addresses found for $svc/$OCF_RESKEY_name"
178
declare ipaddrs ipaddr
181
while [ -n "${ip_keys[$x]}" ]; do
182
ipaddr=$(ccs_get "${ip_keys[$x]}/@address")
183
if [ -z "$ipaddr" ]; then
188
iponly=`echo $ipaddr | sed 's/\/.*//'`
189
ipaddrs="$ipaddrs $iponly"
196
generate_name_for_pid_file()
198
declare filename=$(basename $0)
200
echo "$RA_COMMON_pid_dir/$(basename $0 | sed 's/^\(.*\)\..*/\1/')/$OCF_RESOURCE_INSTANCE.pid"
205
generate_name_for_pid_dir()
207
declare filename=$(basename $0)
209
echo "$RA_COMMON_pid_dir/$(basename $0 | sed 's/^\(.*\)\..*/\1/')/$OCF_RESOURCE_INSTANCE"
214
generate_name_for_conf_dir()
216
declare filename=$(basename $0)
218
echo "$RA_COMMON_conf_dir/$(basename $0 | sed 's/^\(.*\)\..*/\1/')/$OCF_RESOURCE_INSTANCE"
223
create_pid_directory()
225
declare program_name="$(basename $0 | sed 's/^\(.*\)\..*/\1/')"
226
declare dirname="$RA_COMMON_pid_dir/$program_name"
228
if [ -d "$dirname" ]; then
232
chmod 711 "$RA_COMMON_pid_dir"
235
if [ "$program_name" = "mysql" ]; then
236
chown mysql.root "$dirname"
237
elif [ "$program_name" = "tomcat-5" ]; then
238
chown tomcat.root "$dirname"
244
create_conf_directory()
248
if [ -d "$dirname" ]; then
258
declare pid_file="$1"
260
if [ -z "$pid_file" ]; then
264
if [ ! -e "$pid_file" ]; then
268
## if PID file is empty then it should be safe to remove it
269
read pid < "$pid_file"
270
if [ -z "$pid" ]; then
272
ocf_log debug "PID File \"$pid_file\" Was Removed - Zero length";
276
if [ ! -d /proc/`cat "$pid_file"` ]; then
278
ocf_log debug "PID File \"$pid_file\" Was Removed - PID Does Not Exist";