<commit_before>#!/bin/bash

echo INFO: keypass entrypoint start"

# Check argument DB_HOST
DB_HOST_ARG=${1}
# DB_HOST_VALUE can be hostname[:port]
DB_HOST_VALUE=${2}
DB_HOST_NAME="$(echo "${DB_HOST_VALUE}" | awk -F: '{print $1}')"
DB_HOST_PORT="$(echo "${DB_HOST_VALUE}" | awk -F: '{print $2}')"
# Default MySQL port 3306
[[ "${DB_HOST_PORT}" == "" ]] && DB_HOST_PORT=3306
# DBTIMEOUT in seconds. Default to 60 seconds
[[ "${DBTIMEOUT}" == "" ]] && export DBTIMEOUT=60

if [ "${DB_HOST_ARG}" == "-dbhost" ]; then
    echo "INFO: MySQL endpoint <${DB_HOST_VALUE}>"
    echo "INFO: DB_HOST_NAME <${DB_HOST_NAME}>"
    echo "INFO: DB_HOST_PORT <${DB_HOST_PORT}>"
    [[ "${DB_HOST_NAME}" == "" ]] && echo "ERROR: MySQL hostname not provided" >&2 && exit 2
    sed -i "s/mysql:\/\/localhost/mysql:\/\/"${DB_HOST_VALUE}"/g" /opt/keypass/config.yml
    # Wait until DB is up or exit if timeout
    # Current time in seconds
    STARTTIME=$(date +%s)
    while ! nc -z ${DB_HOST_NAME} ${DB_HOST_PORT}
    do
        [[ $(($(date +%s) - ${DBTIMEOUT})) -lt ${STARTTIME} ]] || { echo "ERROR: Timeout MySQL endpoint <${DB_HOST_NAME}:${DB_HOST_PORT}>" >&2; exit 3; }
        echo "INFO: Wait for MySQL endpoint <${DB_HOST_NAME}:${DB_HOST_PORT}>"
        sleep 2
    done
    java -jar /opt/keypass/keypass.jar db migrate /opt/keypass/config.yml
fi

java -jar /opt/keypass/keypass.jar server /opt/keypass/config.yml<commit_msg>fix type errors<commit_after>#!/bin/bash

echo "INFO: keypass entrypoint start"

# Check argument DB_HOST
DB_HOST_ARG=${1}
# DB_HOST_VALUE can be hostname[:port]
DB_HOST_VALUE=${2}
DB_HOST_NAME="$(echo "${DB_HOST_VALUE}" | awk -F: '{print $1}')"
DB_HOST_PORT="$(echo "${DB_HOST_VALUE}" | awk -F: '{print $2}')"
# Default MySQL port 3306
[[ "${DB_HOST_PORT}" == "" ]] && DB_HOST_PORT=3306
# DBTIMEOUT in seconds. Default to 60 seconds
[[ "${DBTIMEOUT}" == "" ]] && export DBTIMEOUT=60

if [ "${DB_HOST_ARG}" == "-dbhost" ]; then
    echo "INFO: MySQL endpoint <${DB_HOST_VALUE}>"
    echo "INFO: DB_HOST_NAME <${DB_HOST_NAME}>"
    echo "INFO: DB_HOST_PORT <${DB_HOST_PORT}>"
    [[ "${DB_HOST_NAME}" == "" ]] && echo "ERROR: MySQL hostname not provided" >&2 && exit 2
    sed -i "s/mysql:\/\/localhost/mysql:\/\/${DB_HOST_VALUE}/g" /opt/keypass/config.yml
    # Wait until DB is up or exit if timeout
    # Current time in seconds
    STARTTIME=$(date +%s)
    while ! nc -z ${DB_HOST_NAME} ${DB_HOST_PORT}
    do
        [[ $(($(date +%s) - ${DBTIMEOUT})) -lt ${STARTTIME} ]] || { echo "ERROR: Timeout MySQL endpoint <${DB_HOST_NAME}:${DB_HOST_PORT}>" >&2; exit 3; }
        echo "INFO: Wait for MySQL endpoint <${DB_HOST_NAME}:${DB_HOST_PORT}>"
        sleep 2
    done
    java -jar /opt/keypass/keypass.jar db migrate /opt/keypass/config.yml
fi

java -jar /opt/keypass/keypass.jar server /opt/keypass/config.yml
{'fraction_non_alphanumeric': 0.18840579710144928, 'fraction_numerical': 0.014846235418875928, 'mean_word_length': 3.9736379613356765, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 17, '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': '4407370', 'n_tokens_mistral': 1098, 'n_tokens_neox': 1048, 'n_words': 263}