Last active
September 26, 2019 09:44
-
-
Save charmygarg/48a4dfb9bf68eee3d2f04e50096875e5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
ENVIRONMENTS=("dev2", "tst2", "shiptst1", "shiptst2", "stg1", "shipstg1") | |
SHIPS=("prd", "allure", "adventure", "anthem", "brilliance", "constellation", "edge", "enchantment", "equinox", "harmony", "independence", "liberty", "mariner", "majesty", "millennium", "navigator", "oasis", "ovation", "pursuit", "quantum", "reflection", "spectrum", "summit", "serenade", "symphony", "vision") | |
if [[ "$environmentGroup" == "dev" && "$environmentChoice" == "all" ]] | |
then | |
ENV_NAMES=("dev2") | |
elif [[ "$environmentGroup" == "test" && "$environmentChoice" == "all" ]] | |
then | |
ENV_NAMES=("tst2" "shiptst1" "shiptst2") | |
elif [[ "$environmentGroup" == "stage" && "$environmentChoice" == "all" ]] | |
then | |
ENV_NAMES=("stg1" "shipstg1") | |
elif [[ "$environmentGroup" == "prod" && "$environmentChoice" == "all" ]] | |
then | |
SHIP_NAMES=("prd" "allure" "adventure" "anthem" "brilliance" "constellation" "edge" "enchantment" "equinox" "harmony" "independence" "liberty" "mariner" "majesty" "millennium" "navigator" "oasis" "ovation" "pursuit" "quantum" "reflection" "spectrum" "summit" "serenade" "symphony" "vision") | |
elif [[ "$environmentGroup" == "prod" ]] | |
then | |
SHIP_NAMES=(${environmentChoice}) | |
else | |
ENV_NAMES=(${environmentChoice}) | |
fi | |
echo "Running for config $environmentGroup..." | |
SOURCE_COLLECTION=${sourceCollection} | |
DEST_COLLECTION=${destinationCollection} | |
FILTER=${filter} | |
lower_env_import_export_jenkins() | |
{ | |
for ENV in ${ENV_NAMES[*]} | |
do | |
if [[ "${ENVIRONMENTS[@]}" =~ "${ENV}" ]] | |
then | |
SOLR="http://${ENV}.mesos.rccl.com/solr-cloud/v3/solr" | |
import_export_jenkins "${SOLR}" "${SOLR}" "${ENV}" | |
else | |
echo "Incorrect environment choice!! Please enter (all) or specific environment from (${ENVIRONMENTS[*]}) " | |
fi | |
done | |
} | |
prod_import_export_jenkins() | |
{ | |
for SHIP in ${SHIP_NAMES[*]} | |
do | |
if [[ "${SHIPS[@]}" =~ "${SHIP}" ]] | |
then | |
if [[ "$SHIP" == "prd" ]] | |
then | |
SOURCE_SOLR="http://${SHIP}.mesos.rccl.com/solr-cloud/v3/solr" | |
DEST_SOLR="http://${SHIP}.mesos.rccl.com/solr-cloud/v3/solr" | |
else | |
SOURCE_SOLR="http://mesos.${SHIP}.sh.rccl.com/solr-cloud/v3/solr" | |
DEST_SOLR="http://mesos.${SHIP}.sh.rccl.com/solr-cloud/v3/solr" | |
fi | |
import_export_jenkins "${SOURCE_SOLR}" "${DEST_SOLR}" "${SHIP}" | |
else | |
echo "Incorrect ship choice!! Please enter specific ship from (${SHIPS[*]})" | |
fi | |
done | |
} | |
import_export_jenkins() | |
{ | |
local SOURCE_SOLR="$1" DEST_SOLR="$2" ENV="$3" | |
echo "**************************************" | |
FILE="${ENV}_${SOURCE_COLLECTION}_to_${DEST_COLLECTION}" | |
echo "Review Setup:" | |
echo "**************************************" | |
echo "SOURCE_SOLR: $SOURCE_SOLR" | |
echo "SOURCE_COLLECTION: $SOURCE_COLLECTION" | |
echo "DEST_SOLR: $DEST_SOLR" | |
echo "DEST_COLLECTION: $DEST_COLLECTION" | |
echo "FILTER: $FILTER" | |
echo "FILE: $FILE" | |
echo "**************************************" | |
docker run -e source_solr=${SOURCE_SOLR}/${SOURCE_COLLECTION} -e destination_solr=${DEST_SOLR}/${DEST_COLLECTION} -e file=${FILE} -e filter_query=${FILTER} -d charmygarg/dockerfile:importExport | |
} | |
if [[ "${#SHIP_NAMES[@]}" -ne 0 ]] | |
then | |
prod_import_export_jenkins | |
elif [[ "${#ENV_NAMES[@]}" -ne 0 ]] | |
then | |
lower_env_import_export_jenkins | |
else | |
echo "Incorrect ship choice!!" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment