diff --git a/Makefile b/Makefile index f0b413a6..790d2231 100644 --- a/Makefile +++ b/Makefile @@ -53,7 +53,7 @@ build: .init @/bin/bash -c "./docker.sh create " .prepare: - /bin/bash -c 'docker run -it -v ${PWD}/iotanalytics-dashboard:/app openiotconnector_dashboard /bin/bash -c \ + @/bin/bash -c 'docker run -it -v ${PWD}/iotanalytics-dashboard:/app openiotconnector_dashboard /bin/bash -c \ "/app/public-interface/scripts/docker-prepare.sh"' @touch $@ @@ -63,13 +63,11 @@ build-force: .init start: build .prepare @$(call msg,"Starting IoT connector ..."); - @sudo /bin/bash -c "( (service --status-all | grep -q redis-server) && (systemctl stop redis-server) ) || true" - @sudo /bin/bash -c "./docker.sh up -d" + @/bin/bash -c "./docker.sh up -d" stop: @$(call msg,"Stopping IoT connector ..."); - @sudo /bin/bash -c "./docker.sh stop" - @sudo /bin/bash -c "docker stop redsocks" + @/bin/bash -c "./docker.sh stop" update: @$(call msg,"Git Update ..."); diff --git a/docker.sh b/docker.sh index eaab6e1d..5117ca87 100755 --- a/docker.sh +++ b/docker.sh @@ -3,18 +3,24 @@ # Set env for application . ./setup-environment.sh +redsocks_container_name='redsocks' + if [ -n "$http_proxy" ] && [ -n "$https_proxy" ] && [ "$1" == "up" ]; then # Run redsocks to allow containers to use proxy - container_name='redsocks' - if ! [[ $(docker ps -f "name=$container_name" --format '{{.Names}}') == $container_name ]]; then + + if ! [[ $(docker ps -f "name=$redsocks_container_name" --format '{{.Names}}') == $redsocks_container_name ]]; then echo "Starting redsocks..." - docker run -d --net=host --privileged --name $container_name --rm -e http_proxy=$http_proxy -e https_proxy=$https_proxy klabs/forgetproxy + docker run -d --net=host --privileged --name $redsocks_container_name --rm -e http_proxy=$http_proxy -e https_proxy=$https_proxy klabs/forgetproxy echo fi fi -# Start containers docker-compose $* +if [ "$1" == "stop" ]; then + if [[ $(docker ps -f "name=$redsocks_container_name" --format '{{.Names}}') == $redsocks_container_name ]]; then + docker stop $redsocks_container_name + fi +fi