<commit_before>#!/bin/sh

### The purpose of this script is to load the various docker images and to extract the components to the right location
### set the right permissions, etc.

### This script is meant to be used the first time around for clean installation

## Untar up all the required images and components in the home folder
tar xvf JuliaDeploymentBundle.tar


cd JuliaDeploymentImages


## Load all the docker images

for dock_img in `ls -1 *_image.tar`
do
	echo ""
    echo "======================================================"
    echo "Loading docker image ${dock_img} ..."
    echo "======================================================"
	docker load < $dock_img
	ret_val=$?
    echo "======================================================"
    echo "Loaded docker image ${dock_img} ..."
    echo "Status ${ret_val} ..."  ## Should exit if not successful !
    echo "======================================================"
done

## Go back to where it all started
cd ../

echo "======================================================"
echo "Unpack jboxengine ..."
echo "======================================================"
\cp -rf jboxengine /
ret_val=$?
## TODO check if it is required to change ownership. It may not be required?
chown -R $USER:$USER /jboxengine
echo "======================================================"
echo "Unpacked jboxengine ..."
echo "Status ${ret_val} ..."  ## Should exit if not successful !
echo "======================================================"


echo "======================================================"
echo "Starting components ..."
echo "======================================================"

cd JuliaDeployment
./scripts/run/start.sh
ret_val=$?

echo "======================================================"
echo "Started components. ..."
echo "Status ${ret_val} ..."  ## Should exit if not successful !
echo "======================================================"


echo "======================================================"
echo "Validating components ..."
echo "======================================================"

num_containers=`docker ps -a | wc -l`

echo "======================================================"
if [$num_containers -ge 4]; then
	echo "Validation Successful !!!"
else
	echo "Validation Failed !!! Please check the log files for more information"
fi
echo "======================================================"


echo "======================================================"
echo "Validating API container ..."
echo "======================================================"

## TODO make a curl call to echo server to test the API container deployment

retVal=`curl -v --data ";jsonString=\"Hello\""  http://api.ip-10-93-140-37/test/echo/ | cat - | grep "Hello" | wc -l`

echo "The retVal is :: $retVal"

echo "======================================================"
if [$ret_val != 0]; then
	echo "API Deployment Successful !!!"
else
	echo "API Deployment Failed !!! Please check the log files for more information"
fi
echo "======================================================"

echo
echo "Installation and Validation DONE !!!"<commit_msg>pre-requirement checks added<commit_after>#!/bin/sh

### The purpose of this script is to load the various docker images and to extract the components to the right location
### set the right permissions, etc.

### This script is meant to be used the first time around for clean installation


### Perform pre-requisites check ...

PRE_REQUISITE_APPS="docker supervisord supervisorctl"


check_availability() {
    command -v $1 > /dev/null 2>&1
    ret_val=$?
    ## echo "The ret_val is :: $ret_val"
    return $ret_val
}

for req_app in $PRE_REQUISITE_APPS
do
    ## echo $req_app
    check_availability $req_app
    ret_val=$?
    if [ $ret_val -eq 0 ]
    then
        echo "$req_app is installed, good to go !"
    else
        echo "$req_app is not installed. Please install $req_app first !"
        echo "Installation terminated as dependencies are not met."
        exit 1
    fi
done


## Untar up all the required images and components in the home folder
tar xvf JuliaDeploymentBundle.tar


cd JuliaDeploymentImages


## Load all the docker images

for dock_img in `ls -1 *_image.tar`
do
	echo ""
    echo "======================================================"
    echo "Loading docker image ${dock_img} ..."
    echo "======================================================"
	docker load < $dock_img
	ret_val=$?
    echo "======================================================"
    echo "Loaded docker image ${dock_img} ..."
    echo "Status ${ret_val} ..."  ## Should exit if not successful !
    echo "======================================================"
done

## Go back to where it all started
cd ../

echo "======================================================"
echo "Unpack jboxengine ..."
echo "======================================================"
\cp -rf jboxengine /
ret_val=$?
## TODO check if it is required to change ownership. It may not be required?
chown -R $USER:$USER /jboxengine
echo "======================================================"
echo "Unpacked jboxengine ..."
echo "Status ${ret_val} ..."  ## Should exit if not successful !
echo "======================================================"


echo "======================================================"
echo "Starting components ..."
echo "======================================================"

cd JuliaDeployment
./scripts/run/start.sh
ret_val=$?

echo "======================================================"
echo "Started components. ..."
echo "Status ${ret_val} ..."  ## Should exit if not successful !
echo "======================================================"


echo "======================================================"
echo "Validating components ..."
echo "======================================================"

num_containers=`docker ps -a | wc -l`

echo "======================================================"
if [$num_containers -ge 4]; then
	echo "Validation Successful !!!"
else
	echo "Validation Failed !!! Please check the log files for more information"
fi
echo "======================================================"


echo "======================================================"
echo "Validating API container ..."
echo "======================================================"

## TODO make a curl call to echo server to test the API container deployment

ret_val=`curl -v --data ";jsonString=\"Hello\""  http://api.ip-10-93-140-37/test/echo/ | cat - | grep "Hello" | wc -l`

echo "The ret_val is :: $ret_val"

echo "======================================================"
if [$ret_val != 0]; then
	echo "API Deployment Successful !!!"
else
	echo "API Deployment Failed !!! Please check the log files for more information"
fi
echo "======================================================"

echo
echo "Installation and Validation DONE !!!"
{'fraction_non_alphanumeric': 0.39742476851851855, 'fraction_numerical': 0.004195601851851852, 'mean_word_length': 5.278837420526794, 'pattern_counts': {'":': 0, '<': 5, '<?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': '1851063', 'n_tokens_mistral': 1797, 'n_tokens_neox': 1568, 'n_words': 598}