Skip to content
This repository has been archived by the owner on Jul 1, 2020. It is now read-only.

Commit

Permalink
Aggiunti mr_wolf e docker-compose
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxelweb committed May 6, 2020
1 parent 37f7e8e commit 68be5b0
Show file tree
Hide file tree
Showing 2 changed files with 217 additions and 0 deletions.
54 changes: 54 additions & 0 deletions docker-compose.riot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#
# Version 1
#
# ___ __ ___ __ ___ __ _
# / _ \___ ___/ / / _ \___ __ _____ ___/ / / _ \___ / / (_)__
# / , _/ -_) _ / / , _/ _ \/ // / _ \/ _ / / , _/ _ \/ _ \/ / _ \
# /_/|_|\__/\_,_/ /_/|_|\___/\_,_/_//_/\_,_/ /_/|_|\___/_.__/_/_//_/
#
#

version: '3'

networks:
kafka-net:
driver: bridge

services:
api:
container_name: thirema-api
build: ./api
networks:
- kafka-net
ports:
- "9999:9999"

telegram_bot:
container_name: thirema-telegram-bot
build: ./telegram
networks:
- kafka-net
ports:
- "3000:3000"

gateway:
container_name: thirema-gateway
build: ./gateway
networks:
- kafka-net

data_collector:
container_name: thirema-data-collector
build: ./kafka-db
networks:
- kafka-net

webapp:
container_name: thirema-webapp
build: ./webapp
networks:
- kafka-net
ports:
- "80:8000"


163 changes: 163 additions & 0 deletions mr_wolf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
#!/bin/sh

# Version 1
# ___ __ ___ __ ___ __ _
# / _ \___ ___/ / / _ \___ __ _____ ___/ / / _ \___ / / (_)__
# / , _/ -_) _ / / , _/ _ \/ // / _ \/ _ / / , _/ _ \/ _ \/ / _ \
# /_/|_|\__/\_,_/ /_/|_|\___/\_,_/_//_/\_,_/ /_/|_|\___/_.__/_/_//_/
#
# mr_wolf.sh - i solve problems for RIoT (Project ThiReMa)
#

GREEN='\033[0;32m'
ORANGE='\033[0;33m'
RED='\033[0;31m'
NC='\033[0m' # No Color


startingmessage () {
echo "${GREEN}[Mr. Wolf]${NC} $1"
echo "${NC}============================================="
}

finalmessage () {
echo "${NC} ============================================="
echo "${NC}> ${ORANGE}Mr. Wolf ${GREEN} solved our ${RED} problems ${NC} <"
}

errormex () {
echo "${RED}[Errore:] $1"
}

dockercompose_cmd () {
docker-compose \
-f riot/docker-compose.yml \
-f riot/docker-compose.riot.yml \
$1
}

dockercompose_status () {
dockercompose_cmd "ps"
}

dockercompose_up () {
echo "${ORANGE}[Mr. Wolf] ${NC} Installazione e avvio dei container Docker in corso..."
dockercompose_cmd "up --build -d"
echo "${ORANGE}[Mr. Wolf] ${GREEN} Avvio dei container completato!"
}


dockercompose_start () {
echo "${ORANGE}[Mr. Wolf] ${NC} Avvio dei container Docker in corso..."
dockercompose_cmd "start"
echo "${ORANGE}[Mr. Wolf] ${GREEN} Avvio dei container completato!"
}

dockercompose_stop () {
echo "${ORANGE}[Mr. Wolf] ${NC} Stop dei servizi attivi ..."
dockercompose_cmd "stop"
echo "${ORANGE}[Mr. Wolf] ${GREEN} Stop eseguito!"
}

dockercompose_down () {
echo "${ORANGE}[Mr. Wolf] ${NC} Rimozione dei servizi attivi, delle immagini e dei volumi ..."
dockercompose_cmd "down -v"
docker image prune -f
echo "${ORANGE}[Mr. Wolf] ${GREEN} Rimozione eseguita!"
}


if [ $# = 0 ] || [ $1 = "help" ]
then
echo " "
echo "I'm Mr Wolf. Tell me what the problem is.. "
echo "[USAGE:] ${ORANGE}mr_wolf.sh ${NC}[command]"
echo " ${NC}"
echo "${NC}help ${NC}Comandi di aiuto per lo script"
echo "${NC}status ${NC}Status dei servizi RIoT"
echo "${GREEN}init ${NC}Prima installazione e avvio di tutti i servizi RIoT"
echo "${GREEN}start ${NC}Avvio di tutti i servizi RIoT"
echo "${ORANGE}stop ${NC}Stop di tutti i servizi RIoT"
echo "${RED}remove ${NC}Stop e rimozione di tutti i servizi RIoT"

elif [ $1 = "init" ]
then
if [ -f "./riot/riot-installed.lock" ]
then
errormex "È già presente un'installazione di RIoT. Esegui prima [remove], oppure cancella la cartella (riot/) prima di continuare."
exit 1
fi

startingmessage "Avvio della prima installazione di RIoT"
echo "${ORANGE}[Mr. Wolf] ${NC} Copia delle componenti software ..."
mkdir riot
cp -r kafka-db riot/kafka-db
cp -r gateway riot/gateway
cp -r api riot/api
cp -r telegram riot/telegram
cp -r webapp riot/webapp
cp ./docker-compose.riot.yml riot/
mv ./riot/kafka-db/kafka/* riot/
touch ./riot/riot-installed.lock
echo "${ORANGE}[Mr. Wolf] ${GREEN} Componenti copiate con successo!"
dockercompose_up
finalmessage
exit 0

elif [ $1 = "status" ]
then
if [ ! -f "./riot/riot-installed.lock" ]
then
errormex "Nessuna installazione del prodotto trovata."
exit 1
fi
startingmessage "Status dei servizi RIoT"
dockercompose_status
exit 0

elif [ $1 = "start" ]
then
if [ ! -f "./riot/riot-installed.lock" ]
then
errormex "Nessuna installazione del prodotto trovata."
exit 1
fi
startingmessage "Avvio dei servizi RIoT"
dockercompose_start
finalmessage
exit 0

elif [ $1 = "stop" ]
then
if [ ! -f "./riot/riot-installed.lock" ]
then
errormex "Nessuna installazione del prodotto trovata."
exit 1
fi
startingmessage "Stop dei servizi RIoT"
dockercompose_stop
finalmessage
exit 0

elif [ $1 = "remove" ]
then
if [ ! -f "./riot/riot-installed.lock" ]
then
errormex "Nessuna installazione del prodotto trovata."
exit 1
fi
echo "La rimozione di RIoT comporta la rimozione delle dangling images da docker, dei volumi e dei container."
read -r -p "Sei sicuro di voler proseguire? [y/N] " response
if [ "$response" = "y" ] || [ "$response" = "Y" ]
then
startingmessage "Stop e rimozione dei servizi RIoT dalla macchina.."
dockercompose_down
rm -rf ./riot/
finalmessage
else
echo "Pericolo scampato :)"
fi

exit 0
fi

0 comments on commit 68be5b0

Please sign in to comment.