From 1b086c8b09d9f3abad6b00dcffc381edb43a4a24 Mon Sep 17 00:00:00 2001 From: Sowmiya Nagarajan Date: Sun, 29 Mar 2020 13:16:46 +0530 Subject: [PATCH 1/2] Adding mosified script for brew --- stackbox-brew.sh | 164 ++++++++++++++++++++++++++++++++++++ stack_box.sh => stackbox.sh | 0 2 files changed, 164 insertions(+) create mode 100644 stackbox-brew.sh rename stack_box.sh => stackbox.sh (100%) diff --git a/stackbox-brew.sh b/stackbox-brew.sh new file mode 100644 index 0000000..36a6706 --- /dev/null +++ b/stackbox-brew.sh @@ -0,0 +1,164 @@ +#!/bin/bash + +echo " _ _ _" +echo " ___| |_ __ _ ___| | _| |__ _____ __" +echo "/ __| __/ _ |/ __| |/ / '_ \ / _ \ \/ /" +echo "\__ \ || (_| | (__| <| |_) | (_) > <" +echo '|___/\__\__,_|\___|_|\_\_.__/ \___/_/\_\' +echo "\n" + +echo "######## SELECT YOUR STACK #############\n" + +stack=() + +PS3='Select your frontend: ' + +echo "FRONTEND OPTIONS:" + +frontend_options=("Vue") +select opt in "${frontend_options[@]}" +do + case $opt in + "Vue") + echo "You've chosen Vue" + stack+=("vue") + break; + ;; + *) echo "Invalid option $REPLY";; + esac +done + +PS3='Select your backend: ' + +echo "BACKEND OPTIONS:" + +backend_options=("Flask" "Rails") +select opt in "${backend_options[@]}" +do + case $opt in + "Flask") + echo "You've chosen Flask" + stack+=("flask") + break; + ;; + "Rails") + echo "You've chosen Rails" + stack+=("rubyonrails") + break; + ;; + *) echo "Invalid option $REPLY";; + esac +done + +printf "\n" +PS3='Add your services. Choose 5 to finish adding: ' + +echo "SERVICE OPTIONS:" +service_options=("MySQL" "Kafka" "Elasticsearch" "Nginx" "Done") +select opt in "${service_options[@]}" +do + case $opt in + "MySQL") + echo "You've chosen MySQL" + stack+=("mysql") + continue; + ;; + "Kafka") + echo "You've chosen Kafka. Zookeper will also be set up." + stack+=("kafka") + stack+=("zookeeper") + continue; + ;; + "Elasticsearch") + echo "You've chosen Elasticsearch" + stack+=("elasticsearch") + # shellcheck disable=SC2162 + read -p "Do you want Kibana as well? (y/n)" yn + case $yn in + [Yy]* ) + echo "You've chosen Kibana + Elasticsearch" + stack+=("kibana") + continue;; + [Nn]* ) + echo "You've chosen Elasticsearch without Kibana" + continue;; + * ) echo "Please answer yes or no.";; + esac + ;; + "Nginx") + echo "You've chosen Nginx" + stack+=("nginx") + continue; + ;; + "Done") + break + ;; + *) echo "Invalid option $REPLY";; + esac +done + +printf "\n" +printf "The services you've chosen are: " +echo "${stack[*]}" +printf "\n" + +echo "######## BUILDING YOUR STACK ###############\n" + +beginswith() { case $2 in "$1"*) true;; *) false;; esac; } + +python_version=$(python --version) +python3_version=$(python3 --version) + +if beginswith "Python 3" "$python_version" ; +then + var="$(pip --disable-pip-version-check install -r ../requirements.txt) > /dev/null " + python ../stack.py ${stack[*]} +elif beginswith "Python 3" "$python3_version"; +then + var="$(pip3 --disable-pip-version-check install -r ../requirements.txt) > /dev/null" + python3 ../stack.py ${stack[*]} +else + echo "Unable to find a python 3 installation" +fi + +docker-compose -f ../docker-compose.yml down 2> /dev/null > logs/docker-compose-down-log.txt +docker-compose -f ../docker-compose.yml build > logs/docker-compose-build-log.txt + +echo "\n######## DEPLOYING YOUR STACK ##############\n" + +docker-compose -f ../docker-compose.yml up -d --remove-orphans + +sleep 5 + +echo "\n######## YOUR STACK ########################\n" + +containers=$(docker ps --format '{{.Names}}') +ports="$(docker ps --format '{{.Ports}}')" + +service_ports=() + +for port in $ports; +do + if beginswith "0.0.0.0" "$port"; + then + port1=$(echo "$port" | awk -F[:-] '{print $2}') + service_ports+=("$port1") + fi +done + +i=-1 + +for container in $containers; +do + i=$i+1 + if [ "$container" != "registry" ]; + then + if beginswith "stackbox" "$container"; + then + tmp=${container%"_1"} + echo ${tmp#"stackbox_"} is up at http://localhost:${service_ports[i]} + fi + fi +done + +echo "\n" \ No newline at end of file diff --git a/stack_box.sh b/stackbox.sh similarity index 100% rename from stack_box.sh rename to stackbox.sh From cedbb39dab120ede692be3463d2330565073c7f7 Mon Sep 17 00:00:00 2001 From: Sowmiya Nagarajan Date: Sun, 29 Mar 2020 13:17:14 +0530 Subject: [PATCH 2/2] Renaming starter scrip[t --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6b6188e..fc70221 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ Stackbox helps you create app stacks loaded with all your favourite clients, ser # Get Started ## Run -`sh stack_box.sh ` +`sh stackbox.sh` Jump to [_**example-stacks**_](https://github.com/Stack-Box/StackBox/blob/master/README.md#example-stacks) to quickly try a run @@ -51,7 +51,7 @@ The following is a list of example stacks you could spin-up using Stackbox and q ### 1. Flask-Vue-Mysql-Elasticsearch #### Run -`sh stack_box.sh` +`sh stackbox.sh` #### Test After the run is finished, the final log should look like the one below.