/usr/share/cluster/apache.sh is in resource-agents 1:3.9.7-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 | #!/bin/bash
#
# Copyright (C) 1997-2003 Sistina Software, Inc. All rights reserved.
# Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
export LC_ALL=C
export LANG=C
export PATH=/bin:/sbin:/usr/bin:/usr/sbin
. $(dirname $0)/ocf-shellfuncs
. $(dirname $0)/utils/config-utils.sh
. $(dirname $0)/utils/messages.sh
. $(dirname $0)/utils/ra-skelet.sh
APACHE_HTTPD=$OCF_RESKEY_httpd
if [ -z "$APACHE_HTTPD" ]; then
if [ -x /usr/sbin/httpd ]; then
declare APACHE_HTTPD=/usr/sbin/httpd
elif [ -x /usr/sbin/apache2 ]; then
declare APACHE_HTTPD=/usr/sbin/apache2
fi
fi
declare APACHE_serverConfigFile
declare APACHE_pid_file="`generate_name_for_pid_file`"
declare APACHE_conf_dir="`generate_name_for_conf_dir`"
declare APACHE_genConfig="$APACHE_conf_dir/httpd.conf"
declare APACHE_parseConfig=$(dirname $0)/utils/httpd-parse-config.pl
apache_serverConfigFile()
{
if $(echo $OCF_RESKEY_config_file | grep -q "^/"); then
APACHE_serverConfigFile="$OCF_RESKEY_config_file"
else
APACHE_serverConfigFile="$OCF_RESKEY_server_root/$OCF_RESKEY_config_file"
fi
return;
}
verify_all()
{
clog_service_verify $CLOG_INIT
if [ -z "$OCF_RESKEY_name" ]; then
clog_service_verify $CLOG_FAILED "Invalid Name Of Service"
return $OCF_ERR_ARGS
fi
if [ -n "$OCF_RESKEY_httpd" ] && ! [ -e $OCF_RESKEY_httpd ]; then
clog_service_verify $CLOG_FAILED "Invalid httpd binary, $OCF_RESKEY_http does not exist"
return $OCF_ERR_ARGS
fi
if [ -z "$OCF_RESKEY_service_name" ]; then
clog_service_verify $CLOG_FAILED_NOT_CHILD
return $OCF_ERR_ARGS
fi
if [ -z "$OCF_RESKEY_server_root" ]; then
clog_service_verify $CLOG_FAILED "Invalid ServerRoot"
return $OCF_ERR_ARGS
fi
if [ ! -d "$OCF_RESKEY_server_root" ]; then
clog_service_verify $CLOG_FAILED "ServerRoot Directory Is Missing"
return $OCF_ERR_ARGS
fi
if [ -z "$OCF_RESKEY_config_file" ]; then
clog_check_file_exist $CLOG_FAILED_INVALID "$OCF_RESKEY_config_file"
return $OCF_ERR_ARGS
fi
if [ ! -r "$APACHE_serverConfigFile" ]; then
clog_check_file_exist $CLOG_FAILED_NOT_READABLE "$APACHE_serverConfigFile"
return $OCF_ERR_ARGS
fi
if [ -z "$APACHE_pid_file" ]; then
clog_service_verify $CLOG_FAILED "Invalid name of PID file"
return $OCF_ERR_ARGS
fi
clog_check_syntax $CLOG_INIT "$APACHE_serverConfigFile"
"$APACHE_HTTPD" -t \
-D"$OCF_RESKEY_name" \
-d "$OCF_RESKEY_server_root" \
-f "$APACHE_serverConfigFile" \
$OCF_RESKEY_httpd_options &> /dev/null
if [ $? -ne 0 ]; then
clog_check_syntax $CLOG_FAILED "$APACHE_serverConfigFile"
return $OCF_ERR_GENERIC
fi
clog_check_syntax $CLOG_SUCCEED "$APACHE_serverConfigFile"
return 0
}
generate_configFile()
{
declare originalConfigFile=$1;
declare generatedConfigFile=$2;
declare ip_addresses=$3;
if [ -f "$generatedConfigFile" ]; then
sha1_verify "$generatedConfigFile"
if [ $? -ne 0 ]; then
clog_check_sha1 $CLOG_FAILED
return 0
fi
fi
clog_generate_config $CLOG_INIT "$originalConfigFile" "$generatedConfigFile"
generate_configTemplate "$generatedConfigFile" "$1"
cat >> "$generatedConfigFile" << EOT
# From a cluster perspective, the key fields are:
# Listen - must be set to service floating IP address.
# ServerRoot - path to the ServerRoot (initial value is set in service conf)
#
EOT
IFS_old="$IFS"
IFS=$'\n'
for i in `"$APACHE_parseConfig" -D"$OCF_RESKEY_name" < "$originalConfigFile" | grep -P '(^Listen)|(^Port)' `; do
port=`echo $i | sed 's/^Listen \(.*\)/\1/;s/^Port \(.*\)/\1/'`;
testcond=`echo $port|grep :`
if [ $testcond ]; then
port=`echo $port|awk -F : '{print $2}'`
fi
IFS=$' ';
for z in $ip_addresses; do
if [ "${z//:/}" != "$z" ]; then
echo "Listen [$z]:$port" >> "$generatedConfigFile";
else
echo "Listen $z:$port" >> "$generatedConfigFile";
fi
done
IFS=$'\n';
done;
IFS="$IFS_old"
echo "PidFile \"$APACHE_pid_file\"" >> "$generatedConfigFile";
echo >> "$generatedConfigFile"
cat "$originalConfigFile" | sed 's/^Listen/### Listen/;s/^Port/### Port/;s/^PidFile/### PidFile/' | \
"$APACHE_parseConfig" -D"$OCF_RESKEY_name" >> "$generatedConfigFile"
sha1_addToFile "$generatedConfigFile"
clog_generate_config $CLOG_SUCCEED "$originalConfigFile" "$generatedConfigFile"
}
start()
{
if status; then
ocf_log info "Starting Service $OCF_RESOURCE_INSTANCE > Already running"
return $OCF_SUCCESS
fi
declare ip_addresses
clog_service_start $CLOG_INIT
create_pid_directory
create_conf_directory "$APACHE_conf_dir"
check_pid_file "$APACHE_pid_file"
if [ $? -ne 0 ]; then
clog_check_pid $CLOG_FAILED "$APACHE_pid_file"
clog_service_start $CLOG_FAILED
return $OCF_ERR_GENERIC
fi
clog_looking_for $CLOG_INIT "IP Addresses"
get_service_ip_keys "$OCF_RESKEY_service_name"
ip_addresses=`build_ip_list`
if [ -z "$ip_addresses" ]; then
clog_looking_for $CLOG_FAILED_NOT_FOUND "IP Addresses"
return $OCF_ERR_GENERIC
fi
clog_looking_for $CLOG_SUCCEED "IP Addresses"
generate_configFile "$APACHE_serverConfigFile" "$APACHE_genConfig" "$ip_addresses"
"$APACHE_HTTPD" \
"-D$OCF_RESKEY_name" \
-d "$OCF_RESKEY_server_root" \
-f "$APACHE_genConfig" \
$OCF_RESKEY_httpd_options \
-k start
if [ $? -ne 0 ]; then
clog_service_start $CLOG_FAILED
return $OCF_ERR_GENERIC
else
clog_service_start $CLOG_SUCCEED
fi
return 0;
}
stop()
{
clog_service_stop $CLOG_INIT
stop_generic "$APACHE_pid_file" "$OCF_RESKEY_shutdown_wait"
if [ $? -ne 0 ]; then
clog_service_stop $CLOG_FAILED
return $OCF_ERR_GENERIC
fi
clog_service_stop $CLOG_SUCCEED
return 0;
}
status()
{
clog_service_status $CLOG_INIT
status_check_pid "$APACHE_pid_file"
case $? in
$OCF_NOT_RUNNING)
clog_service_status $CLOG_FAILED "$APACHE_pid_file"
return $OCF_NOT_RUNNING
;;
0)
clog_service_status $CLOG_SUCCEED
exit 0
;;
*)
clog_service_status $CLOG_FAILED "$APACHE_pid_file"
return $OCF_ERR_GENERIC
;;
esac
}
if [ "$1" != "meta-data" ]; then
apache_serverConfigFile
fi;
case $1 in
meta-data)
cat `echo $0 | sed 's/^\(.*\)\.sh$/\1.metadata/'`
exit 0
;;
validate-all|verify-all)
verify_all
exit $?
;;
start)
verify_all && start
exit $?
;;
stop)
verify_all && stop
exit $?
;;
status|monitor)
verify_all
status
exit $?
;;
restart)
verify_all
stop
start
exit $?
;;
*)
echo "Usage: $0 {start|stop|status|monitor|restart|meta-data|validate-all}"
exit $OCF_ERR_UNIMPLEMENTED
;;
esac
|