Improve script/mitm-proxy.sh to support podman (#25834)
This commit is contained in:
parent
760d08711c
commit
53b2792844
1 changed files with 16 additions and 4 deletions
|
@ -1,10 +1,22 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
set -e
|
set -euo pipefail
|
||||||
|
|
||||||
CONTAINER_ID=$(docker run -d --rm -it -v ~/.mitmproxy:/home/mitmproxy/.mitmproxy -p 9876:8080 mitmproxy/mitmproxy mitmdump)
|
if command -v docker >/dev/null 2>&1; then
|
||||||
|
ENGINE="docker"
|
||||||
|
elif command -v podman >/dev/null 2>&1; then
|
||||||
|
ENGINE="podman"
|
||||||
|
else
|
||||||
|
echo "Neither Docker nor Podman found. Please install one of them."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ ! -d ~/.mitmproxy ]; then
|
||||||
|
mkdir -p ~/.mitmproxy
|
||||||
|
fi
|
||||||
|
|
||||||
trap 'docker stop '"$CONTAINER_ID"' 1> /dev/null || true; exit 1' SIGINT
|
CONTAINER_ID="$(${ENGINE} run -d --rm -it -v ~/.mitmproxy:/home/mitmproxy/.mitmproxy -p 9876:8080 mitmproxy/mitmproxy mitmdump)"
|
||||||
|
|
||||||
|
trap "${ENGINE} stop \"$CONTAINER_ID\" 1> /dev/null || true; exit 1" SIGINT
|
||||||
|
|
||||||
echo "Add the root certificate created in ~/.mitmproxy to your certificate chain for HTTP"
|
echo "Add the root certificate created in ~/.mitmproxy to your certificate chain for HTTP"
|
||||||
echo "on macOS:"
|
echo "on macOS:"
|
||||||
|
@ -15,4 +27,4 @@ read
|
||||||
http_proxy=http://localhost:9876 cargo run
|
http_proxy=http://localhost:9876 cargo run
|
||||||
|
|
||||||
# Clean up detached proxy after running
|
# Clean up detached proxy after running
|
||||||
docker stop "$CONTAINER_ID" 2>/dev/null || true
|
${ENGINE} stop "${CONTAINER_ID}" 2>/dev/null || true
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue