<commit_before>#!/bin/sh

#######################################################################

# Attempt to detect a default binary
OCF_RESKEY_binary_default=$(which mysqld_safe 2> /dev/null)
if [ "$OCF_RESKEY_binary_default" = "" ]; then
	OCF_RESKEY_binary_default=$(which safe_mysqld 2> /dev/null)
fi

# Fill in some defaults if no values are specified
HOSTOS=`uname`
if [ "X${HOSTOS}" = "XOpenBSD" ];then
	if [ "$OCF_RESKEY_binary_default" = "" ]; then
		OCF_RESKEY_binary_default="/usr/local/bin/mysqld_safe"
	fi
	OCF_RESKEY_config_default="/etc/my.cnf"
	OCF_RESKEY_datadir_default="/var/mysql"
	OCF_RESKEY_user_default="_mysql"
	OCF_RESKEY_group_default="_mysql"
	OCF_RESKEY_log_default="/var/log/mysqld.log"
	OCF_RESKEY_pid_default="/var/mysql/mysqld.pid"
	OCF_RESKEY_socket_default="/var/run/mysql/mysql.sock"
else
	if [ "$OCF_RESKEY_binary_default" = "" ]; then
		OCF_RESKEY_binary_default="/usr/bin/safe_mysqld"
	fi
	OCF_RESKEY_config_default="/etc/my.cnf"
	OCF_RESKEY_datadir_default="/var/lib/mysql"
	OCF_RESKEY_user_default="mysql"
	OCF_RESKEY_group_default="mysql"
	OCF_RESKEY_log_default="/var/log/mysqld.log"
	OCF_RESKEY_pid_default="/var/run/mysql/mysqld.pid"
	OCF_RESKEY_socket_default="/var/lib/mysql/mysql.sock"
fi
OCF_RESKEY_client_binary_default="mysql"
OCF_RESKEY_test_user_default="root"
OCF_RESKEY_test_table_default="mysql.user"
OCF_RESKEY_test_passwd_default=""
OCF_RESKEY_enable_creation_default=0
OCF_RESKEY_additional_parameters_default=""
OCF_RESKEY_replication_port_default="3306"
OCF_RESKEY_max_slave_lag_default="3600"
OCF_RESKEY_evict_outdated_slaves_default="false"
OCF_RESKEY_reader_attribute_default="readable"

: ${OCF_RESKEY_binary=${OCF_RESKEY_binary_default}}
MYSQL_BINDIR=`dirname ${OCF_RESKEY_binary}`

: ${OCF_RESKEY_client_binary=${OCF_RESKEY_client_binary_default}}

: ${OCF_RESKEY_config=${OCF_RESKEY_config_default}}
: ${OCF_RESKEY_datadir=${OCF_RESKEY_datadir_default}}

: ${OCF_RESKEY_user=${OCF_RESKEY_user_default}}
: ${OCF_RESKEY_group=${OCF_RESKEY_group_default}}

: ${OCF_RESKEY_log=${OCF_RESKEY_log_default}}
: ${OCF_RESKEY_pid=${OCF_RESKEY_pid_default}}
: ${OCF_RESKEY_socket=${OCF_RESKEY_socket_default}}

: ${OCF_RESKEY_test_user=${OCF_RESKEY_test_user_default}}
: ${OCF_RESKEY_test_table=${OCF_RESKEY_test_table_default}}
: ${OCF_RESKEY_test_passwd=${OCF_RESKEY_test_passwd_default}}

: ${OCF_RESKEY_enable_creation=${OCF_RESKEY_enable_creation_default}}
: ${OCF_RESKEY_additional_parameters=${OCF_RESKEY_additional_parameters_default}}

: ${OCF_RESKEY_replication_user=${OCF_RESKEY_replication_user_default}}
: ${OCF_RESKEY_replication_passwd=${OCF_RESKEY_replication_passwd_default}}
: ${OCF_RESKEY_replication_port=${OCF_RESKEY_replication_port_default}}

: ${OCF_RESKEY_max_slave_lag=${OCF_RESKEY_max_slave_lag_default}}
: ${OCF_RESKEY_evict_outdated_slaves=${OCF_RESKEY_evict_outdated_slaves_default}}

: ${OCF_RESKEY_reader_attribute=${OCF_RESKEY_reader_attribute_default}}

#######################################################################
# Convenience variables

MYSQL=$OCF_RESKEY_client_binary
MYSQL_OPTIONS_LOCAL="-S $OCF_RESKEY_socket --connect_timeout=10"
MYSQL_OPTIONS_REPL="$MYSQL_OPTIONS_LOCAL --user=$OCF_RESKEY_replication_user --password=$OCF_RESKEY_replication_passwd"
MYSQL_OPTIONS_TEST="$MYSQL_OPTIONS_LOCAL --user=$OCF_RESKEY_test_user --password=$OCF_RESKEY_test_passwd"
MYSQL_TOO_MANY_CONN_ERR=1040

CRM_MASTER="${HA_SBIN_DIR}/crm_master -l reboot "
NODENAME=$(ocf_local_nodename)
CRM_ATTR="${HA_SBIN_DIR}/crm_attribute -N $NODENAME "
INSTANCE_ATTR_NAME=`echo ${OCF_RESOURCE_INSTANCE}| awk -F : '{print $1}'`
CRM_ATTR_REPL_INFO="${HA_SBIN_DIR}/crm_attribute --type crm_config --name ${INSTANCE_ATTR_NAME}_REPL_INFO -s mysql_replication"

#######################################################################

mysql_common_validate()
{
    check_binary $OCF_RESKEY_binary
    check_binary  $OCF_RESKEY_client_binary

    if [ ! -f $OCF_RESKEY_config ]; then
        ocf_exit_reason "Config $OCF_RESKEY_config doesn't exist";
        return $OCF_ERR_INSTALLED;<commit_msg>High: mysql-common: avoid use of check_binary in common validation function.<commit_after>#!/bin/sh

#######################################################################

# Attempt to detect a default binary
OCF_RESKEY_binary_default=$(which mysqld_safe 2> /dev/null)
if [ "$OCF_RESKEY_binary_default" = "" ]; then
	OCF_RESKEY_binary_default=$(which safe_mysqld 2> /dev/null)
fi

# Fill in some defaults if no values are specified
HOSTOS=`uname`
if [ "X${HOSTOS}" = "XOpenBSD" ];then
	if [ "$OCF_RESKEY_binary_default" = "" ]; then
		OCF_RESKEY_binary_default="/usr/local/bin/mysqld_safe"
	fi
	OCF_RESKEY_config_default="/etc/my.cnf"
	OCF_RESKEY_datadir_default="/var/mysql"
	OCF_RESKEY_user_default="_mysql"
	OCF_RESKEY_group_default="_mysql"
	OCF_RESKEY_log_default="/var/log/mysqld.log"
	OCF_RESKEY_pid_default="/var/mysql/mysqld.pid"
	OCF_RESKEY_socket_default="/var/run/mysql/mysql.sock"
else
	if [ "$OCF_RESKEY_binary_default" = "" ]; then
		OCF_RESKEY_binary_default="/usr/bin/safe_mysqld"
	fi
	OCF_RESKEY_config_default="/etc/my.cnf"
	OCF_RESKEY_datadir_default="/var/lib/mysql"
	OCF_RESKEY_user_default="mysql"
	OCF_RESKEY_group_default="mysql"
	OCF_RESKEY_log_default="/var/log/mysqld.log"
	OCF_RESKEY_pid_default="/var/run/mysql/mysqld.pid"
	OCF_RESKEY_socket_default="/var/lib/mysql/mysql.sock"
fi
OCF_RESKEY_client_binary_default="mysql"
OCF_RESKEY_test_user_default="root"
OCF_RESKEY_test_table_default="mysql.user"
OCF_RESKEY_test_passwd_default=""
OCF_RESKEY_enable_creation_default=0
OCF_RESKEY_additional_parameters_default=""
OCF_RESKEY_replication_port_default="3306"
OCF_RESKEY_max_slave_lag_default="3600"
OCF_RESKEY_evict_outdated_slaves_default="false"
OCF_RESKEY_reader_attribute_default="readable"

: ${OCF_RESKEY_binary=${OCF_RESKEY_binary_default}}
MYSQL_BINDIR=`dirname ${OCF_RESKEY_binary}`

: ${OCF_RESKEY_client_binary=${OCF_RESKEY_client_binary_default}}

: ${OCF_RESKEY_config=${OCF_RESKEY_config_default}}
: ${OCF_RESKEY_datadir=${OCF_RESKEY_datadir_default}}

: ${OCF_RESKEY_user=${OCF_RESKEY_user_default}}
: ${OCF_RESKEY_group=${OCF_RESKEY_group_default}}

: ${OCF_RESKEY_log=${OCF_RESKEY_log_default}}
: ${OCF_RESKEY_pid=${OCF_RESKEY_pid_default}}
: ${OCF_RESKEY_socket=${OCF_RESKEY_socket_default}}

: ${OCF_RESKEY_test_user=${OCF_RESKEY_test_user_default}}
: ${OCF_RESKEY_test_table=${OCF_RESKEY_test_table_default}}
: ${OCF_RESKEY_test_passwd=${OCF_RESKEY_test_passwd_default}}

: ${OCF_RESKEY_enable_creation=${OCF_RESKEY_enable_creation_default}}
: ${OCF_RESKEY_additional_parameters=${OCF_RESKEY_additional_parameters_default}}

: ${OCF_RESKEY_replication_user=${OCF_RESKEY_replication_user_default}}
: ${OCF_RESKEY_replication_passwd=${OCF_RESKEY_replication_passwd_default}}
: ${OCF_RESKEY_replication_port=${OCF_RESKEY_replication_port_default}}

: ${OCF_RESKEY_max_slave_lag=${OCF_RESKEY_max_slave_lag_default}}
: ${OCF_RESKEY_evict_outdated_slaves=${OCF_RESKEY_evict_outdated_slaves_default}}

: ${OCF_RESKEY_reader_attribute=${OCF_RESKEY_reader_attribute_default}}

#######################################################################
# Convenience variables

MYSQL=$OCF_RESKEY_client_binary
MYSQL_OPTIONS_LOCAL="-S $OCF_RESKEY_socket --connect_timeout=10"
MYSQL_OPTIONS_REPL="$MYSQL_OPTIONS_LOCAL --user=$OCF_RESKEY_replication_user --password=$OCF_RESKEY_replication_passwd"
MYSQL_OPTIONS_TEST="$MYSQL_OPTIONS_LOCAL --user=$OCF_RESKEY_test_user --password=$OCF_RESKEY_test_passwd"
MYSQL_TOO_MANY_CONN_ERR=1040

CRM_MASTER="${HA_SBIN_DIR}/crm_master -l reboot "
NODENAME=$(ocf_local_nodename)
CRM_ATTR="${HA_SBIN_DIR}/crm_attribute -N $NODENAME "
INSTANCE_ATTR_NAME=`echo ${OCF_RESOURCE_INSTANCE}| awk -F : '{print $1}'`
CRM_ATTR_REPL_INFO="${HA_SBIN_DIR}/crm_attribute --type crm_config --name ${INSTANCE_ATTR_NAME}_REPL_INFO -s mysql_replication"

#######################################################################

mysql_common_validate()
{

    if ! have_binary "$OCF_RESKEY_binary"; then
        ocf_exit_reason "Setup problem: couldn't find command: $OCF_RESKEY_binary"
        return $OCF_ERR_INSTALLED;
    fi

    if ! have_binary "$OCF_RESKEY_client_binary"; then
        ocf_exit_reason "Setup problem: couldn't find command: $OCF_RESKEY_client_binary"
        return $OCF_ERR_INSTALLED;
    fi

    if [ ! -f $OCF_RESKEY_config ]; then
        ocf_exit_reason "Config $OCF_RESKEY_config doesn't exist";
        return $OCF_ERR_INSTALLED;
{'fraction_non_alphanumeric': 0.1611039037622361, 'fraction_numerical': 0.004245783700908126, 'mean_word_length': 10.413189771197846, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7428449', 'n_tokens_mistral': 3305, 'n_tokens_neox': 3245, 'n_words': 312}