<commit_before>#!/bin/sh

# http://ec2-54-219-59-129.us-west-1.compute.amazonaws.com:8983/solr/
# ssh -p22022 -i .ssh/motive2Key.pem root@ec2-54-219-59-129.us-west-1.compute.amazonaws.com

P=""
U=""
T=""
S=""
V=""

#check rights
if [ "$(id -u)" != "0" ]; then
   echo -e "This script must be run as root or be in /etc/sudoers to exec sudo -s\n" 1>&2
   exit 1
fi

#check OS 
if ! cat /etc/redhat-release | grep -iE 'centos|rhel|fedora|red|hat'; then
    echo -e "\nIncorrect OS!\n"
    exit 1;
fi

#parse args
if [ "$#" -eq 10 ]
then
        echo -e "\t\t Parsing params..."
        while getopts "u:p:t:s:v:" opt; do
            case "$opt" in
            u) U=$OPTARG
                ;;
            p) P=$OPTARG
                ;;
            t) T=$OPTARG
                ;;
	    s) S=$OPTARG
		;;
	    v) V=$OPTARG
		;;
            esac
        done
        echo -e "\tSCRIPT EXECUTED WITH NEXT PARAMETERS:\n"
        echo -e "-u - SVN USER: $U\n"
        echo -e "-p - SVN PASSWORD: <PASSWORD>"       
        echo -e "-t - ENVIRONMENT: $T\n"
        echo -e "-s - SPRINT NAME: $S\n"
        echo -e "-v - VERSION: $V\n"
        read -sn 1 -p "Check them and press any key to continue..."
        echo -e "\n"
else
  echo -e "\nscript usage:\n"
  echo -e "$0 -u USER -p PASSWORD -s sprint_name -t prod or test (all other args will be use as test) -v 1.2.4\n"
  echo -e "Example1: $0 -s trunk -u bogdan -p qwerty -t test -v 1.2.4\n"
  echo -e "Example2: $0 -s sprint_name -u bogdan -p qwerty -t prod -v 1.2.4\n"
  echo -e "Example3: $0 -s sprint_name -u bogdan -p qwerty -t BLA_BLA_INFO -v 1.2.4 \n"
  exit 1;
fi


#create test dir
rm -rf ~/build/
mkdir -p ~/build/
cd ~/build/

#check server type 
#  trunk/ - test
#  prod/ - prod
#--------------------------------------------------------------------------------------------------------------------------------------#
if [ "$T" == "prod" ]
then
    #PROD SERVER

    #set custom.properties
    dos2unix ~/build/prod/eas/resources/custom.properties_prod
    sed -i -r 's/build_version=.*/build_version='$V'/'  ~/build/prod/eas/resources/custom.properties_prod

    #change win to unix encoding<commit_msg>add -d key for prod password<commit_after>#!/bin/sh

# http://ec2-54-219-59-129.us-west-1.compute.amazonaws.com:8983/solr/
# ssh -p22022 -i .ssh/motive2Key.pem root@ec2-54-219-59-129.us-west-1.compute.amazonaws.com

P=""
U=""
T=""
S=""
V=""
D=""

#check rights
if [ "$(id -u)" != "0" ]; then
   echo -e "This script must be run as root or be in /etc/sudoers to exec sudo -s\n" 1>&2
   exit 1
fi

#check OS 
if ! cat /etc/redhat-release | grep -iE 'centos|rhel|fedora|red|hat'; then
    echo -e "\nIncorrect OS!\n"
    exit 1;
fi

#parse args
if [ "$#" -eq 10 ]
then
        echo -e "\t\t Parsing params..."
        while getopts "u:p:t:s:v:d:" opt; do
            case "$opt" in
            u) U=$OPTARG
                ;;
            p) P=$OPTARG
                ;;
            t) T=$OPTARG
                ;;
	    s) S=$OPTARG
		;;
	    v) V=$OPTARG
		;;
	    d) D=$OPTARG
		;;
            esac
        done
        echo -e "\tSCRIPT EXECUTED WITH NEXT PARAMETERS:\n"
        echo -e "-u - SVN USER: $U\n"
        echo -e "-p - SVN PASSWORD: <PASSWORD>"       
        echo -e "-t - ENVIRONMENT: $T\n"
        echo -e "-s - SPRINT NAME: $S\n"
        echo -e "-v - VERSION: $V\n"
        echo -e "-d - DB PASSWORD: <PASSWORD>"
        read -sn 1 -p "Check them and press any key to continue..."
        echo -e "\n"
else
  echo -e "\nscript usage:\n"
  echo -e "$0 -u USER -p PASSWORD -s sprint_name -t prod or test (all other args will be use as test) -v 1.2.4\n"
  echo -e "Example1: $0 -s trunk -u bogdan -p qwerty -t test -v 1.2.4\n"
  echo -e "Example2: $0 -s sprint_name -u bogdan -p qwerty -t prod -v 1.2.4\n"
  echo -e "Example3: $0 -s sprint_name -u bogdan -p qwerty -t BLA_BLA_INFO -v 1.2.4 \n"
  exit 1;
fi


#create test dir
rm -rf ~/build/
mkdir -p ~/build/
cd ~/build/

#check server type 
#  trunk/ - test
#  prod/ - prod
#--------------------------------------------------------------------------------------------------------------------------------------#
if [ "$T" == "prod" ]
then
    #PROD SERVER

    #set custom.properties
    dos2unix ~/build/prod/eas/resources/custom.properties_prod
    sed -i -r 's/build_version=.*/build_version='$V'/'  ~/build/prod/eas/resources/custom.properties_prod

    #change win to unix encoding
{'fraction_non_alphanumeric': 0.2150635208711434, 'fraction_numerical': 0.028584392014519056, 'mean_word_length': 1.5753504672897196, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '4161175', 'n_tokens_mistral': 1768, 'n_tokens_neox': 1667, 'n_words': 511}