<commit_before>#!/bin/bash

# push.sh -c {configfile} {command} {arg...}  - see README.md for documentation
# The command is either a component to install, or an operation to
# perform.  Components are opentree [web app], api, taxomachine, etc.
# Operation to perform would be copying a neo4j database image or
# invoking the OTI indexing operation.

# If command is missing, components are pushed to the server according
# to OPENTREE_COMPONENTS as defined in the config file.

# You may wonder about my use of $foo vs. ${foo} vs. "$foo" vs. "${foo}".
# It's basically random.  I'm expecting to come up with some rules for
# choosing between these any day now.
# As far as I can tell, you use {} in case of concatenation with a
# letter or digit, and you use "" to protect against the possibility
# of there being a space in the variable value.

function err {
    echo "Error: $@" 1>&2
    exit 1
}

set -e

# $0 -h <hostname> -u <username> -i <identityfile> -n <hostname>

function opentree_branch {
    # Ignore on this end, in case the currently executing bash doesn't
    # have associative arrays.  See functions.sh for the 'real' definition.
    true
}

# declare -A OPENTREE_BRANCHES  - doesn't work in bash 3.2.48
#  but associative arrays seem to work without the declaration in
#  3.2.48 and in 4.2.37, contrary to documentation on web

# The host must always be specified
# OPENTREE_HOST=dev.opentreeoflife.org
# OPENTREE_NEO4J_HOST=dev.opentreeoflife.org

# The following defaults; they can be overridden by the config file
OPENTREE_ADMIN=admin
OPENTREE_IDENTITY=opentree.pem
OPENTREE_DOCSTORE=phylesystem
OPENTREE_GH_IDENTITY=opentree-gh.pem
OPENTREE_COMPONENTS=most
OPENTREE_USER=opentree
DRYRUN=no
FORCE_COMPILE=no

if [ x$CONTROLLER = x ]; then
    CONTROLLER=`whoami`
fi

# On ubuntu, the admin user is called 'ubuntu'

while [ $# -gt 0 ]; do
    if [ ${1:0:1} != - ]; then
        break
    fi
    flag=$1
    shift
    if [ "x$flag" = "x-c" ]; then
        # Config file overrides default parameter settings
        configfile=$1
        source "$configfile"; shift
        cp -pf $configfile setup/CONFIG    # Will get copied during 'sync'
    elif [ "x$flag" = "x-f" ]; then
        #echo "Forcing recompile!"
        FORCE_COMPILE=yes;
    elif [ "$flag" = "--dry-run" ]; then
        #echo "Dry run only!"
        DRYRUN=yes;
    # The following are all legacy; do not add cases to this 'while'.
    # Configuration should now be done in the config file.
    elif [ "x$flag" = "x-h" ]; then
        OPENTREE_HOST="$1"; shift
    elif [ "x$flag" = "x-p" ]; then
        OPENTREE_PUBLIC_DOMAIN="$1"; shift
    elif [ "x$flag" = "x-u" ]; then
        OPENTREE_ADMIN="$1"; shift
    elif [ "x$flag" = "x-i" ]; then
        OPENTREE_IDENTITY="$1"; shift
    elif [ "x$flag" = "x-n" ]; then
        OPENTREE_NEO4J_HOST="$1"; shift
    else
        err "Unrecognized flag: $flag"
    fi
done

if [ "x$OPENTREE_HOST" = x ] ; then err "OPENTREE_HOST not specified"; fi
if [ "x$OPENTREE_IDENTITY" = x ]; then err "OPENTREE_IDENTITY not specified"; fi
if [ ! -r $OPENTREE_IDENTITY ]; then err "$OPENTREE_IDENTITY not found"; fi
[ "x$OPENTREE_NEO4J_HOST" != x ] || OPENTREE_NEO4J_HOST=$OPENTREE_HOST
[ "x$OPENTREE_PUBLIC_DOMAIN" != x ] || OPENTREE_PUBLIC_DOMAIN=$OPENTREE_HOST

[ "x$CURATION_GITHUB_CLIENT_ID" != x ] || CURATION_GITHUB_CLIENT_ID=ID_NOT_PROVIDED
[ "x$CURATION_GITHUB_REDIRECT_URI" != x ] || CURATION_GITHUB_REDIRECT_URI=$OPENTREE_PUBLIC_DOMAIN/webapp/user/login
[ "x$TREEVIEW_GITHUB_CLIENT_ID" != x ] || TREEVIEW_GITHUB_CLIENT_ID=ID_NOT_PROVIDED
[ "x$TREEVIEW_GITHUB_REDIRECT_URI" != x ] || TREEVIEW_GITHUB_REDIRECT_URI=$OPENTREE_PUBLIC_DOMAIN/curator/user/login

[ "x$TREEMACHINE_BASE_URL" != x ] || TREEMACHINE_BASE_URL=$OPENTREE_NEO4J_HOST/treemachine
[ "x$TAXOMACHINE_BASE_URL" != x ] || TAXOMACHINE_BASE_URL=$OPENTREE_NEO4J_HOST/taxomachine
# Extraneous http:// is needed for now, but should get phased out
[ "x$OTI_BASE_URL" != x ] || OTI_BASE_URL=http://$OPENTREE_NEO4J_HOST/oti
[ "x$OPENTREE_API_BASE_URL" != x ] || OPENTREE_API_BASE_URL=$OPENTREE_PUBLIC_DOMAIN/api/v1

[ "x$OPENTREE_DEFAULT_APPLICATION" != x ] || OPENTREE_DEFAULT_APPLICATION=opentree

# abbreviations... no good reason for these, they just make the commands shorter

ADMIN=$OPENTREE_ADMIN<commit_msg>change redirect to send users back to opentree<commit_after>#!/bin/bash

# push.sh -c {configfile} {command} {arg...}  - see README.md for documentation
# The command is either a component to install, or an operation to
# perform.  Components are opentree [web app], api, taxomachine, etc.
# Operation to perform would be copying a neo4j database image or
# invoking the OTI indexing operation.

# If command is missing, components are pushed to the server according
# to OPENTREE_COMPONENTS as defined in the config file.

# You may wonder about my use of $foo vs. ${foo} vs. "$foo" vs. "${foo}".
# It's basically random.  I'm expecting to come up with some rules for
# choosing between these any day now.
# As far as I can tell, you use {} in case of concatenation with a
# letter or digit, and you use "" to protect against the possibility
# of there being a space in the variable value.

function err {
    echo "Error: $@" 1>&2
    exit 1
}

set -e

# $0 -h <hostname> -u <username> -i <identityfile> -n <hostname>

function opentree_branch {
    # Ignore on this end, in case the currently executing bash doesn't
    # have associative arrays.  See functions.sh for the 'real' definition.
    true
}

# declare -A OPENTREE_BRANCHES  - doesn't work in bash 3.2.48
#  but associative arrays seem to work without the declaration in
#  3.2.48 and in 4.2.37, contrary to documentation on web

# The host must always be specified
# OPENTREE_HOST=dev.opentreeoflife.org
# OPENTREE_NEO4J_HOST=dev.opentreeoflife.org

# The following defaults; they can be overridden by the config file
OPENTREE_ADMIN=admin
OPENTREE_IDENTITY=opentree.pem
OPENTREE_DOCSTORE=phylesystem
OPENTREE_GH_IDENTITY=opentree-gh.pem
OPENTREE_COMPONENTS=most
OPENTREE_USER=opentree
DRYRUN=no
FORCE_COMPILE=no

if [ x$CONTROLLER = x ]; then
    CONTROLLER=`whoami`
fi

# On ubuntu, the admin user is called 'ubuntu'

while [ $# -gt 0 ]; do
    if [ ${1:0:1} != - ]; then
        break
    fi
    flag=$1
    shift
    if [ "x$flag" = "x-c" ]; then
        # Config file overrides default parameter settings
        configfile=$1
        source "$configfile"; shift
        cp -pf $configfile setup/CONFIG    # Will get copied during 'sync'
    elif [ "x$flag" = "x-f" ]; then
        #echo "Forcing recompile!"
        FORCE_COMPILE=yes;
    elif [ "$flag" = "--dry-run" ]; then
        #echo "Dry run only!"
        DRYRUN=yes;
    # The following are all legacy; do not add cases to this 'while'.
    # Configuration should now be done in the config file.
    elif [ "x$flag" = "x-h" ]; then
        OPENTREE_HOST="$1"; shift
    elif [ "x$flag" = "x-p" ]; then
        OPENTREE_PUBLIC_DOMAIN="$1"; shift
    elif [ "x$flag" = "x-u" ]; then
        OPENTREE_ADMIN="$1"; shift
    elif [ "x$flag" = "x-i" ]; then
        OPENTREE_IDENTITY="$1"; shift
    elif [ "x$flag" = "x-n" ]; then
        OPENTREE_NEO4J_HOST="$1"; shift
    else
        err "Unrecognized flag: $flag"
    fi
done

if [ "x$OPENTREE_HOST" = x ] ; then err "OPENTREE_HOST not specified"; fi
if [ "x$OPENTREE_IDENTITY" = x ]; then err "OPENTREE_IDENTITY not specified"; fi
if [ ! -r $OPENTREE_IDENTITY ]; then err "$OPENTREE_IDENTITY not found"; fi
[ "x$OPENTREE_NEO4J_HOST" != x ] || OPENTREE_NEO4J_HOST=$OPENTREE_HOST
[ "x$OPENTREE_PUBLIC_DOMAIN" != x ] || OPENTREE_PUBLIC_DOMAIN=$OPENTREE_HOST

[ "x$CURATION_GITHUB_CLIENT_ID" != x ] || CURATION_GITHUB_CLIENT_ID=ID_NOT_PROVIDED
[ "x$CURATION_GITHUB_REDIRECT_URI" != x ] || CURATION_GITHUB_REDIRECT_URI=$OPENTREE_PUBLIC_DOMAIN/webapp
[ "x$TREEVIEW_GITHUB_CLIENT_ID" != x ] || TREEVIEW_GITHUB_CLIENT_ID=ID_NOT_PROVIDED
[ "x$TREEVIEW_GITHUB_REDIRECT_URI" != x ] || TREEVIEW_GITHUB_REDIRECT_URI=$OPENTREE_PUBLIC_DOMAIN/curator

[ "x$TREEMACHINE_BASE_URL" != x ] || TREEMACHINE_BASE_URL=$OPENTREE_NEO4J_HOST/treemachine
[ "x$TAXOMACHINE_BASE_URL" != x ] || TAXOMACHINE_BASE_URL=$OPENTREE_NEO4J_HOST/taxomachine
# Extraneous http:// is needed for now, but should get phased out
[ "x$OTI_BASE_URL" != x ] || OTI_BASE_URL=http://$OPENTREE_NEO4J_HOST/oti
[ "x$OPENTREE_API_BASE_URL" != x ] || OPENTREE_API_BASE_URL=$OPENTREE_PUBLIC_DOMAIN/api/v1

[ "x$OPENTREE_DEFAULT_APPLICATION" != x ] || OPENTREE_DEFAULT_APPLICATION=opentree

# abbreviations... no good reason for these, they just make the commands shorter

ADMIN=$OPENTREE_ADMIN
{'fraction_non_alphanumeric': 0.11295372840078859, 'fraction_numerical': 0.008349762263713326, 'mean_word_length': 3.916761687571266, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, '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': '5635300', 'n_tokens_mistral': 3194, 'n_tokens_neox': 3115, 'n_words': 874}