Skip to content

Commit

Permalink
Fix redsocks error message if not started. Closes Open-IoT-Service-Pl…
Browse files Browse the repository at this point in the history
  • Loading branch information
nevets963 authored and wagmarcel committed Jan 10, 2018
1 parent 87ac2b9 commit da1f5ef
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
8 changes: 3 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 $@

Expand All @@ -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 ...");
Expand Down
14 changes: 10 additions & 4 deletions docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit da1f5ef

Please sign in to comment.