github.com/weaveworks/common@v0.0.0-20230728070032-dd9e68f319d5/tools/socks/connect.sh (about) 1 #!/bin/bash 2 3 set -eu 4 5 if [ $# -ne 1 ]; then 6 echo "Usage: $0 <host>" 7 exit 1 8 fi 9 10 HOST=$1 11 12 echo "Starting proxy container..." 13 PROXY_CONTAINER=$(ssh "$HOST" weave run -d weaveworks/socksproxy) 14 15 function finish() { 16 echo "Removing proxy container.." 17 # shellcheck disable=SC2029 18 ssh "$HOST" docker rm -f "$PROXY_CONTAINER" 19 } 20 trap finish EXIT 21 22 # shellcheck disable=SC2029 23 PROXY_IP=$(ssh "$HOST" -- "docker inspect --format='{{.NetworkSettings.IPAddress}}' $PROXY_CONTAINER") 24 echo 'Please configure your browser for proxy http://localhost:8080/proxy.pac' 25 # shellcheck disable=SC2029 26 ssh "-L8000:$PROXY_IP:8000" "-L8080:$PROXY_IP:8080" "$HOST" docker attach "$PROXY_CONTAINER"