<commit_before>#/bin/bash -e

# Generates the default exhibitor config and launches exhibitor

IP=$(hostname -i)
DEFAULT_AWS_REGION="us-west-2"
DEFAULT_DATA_DIR="/opt/zookeeper/snapshots"
DEFAULT_LOG_DIR="/opt/zookeeper/transactions"
S3_SECURITY=""
HTTP_PROXY=""
DEFAULT_CONFIG_TYPE="FILE"
DEFAULT_CONFIG_CHECK_MS="30000"
: ${CONFIG_TYPE:=$DEFAULT_CONFIG_TYPE}
: ${HOSTNAME:?$MISSING_VAR_MESSAGE}
: ${AWS_REGION:=$DEFAULT_AWS_REGION}
: ${ZK_DATA_DIR:=$DEFAULT_DATA_DIR}
: ${ZK_LOG_DIR:=$DEFAULT_LOG_DIR}
: ${HTTP_PROXY_HOST:=""}
: ${HTTP_PROXY_PORT:=""}
: ${HTTP_PROXY_USERNAME:=""}
: ${HTTP_PROXY_PASSWORD:=""}
: ${CONFIG_CHECK_MS:=$DEFAULT_CONFIG_CHECK_MS}

cat <<- EOF > /opt/exhibitor/defaults.conf
	zookeeper-data-directory=$ZK_DATA_DIR
	zookeeper-install-directory=/opt/zookeeper
	zookeeper-log-directory=$ZK_LOG_DIR
	log-index-directory=$ZK_LOG_DIR
	cleanup-period-ms=300000
	check-ms=$CONFIG_CHECK_MS
	backup-period-ms=600000
	client-port=2181
	cleanup-max-files=20
	backup-max-store-ms=21600000
	connect-port=2888
	observer-threshold=0
	election-port=3888
	zoo-cfg-extra=tickTime\=2000&initLimit\=10&syncLimit\=5&quorumListenOnAllIPs\=true
	auto-manage-instances-settling-period-ms=0
	auto-manage-instances=1
EOF

echo "Environnment : "
echo `env`

echo "Config type: $CONFIG_TYPE"

if [ "$CONFIG_TYPE" == "ZK" ]
then
    : ${ZKCFG_CONNECT?"Need to set ZK_CONNECT"}
    : ${ZKCFG_POLLING_MS:="10000"}
    : ${KUBERNETES_NAMESPACE:=""}
    : ${ZKCFG_ZPATH:="/exhibitor"}
    : ${ZKCFG_RETRY_SLEEP_MS:="1000"}
    : ${ZKCFG_RETRY_TIMES:="3"}
    if [ -n "${KUBERNETES_NAMESPACE}"]
    then
        ZKCFG_ZPATH_ROOT=""
    else
        ZKCFG_ZPATH_ROOT="/${KUBERNETES_NAMESPACE}"
    fi
    ZK_CONFIG_ZPATH="${ZKCFG_ZPATH_ROOT}${ZKCFG_ZPATH}"
    BACKUP_CONFIG="--configtype zookeeper --zkconfigconnect ${ZKCFG_CONNECT} --zkconfigpollms ${ZKCFG_POLLING_MS} --zkconfigzpath ${ZK_CONFIG_ZPATH}"
    BACKUP_CONFIG=${BACKUP_CONFIG}" --zkconfigretry ${ZKCFG_RETRY_SLEEP_MS}:${ZKCFG_RETRY_TIMES} --filesystembackup true"

elif [ "${CONFIG_TYPE}" == "S3" ]
then<commit_msg>Simplied env vars and uncoupled them from Kubernetes<commit_after>#/bin/bash -e

# Generates the default exhibitor config and launches exhibitor

IP=$(hostname -i)
DEFAULT_AWS_REGION="us-west-2"
DEFAULT_DATA_DIR="/opt/zookeeper/snapshots"
DEFAULT_LOG_DIR="/opt/zookeeper/transactions"
S3_SECURITY=""
HTTP_PROXY=""
DEFAULT_CONFIG_TYPE="FILE"
DEFAULT_CONFIG_CHECK_MS="30000"
: ${CONFIG_TYPE:=$DEFAULT_CONFIG_TYPE}
: ${HOSTNAME:?$MISSING_VAR_MESSAGE}
: ${AWS_REGION:=$DEFAULT_AWS_REGION}
: ${ZK_DATA_DIR:=$DEFAULT_DATA_DIR}
: ${ZK_LOG_DIR:=$DEFAULT_LOG_DIR}
: ${HTTP_PROXY_HOST:=""}
: ${HTTP_PROXY_PORT:=""}
: ${HTTP_PROXY_USERNAME:=""}
: ${HTTP_PROXY_PASSWORD:=""}
: ${CONFIG_CHECK_MS:=$DEFAULT_CONFIG_CHECK_MS}

cat <<- EOF > /opt/exhibitor/defaults.conf
	zookeeper-data-directory=$ZK_DATA_DIR
	zookeeper-install-directory=/opt/zookeeper
	zookeeper-log-directory=$ZK_LOG_DIR
	log-index-directory=$ZK_LOG_DIR
	cleanup-period-ms=300000
	check-ms=$CONFIG_CHECK_MS
	backup-period-ms=600000
	client-port=2181
	cleanup-max-files=20
	backup-max-store-ms=21600000
	connect-port=2888
	observer-threshold=0
	election-port=3888
	zoo-cfg-extra=tickTime\=2000&initLimit\=10&syncLimit\=5&quorumListenOnAllIPs\=true
	auto-manage-instances-settling-period-ms=0
	auto-manage-instances=1
EOF

echo "Environnment : "
echo `env`

echo "Config type: $CONFIG_TYPE"

if [ "$CONFIG_TYPE" == "ZK" ]
then
    : ${ZKCFG_CONNECT?"Need to set ZK_CONNECT"}
    : ${ZKCFG_POLLING_MS:="10000"}
    : ${ZKCFG_ZPATH:="/exhibitor"}
    : ${ZKCFG_RETRY_SLEEP_MS:="1000"}
    : ${ZKCFG_RETRY_TIMES:="3"}
    BACKUP_CONFIG="--configtype zookeeper --zkconfigconnect ${ZKCFG_CONNECT} --zkconfigpollms ${ZKCFG_POLLING_MS} --zkconfigzpath ${ZKCFG_ZPATH}"
    BACKUP_CONFIG=${BACKUP_CONFIG}" --zkconfigretry ${ZKCFG_RETRY_SLEEP_MS}:${ZKCFG_RETRY_TIMES} --filesystembackup true"

elif [ "${CONFIG_TYPE}" == "S3" ]
then
{'fraction_non_alphanumeric': 0.15792141951837768, 'fraction_numerical': 0.031432192648922684, 'mean_word_length': 6.588461538461538, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '5129948', 'n_tokens_mistral': 1687, 'n_tokens_neox': 1625, 'n_words': 188}