cluster/rgmanager/src/resources apache.sh mysq ...
CVSROOT: /cvs/cluster
Module name: cluster
Changes by: mgrac at sourceware.org 2006-09-18 13:48:07
Modified files:
rgmanager/src/resources: apache.sh mysql.sh openldap.sh rgmanager/src/resources/utils: config-utils.sh ra-skelet.sh
Log message:
PID files are stored in common directory. Name of the PID file is generated from the OCF_RESOURCE_INSTANCE. Resource agents for Apache, MySQL and OpenLDAP are updated.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/apache.sh.diff?cvsroot=cluster&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/mysql.sh.diff?cvsroot=cluster&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/openldap.sh.diff?cvsroot=cluster&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/utils/config-utils.sh.diff?cvsroot=cluster&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/utils/ra-skelet.sh.diff?cvsroot=cluster&r1=1.1&r2=1.2
rgmanager/src/resources/apache.sh +15 -32
@@ -27,23 +27,21 @@ export LANG=C export PATH=/bin:/sbin:/usr/bin:/usr/sbin -declare APACHE_HTTPD=/usr/sbin/httpd -declare APACHE_genConfig="/tmp/httpd.$OCF_RESKEY_name" -declare APACHE_pid_file -declare APACHE_serverConfigFile -declare APACHE_defaultPidFile=run/httpd.pid - . $(dirname $0)/ocf-shellfuncs . $(dirname $0)/utils/config-utils.sh . $(dirname $0)/utils/messages.sh . $(dirname $0)/utils/ra-skelet.sh +declare APACHE_HTTPD=/usr/sbin/httpd +declare APACHE_genConfig="/tmp/httpd.$OCF_RESKEY_name" +declare APACHE_serverConfigFile +declare APACHE_pid_file="`generate_name_for_pid_file`" + declare APACHE_parseConfig=$(dirname $0)/utils/httpd-parse-config.pl apache_pidFile() { declare tmpFile="/tmp/httpd.$OCF_RESKEY_name.$$" - declare CFG_pidFile declare CFG_serverRoot if [ -f "$APACHE_genConfig" ]; then
@@ -58,25 +56,13 @@ generate_configFile "$APACHE_serverConfigFile" "$tmpFile" fi - CFG_pidFile=`grep -e '^PidFile' "$tmpFile" | head -n 1 | \ - sed 's/^PidFile "\(.*\)"/\1/;s/^PidFile \(.*\)/\1/'` CFG_serverRoot=`grep -e '^ServerRoot' "$tmpFile" | head -n 1 | \ sed 's/^ServerRoot "\(.*\)"/\1/;s/^ServerRoot \(.*\)/\1/'` - if [ -z "$CFG_pidFile" ]; then - CFG_pidFile="$APACHE_defaultPidFile" - fi - if [ -z "$CFG_serverRoot" ]; then CFG_serverRoot="$OCF_RESKEY_serverRoot" fi - if [[ "$CFG_pidFile" =~ '^/' ]]; then - APACHE_pid_file="$CFG_pidFile" - else - APACHE_pid_file="$CFG_serverRoot/$CFG_pidFile" - fi - rm -f "$tmpFile" return;
@@ -159,7 +145,6 @@ cat >> "$generatedConfigFile" << EOT # From a cluster perspective, the key fields are: # Listen - must be set to service floating IP address. -# PidFile - path to the file where PID of running application is stored # ServerRoot - path to the ServerRoot (initial value is set in service conf) #
@@ -177,7 +162,10 @@ done; IFS="$IFS_old" - cat "$originalConfigFile" | sed 's/^Listen/### Listen/;s/^Port/### Port/' | \ + 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"
@@ -191,6 +179,8 @@ clog_service_start $CLOG_INIT + create_pid_directory + if [ -e "$APACHE_pid_file" ]; then clog_check_pid $CLOG_FAILED "$APACHE_pid_file" clog_service_start $CLOG_FAILED
@@ -237,21 +227,14 @@ { clog_service_stop $CLOG_INIT - if [ ! -e "$APACHE_pid_file" ]; then - clog_check_file_exist $CLOG_FAILED_NOT_FOUND "$APACHE_pid_file" - clog_service_stop $CLOG_FAILED - return $OCF_ERR_GENERIC - fi - - "$APACHE_HTTPD" -k stop - + stop_generic "$APACHE_pid_file" + if [ $? -ne 0 ]; then clog_service_stop $CLOG_FAILED return $OCF_ERR_GENERIC - else - clog_service_stop $CLOG_SUCCEED fi + clog_service_stop $CLOG_SUCCEED return 0; }
@@ -276,7 +259,7 @@ case $1 in meta-data) - cat $(dirname $0)/apache.metadata + cat `echo $0 | sed 's/^\(.*\)\.sh$/\1.metadata/'` exit 0 ;; verify-all)
rgmanager/src/resources/mysql.sh +11 -16
@@ -27,16 +27,16 @@ export LANG=C export PATH=/bin:/sbin:/usr/bin:/usr/sbin -declare MYSQL_MYSQLD=/usr/bin/mysqld_safe -declare MYSQL_ipAddress -declare MYSQL_pid_file="/var/run/mysqld/mysql.$OCF_RESKEY_name.pid" -declare MYSQL_timeout=30 - . $(dirname $0)/ocf-shellfuncs . $(dirname $0)/utils/config-utils.sh . $(dirname $0)/utils/messages.sh . $(dirname $0)/utils/ra-skelet.sh +declare MYSQL_MYSQLD=/usr/bin/mysqld_safe +declare MYSQL_ipAddress +declare MYSQL_pid_file="`generate_name_for_pid_file`" +declare MYSQL_timeout=30 + verify_all() { clog_service_verify $CLOG_INIT
@@ -73,6 +73,8 @@ clog_service_start $CLOG_INIT + create_pid_directory + if [ -e "$MYSQL_pid_file" ]; then clog_check_pid $CLOG_FAILED "$MYSQL_pid_file" clog_service_start $CLOG_FAILED
@@ -136,21 +138,14 @@ { clog_service_stop $CLOG_INIT - if [ ! -e "$MYSQL_pid_file" ]; then - clog_check_file_exist $CLOG_FAILED_NOT_FOUND "$MYSQL_pid_file" - clog_service_stop $CLOG_FAILED - return $OCF_ERR_GENERIC - fi - - kill `cat "$MYSQL_pid_file"` - + stop_generic "$MYSQL_pid_file" + if [ $? -ne 0 ]; then clog_service_stop $CLOG_FAILED return $OCF_ERR_GENERIC - else - clog_service_stop $CLOG_SUCCEED fi + clog_service_stop $CLOG_SUCCEED return 0; }
@@ -170,7 +165,7 @@ case $1 in meta-data) - cat $(dirname $0)/mysql.metadata + cat `echo $0 | sed 's/^\(.*\)\.sh$/\1.metadata/'` exit 0 ;; verify-all)
rgmanager/src/resources/openldap.sh +38 -15
93 lines not on this page · raw message
rgmanager/src/resources/utils/config-utils.sh +30 -0
@@ -19,6 +19,8 @@ # MA 02139, USA. # +declare RA_COMMON_pid_dir=/var/run/cluster + declare -i FAIL=-1 declare -a ip_keys
@@ -214,4 +216,32 @@ done echo $ipaddrs +} + +generate_name_for_pid_file() +{ + declare filename=$(basename $0) + + echo "$RA_COMMON_pid_dir/$(basename $0 | sed 's/^\(.*\)\..*/\1/')/$OCF_RESOURCE_INSTANCE.pid" + + return 0; +} + +create_pid_directory() +{ + declare program_name="$(basename $0 | sed 's/^\(.*\)\..*/\1/')" + declare dirname="$RA_COMMON_pid_dir/$program_name" + + if [ -d "$dirname" ]; then + return 0; + fi + + chmod 711 "$RA_COMMON_pid_dir" + mkdir -p "$dirname" + + if [ "$program_name" = "mysql" ]; then + chown mysql.root "$dirname" + fi + + return 0; }
rgmanager/src/resources/utils/ra-skelet.sh +20 -1
@@ -24,7 +24,7 @@ # status_check_pid() { - declare pid_file=$1 + declare pid_file="$1" if [ -z "$pid_file" ]; then clog_check_file_exist $CLOG_FAILED_INVALID "$pid_file"
@@ -42,3 +42,22 @@ return 0 } + +stop_generic() +{ + declare pid_file="$1" + + if [ ! -e "$pid_file" ]; then + clog_check_file_exist $CLOG_FAILED_NOT_FOUND "$pid_file" + clog_service_stop $CLOG_FAILED + return $OCF_ERR_GENERIC + fi + + kill -TERM `cat "$pid_file"` + + if [ $? -ne 0 ]; then + return $OCF_ERR_GENERIC + fi + + return 0; +}