<commit_before>#!/bin/bash
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# WildFly Control Script
# -----------------------------------------------------------------------------
# Configuration settings, please only modify this section
# -----------------------------------------------------------------------------
readonly dbHost="localhost"
readonly dbPort="5432"
readonly dbUser="cws_user"
readonly dbPassword="<PASSWORD>"
readonly dbName="cws"
# Maximal file size for uploading to WildFly - 25 MB (25 * 1024 * 1024)
readonly maxPostSize="26214400"
readonly wildfly=${JBOSS_HOME}
# Hidden feature, if set this port is used to start JBoss/WildFly in debug mode
readonly debugPort=${DEBUG_PORT}

# Java & JBoss (WildFly) settings
export JAVA_OPTS="${JAVA_OPTS} -Xms1303m -Xmx1303m -Djava.net.preferIPv4Stack=true"
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# Run the Control Script
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
if [ "${wildfly}" = "" ]; then
    echo "Script requires that the system variable \$JBOSS_HOME is defined."
    echo
    exit
fi

action=${1}
if [[ "${action}" = "configure" ]]; then
    ${wildfly}/bin/jboss-cli.sh --connect --controller=localhost --command="read-attribute server-state" >/dev/null
    if [[ $? -eq 0 ]]; then
        # CWS requires a database, currently only scripts for PostgreSQL exists, so
        # this is the one being attempted to create here.
        psql -h ${dbHost} -p ${dbPort} -l | grep cws > /dev/null
        if [[ $? -eq 1 ]]; then
            psql -h ${dbHost} -p ${dbPort} postgres -f  `dirname $0`/../postgresql/01-install.sql
        fi

        if [[ ! -e ${wildfly}/modules/org/postgresql/main/module.xml ]]; then
            echo "Configuring WildFly for CWS"
            mkdir -p "${wildfly}/modules/org/postgresql/main"
            cp `dirname $0`/../lib/postgresql-42.2.5.jar ${wildfly}/modules/org/postgresql/main
            cp `dirname $0`/../wildfly/module.xml ${wildfly}/modules/org/postgresql/main
            ${wildfly}/bin/jboss-cli.sh --connect --command="/subsystem=datasources/jdbc-driver=postgresql:add(driver-name=postgresql,driver-module-name=org.postgresql,driver-xa-datasource-class-name=org.postgresql.xa.PGXADataSource)" 2>/dev/null
            ${wildfly}/bin/jboss-cli.sh --connect --command="data-source add --name=cwsDS --driver-name=postgresql --jndi-name=java:/datasources/cwsDS --connection-url=jdbc:postgresql://${dbHost}:${dbPort}/${dbName} --user-name=${dbUser} --password=${<PASSWORD>} --use-ccm=false --max-pool-size=25 --blocking-timeout-wait-millis=5000 --enabled=true" 2>/dev/null
            ${wildfly}/bin/jboss-cli.sh --connect --command="/subsystem=undertow/server=default-server/http-listener=default/:write-attribute(name=max-post-size,value=${maxPostSize})" 2>/dev/null<commit_msg>Added Proxy support to the WildFly Script.<commit_after>#!/bin/bash
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# WildFly Control Script
# -----------------------------------------------------------------------------
# Configuration settings, please only modify this section
# -----------------------------------------------------------------------------
readonly dbHost="localhost"
readonly dbPort="5432"
readonly dbUser="cws_user"
readonly dbPassword="<PASSWORD>"
readonly dbName="cws"
# Maximal file size for uploading to WildFly - 25 MB (25 * 1024 * 1024)
readonly maxPostSize="26214400"
readonly wildfly=${JBOSS_HOME}
# Hidden feature, if set this port is used to start JBoss/WildFly in debug mode
readonly debugPort=${DEBUG_PORT}

# Java & JBoss (WildFly) settings
export JAVA_OPTS="${JAVA_OPTS} -Xms1303m -Xmx1303m -Djava.net.preferIPv4Stack=true"
readonly proxy=${http_proxy}
if [[ "${proxy}" != "" ]]; then
    readonly tmp=${proxy//:[[:digit:]]*/}
    readonly host=${tmp:7}
    readonly port=${proxy//[^0-9]/}
    export JAVA_OPTS="${JAVA_OPTS} -Dhttp.proxyHost=${host} -Dhttp.proxyPort=${port} -Dhttps.proxyHost=${host} -Dhttps.proxyPort=${port}"
fi
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# Run the Control Script
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
if [[ "${wildfly}" = "" ]]; then
    echo "Script requires that the system variable \$JBOSS_HOME is defined."
    echo
    exit
fi

action=${1}
if [[ "${action}" = "configure" ]]; then
    ${wildfly}/bin/jboss-cli.sh --connect --controller=localhost --command="read-attribute server-state" >/dev/null
    if [[ $? -eq 0 ]]; then
        # CWS requires a database, currently only scripts for PostgreSQL exists, so
        # this is the one being attempted to create here.
        psql -h ${dbHost} -p ${dbPort} -l | grep cws > /dev/null
        if [[ $? -eq 1 ]]; then
            psql -h ${dbHost} -p ${dbPort} postgres -f  `dirname $0`/../postgresql/01-install.sql
        fi

        if [[ ! -e ${wildfly}/modules/org/postgresql/main/module.xml ]]; then
            echo "Configuring WildFly for CWS"
            mkdir -p "${wildfly}/modules/org/postgresql/main"
            cp `dirname $0`/../lib/postgresql-42.2.5.jar ${wildfly}/modules/org/postgresql/main
            cp `dirname $0`/../wildfly/module.xml ${wildfly}/modules/org/postgresql/main
            ${wildfly}/bin/jboss-cli.sh --connect --command="/subsystem=datasources/jdbc-driver=postgresql:add(driver-name=postgresql,driver-module-name=org.postgresql,driver-xa-datasource-class-name=org.postgresql.xa.PGXADataSource)" 2>/dev/null
            ${wildfly}/bin/jboss-cli.sh --connect --command="data-source add --name=cwsDS --driver-name=postgresql --jndi-name=java:/datasources/cwsDS --connection-url=jdbc:postgresql://${dbHost}:${dbPort}/${dbName} --user-name=${dbUser} --password=${<PASSWORD>} --use-ccm=false --max-pool-size=25 --blocking-timeout-wait-millis=5000 --enabled=true" 2>/dev/null
            ${wildfly}/bin/jboss-cli.sh --connect --command="/subsystem=undertow/server=default-server/http-listener=default/:write-attribute(name=max-post-size,value=${maxPostSize})" 2>/dev/null
{'fraction_non_alphanumeric': 0.28793650793650793, 'fraction_numerical': 0.017619047619047618, 'mean_word_length': 2.494731003882418, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '1191724', 'n_tokens_mistral': 2257, 'n_tokens_neox': 1936, 'n_words': 389}