Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 100 lines (87 sloc) 3.1 KB
#!/bin/bash
#
# Command Line Interface to start all services associated with the Getting-Started Tutorial
#
# For this tutorial the commands are merely a convenience script to run docker-compose
#
set -e
loadData () {
./import-data
./provision-devices
echo ""
}
waitForKeyrock () {
printf "⏳ Waiting for \033[1;31mKeyrock\033[0m to be available"
while [ `curl -s -o /dev/null -w %{http_code} 'http://localhost:3005/version'` -eq 000 ]
do
echo -e "Keyrock HTTP state: " `curl -s -o /dev/null -w %{http_code} 'http://localhost:3005/version'` " (waiting for 200)"
sleep 5
done
echo -e " \033[1;32mdone\033[0m"
}
displayServices () {
echo ""
docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}" --filter name=fiware-*
echo ""
}
startContainers () {
echo ""
export IDM_HTTPS_ENABLED="$1"
docker-compose --log-level ERROR -f docker-compose/$2 -p fiware up -d --remove-orphans
echo ""
}
stoppingContainers () {
echo "Stopping containers"
docker-compose --log-level ERROR -f docker-compose/iot-agent.yml -p fiware down -v --remove-orphans
}
if (( $# != 1 )); then
echo "Illegal number of parameters"
echo "usage: services [create|orion|iot-agent]"
exit 1
fi
command="$1"
case "${command}" in
"help")
echo "usage: services [create|orion|iot-agent]"
;;
"orion")
stoppingContainers
echo -e "Starting seven containers \033[1;34mOrion\033[0m, \033[1;36mIoT-Agent\033[0m, \033[1;31mKeyrock\033[0m, \033[1;31mWilma\033[0m, \033[1;30mTutorial\033[0m and \033[1;30mMongoDB\033[0m and \033[1;30mMySQL\033[0m databases."
echo -e "- \033[1;34mOrion\033[0m is the context broker"
echo -e "- \033[1;36mIoT-Agent\033[0m is configured for the UltraLight Protocol"
echo -e "- \033[1;30mTutorial\033[0m acts as a series of dummy IoT Sensors over HTTP"
echo -e "- \033[1;31mKeyrock\033[0m is an Identity Management Front-End"
echo -e "- \033[1;31mWilma\033[0m is a PEP Proxy for Orion"
startContainers false orion.yml
loadData
waitForKeyrock
displayServices
echo -e "Now open \033[4mhttp://localhost:3000\033[0m"
;;
"iot-agent")
stoppingContainers
echo -e "Starting eight containers \033[1;34mOrion\033[0m, \033[1;36mIoT-Agent\033[0m, \033[1;31mKeyrock\033[0m, \033[1;31mWilma\033[0m, \033[1;30mTutorial\033[0m and \033[1;30mMongoDB\033[0m and \033[1;30mMySQL\033[0m databases."
echo -e "- \033[1;34mOrion\033[0m is the context broker"
echo -e "- \033[1;36mIoT-Agent\033[0m is configured for the UltraLight Protocol"
echo -e "- \033[1;30mTutorial\033[0m acts as a series of dummy IoT Sensors over HTTP"
echo -e "- \033[1;31mKeyrock\033[0m is an Identity Management Front-End"
echo -e "- 2 instances of \033[1;31mWilma\033[0m as a PEP Proxy for Orion and IoT Agent"
startContainers false iot-agent.yml
loadData
waitForKeyrock
displayServices
echo -e "Now open \033[4mhttp://localhost:3000\033[0m"
;;
"stop")
stoppingContainers
;;
"create")
echo "Pulling Docker images"
docker-compose --log-level ERROR -f docker-compose/orion.yml -p fiware pull
;;
*)
echo "Command not Found."
echo "usage: services [create|orion|iot-agent|stop]"
exit 127;
;;
esac
You can’t perform that action at this time.