Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 149 lines (139 sloc) 5.98 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 ""
}
stoppingContainers () {
echo "Stopping containers"
docker-compose --log-level ERROR -f docker-compose/multiple.yml -p fiware down -v --remove-orphans
echo "Removing HDFS files"
for dir in ./docker-compose/data/*; do
[ "$dir" = "./docker-compose/data" ] && continue
rm -rf "$dir"
done
}
displayServices () {
echo ""
docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}" --filter name=fiware-*
echo ""
}
displayHDFS () {
echo ""
docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}" --filter name=hdfs-*
echo ""
}
displayCKAN () {
echo ""
docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}" --filter name=ckan*
echo ""
}
if (( $# != 1 )); then
echo "Illegal number of parameters"
echo "usage: services [create|ckan|hdfs|mongodb|mysql|multiple|postgres|stop]"
exit 1
fi
command="$1"
case "${command}" in
"help")
echo "usage: services [create|ckan|hdfs|mongodb|mysql|multiple|postgres|stop]"
;;
"multiple")
stoppingContainers
echo -e "Starting seven containers \033[1;34mOrion\033[0m, \033[1;34mCygnus\033[0m, \033[1;36mIoT-Agent\033[0m, \033[1mTutorial\033[0m and \033[1mMongoDB\033[0m, \033[1mPostgreSQL\033[0m and \033[1mMySQL\033[0m databases."
echo -e "- \033[1;34mOrion\033[0m is the context broker"
echo -e "- \033[1;34mCygnus\033[0m is configured to write context data to Mongo-DB, PostgeSQL and MySQL"
echo -e "- \033[1;36mIoT-Agent\033[0m is configured for the UltraLight Protocol"
echo -e "- \033[1mTutorial\033[0m acts as a series of dummy IoT Sensors over HTTP"
echo ""
docker-compose --log-level ERROR -f docker-compose/multiple.yml -p fiware up -d --remove-orphans
loadData
displayServices
echo -e "Now open \033[4mhttp://localhost:3000/device/monitor\033[0m"
;;
"ckan")
stoppingContainers
echo -e "Starting six containers \033[1;34mOrion\033[0m, \033[1;34mCygnus\033[0m, \033[1;36mIoT-Agent\033[0m, \033[1mTutorial\033[0m and a \033[1mMongoDB\033[0m database and a \033[1mCKAN\033[0m system."
echo -e "- \033[1;34mOrion\033[0m is the context broker"
echo -e "- \033[1;34mCygnus\033[0m is configured to write context data to MySQL only"
echo -e "- \033[1;36mIoT-Agent\033[0m is configured for the UltraLight Protocol"
echo -e "- \033[1mTutorial\033[0m acts as a series of dummy IoT Sensors over HTTP"
echo ""
docker-compose -f docker-compose/ckan.yml -p fiware up -d --remove-orphans
loadData
displayServices
displayCKAN
echo -e "Now open \033[4mhttp://localhost:3000/device/monitor\033[0m"
;;
"hdfs")
stoppingContainers
echo -e "Starting six containers \033[1;34mOrion\033[0m, \033[1;34mCygnus\033[0m, \033[1;36mIoT-Agent\033[0m, \033[1mTutorial\033[0m and a \033[1mMongoDB\033[0m database and a \033[1mHDFS\033[0m filesystem."
echo -e "- \033[1;34mOrion\033[0m is the context broker"
echo -e "- \033[1;34mCygnus\033[0m is configured to write context data to MySQL only"
echo -e "- \033[1;36mIoT-Agent\033[0m is configured for the UltraLight Protocol"
echo -e "- \033[1mTutorial\033[0m acts as a series of dummy IoT Sensors over HTTP"
echo ""
docker-compose -f docker-compose/hdfs.yml -p fiware up -d --remove-orphans
loadData
displayServices
displayHDFS
echo -e "Now open \033[4mhttp://localhost:3000/device/monitor\033[0m"
;;
"mongodb")
stoppingContainers
echo -e "Starting five containers \033[1;34mOrion\033[0m, \033[1;34mCygnus\033[0m, \033[1;36mIoT-Agent\033[0m, \033[1mTutorial\033[0m and a \033[1mMongoDB\033[0m database."
echo -e "- \033[1;34mOrion\033[0m is the context broker"
echo -e "- \033[1;34mCygnus\033[0m is configured to write context data to Mongo-DB only"
echo -e "- \033[1;36mIoT-Agent\033[0m is configured for the UltraLight Protocol"
echo -e "- \033[1mTutorial\033[0m acts as a series of dummy IoT Sensors over HTTP"
echo ""
docker-compose --log-level ERROR -f docker-compose/mongodb.yml -p fiware up -d --remove-orphans
loadData
displayServices
echo -e "Now open \033[4mhttp://localhost:3000/device/monitor\033[0m"
;;
"postgres")
stoppingContainers
echo -e "Starting six containers \033[1;34mOrion\033[0m, \033[1;34mCygnus\033[0m, \033[1;36mIoT-Agent\033[0m, \033[1mTutorial\033[0m and \033[1mMongoDB\033[0m and \033[1mPostgreSQL\033[0m databases."
echo -e "- \033[1;34mOrion\033[0m is the context broker"
echo -e "- \033[1;34mCygnus\033[0m is configured to write context data to PostgreSQL only"
echo -e "- \033[1;36mIoT-Agent\033[0m is configured for the UltraLight Protocol"
echo -e "- \033[1mTutorial\033[0m acts as a series of dummy IoT Sensors over HTTP"
echo ""
docker-compose --log-level ERROR -f docker-compose/postgres.yml -p fiware up -d --remove-orphans
loadData
displayServices
echo -e "Now open \033[4mhttp://localhost:3000/device/monitor\033[0m"
;;
"mysql")
stoppingContainers
echo -e "Starting six containers \033[1;34mOrion\033[0m, \033[1;34mCygnus\033[0m, \033[1;36mIoT-Agent\033[0m, \033[1mTutorial\033[0m and \033[1mMongoDB\033[0m and \033[1mMySQL\033[0m databases."
echo -e "- \033[1;34mOrion\033[0m is the context broker"
echo -e "- \033[1;34mCygnus\033[0m is configured to write context data to MySQL only"
echo -e "- \033[1;36mIoT-Agent\033[0m is configured for the UltraLight Protocol"
echo -e "- \033[1mTutorial\033[0m acts as a series of dummy IoT Sensors over HTTP"
echo ""
docker-compose -f docker-compose/mysql.yml -p fiware up -d --remove-orphans
loadData
displayServices
echo -e "Now open \033[4mhttp://localhost:3000/device/monitor\033[0m"
;;
"stop")
stoppingContainers
;;
"create")
echo "Pulling Docker images"
docker-compose --log-level ERROR -f docker-compose/multiple.yml -p fiware pull
;;
*)
echo "Command not Found."
echo "usage: services [create|ckan|hdfs|mongodb|mysql|multiple|postgres|stop]"
exit 127;
;;
esac
You can’t perform that action at this time.