Skip to content

Commit e3db5c7

Browse files
committed
Refactor kubetap-entrypoint.sh to improve config file handling and enhance logging for better debugging
1 parent 851a017 commit e3db5c7

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

proxies/mitmproxy/kubetap-entrypoint.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@ set -o nounset
66

77
# HACK: this fixes permission issues
88
# Ensure the .mitmproxy directory exists and is writable
9-
# Note: We skip this if we don't have permissions, as the directory should
10-
# already exist from the Dockerfile
119
if [ -d /home/mitmproxy/.mitmproxy ] && [ -w /home/mitmproxy/.mitmproxy ]; then
1210
# Only copy the config file if it exists and we have read access
1311
if [ -f /home/mitmproxy/config/config.yaml ] && [ -r /home/mitmproxy/config/config.yaml ]; then
1412
cp /home/mitmproxy/config/config.yaml /home/mitmproxy/.mitmproxy/config.yaml
13+
echo "Config file copied to /home/mitmproxy/.mitmproxy/config.yaml" >&2
14+
else
15+
echo "Warning: Config file not found or not readable at /home/mitmproxy/config/config.yaml" >&2
1516
fi
17+
else
18+
echo "Warning: .mitmproxy directory not found or not writable" >&2
1619
fi
1720

1821
prog="${1}"
@@ -23,17 +26,19 @@ if [[ "${1}" == 'mitmdump' || "${1}" == 'mitmproxy' || "${1}" == 'mitmweb' ]]; t
2326
if [[ "${1}" == 'mitmproxy' ]]; then
2427
# Start a tmux session with mitmproxy to allow interactive access without requiring a TTY
2528
# Users can 'kubectl exec -it <pod> -- tmux attach-session -t mitmproxy' to interact
26-
# Use -c to specify a new window command, avoiding terminal requirement at session creation
29+
echo "Starting mitmproxy in tmux session with confdir=${MITMPROXY_PATH}" >&2
2730
tmux new-session -d -s mitmproxy -c /home/mitmproxy \
2831
mitmproxy --set "confdir=${MITMPROXY_PATH}" "${@:2}"
2932

30-
# Keep the container running - tail a log or sleep indefinitely
33+
# Keep the container running - sleep indefinitely
3134
# This allows users to attach via: kubectl exec -it <pod> -- tmux attach-session -t mitmproxy
3235
sleep infinity
3336
else
3437
# For mitmdump or mitmweb (or other commands), use direct execution
38+
echo "Starting ${prog} with confdir=${MITMPROXY_PATH}" >&2
3539
exec "${@}" --set "confdir=${MITMPROXY_PATH}"
3640
fi
3741
else
42+
echo "Running command: ${@}" >&2
3843
exec "${@}"
3944
fi

0 commit comments

Comments
 (0)