#!/bin/bash STATE_FILE=/var/spool/pcs-nodeadd-executed pcs_not_configured () { pcs status 2>&1 | grep -qi 'cluster is not currently running on this node' } if [ -f "$STATE_FILE" ]; then echo "INFO: State file ($STATE_FILE) is already exists. It seems node had been already configured." exit 0 fi if [ -z "${PCS_NODEADD_SERVER}" ]; then echo "FATAL: PCS nodeadd service is not specified in /etc/sysconfig/pcs-nodeadd-client" exit 1 fi if pcs_not_configured; then NODE_NAME="$( hostname -s )" echo "${NODE_NAME} ${PCS_NODEADD_SECRET}" | nc ${PCS_NODEADD_SERVER} 2225 if pcs_not_configured; then echo "ERROR: Failed to configure node as a part of PCS clsuter." exit 1 else echo "INFO: Node has been successfully configured as a part of PCS cluster." touch $STATE_FILE exit 0 fi else echo "ERROR: Something goes wrong. Node is already a part of PCS cluster, but there is no state file exists." exit 1 fi