27 lines
717 B
Bash
27 lines
717 B
Bash
|
#!/usr/bin/env bash
|
||
|
set -eou pipefail
|
||
|
|
||
|
pipe="$(mktemp -u)"
|
||
|
trap "rm -f $pipe" EXIT
|
||
|
mkfifo "$pipe"
|
||
|
|
||
|
label="tmux-host-container-id"="$(head -c 32 /dev/urandom | base64)"
|
||
|
|
||
|
function interact() {
|
||
|
# Wait for the container to start
|
||
|
container_id=""
|
||
|
while [ -p "$pipe" ] && [ -z $container_id ]; do
|
||
|
container_id="$(podman container ps -f label="$label" --format "{{ .ID }}")"
|
||
|
done
|
||
|
|
||
|
while [ -p "$pipe" ]; do
|
||
|
if read line; then
|
||
|
echo $line
|
||
|
tmux split podman exec -it "$container_id" $line
|
||
|
fi
|
||
|
done <"$pipe"
|
||
|
}
|
||
|
interact &
|
||
|
container_name="pwntools"
|
||
|
podman run --rm --security-opt seccomp=unconfined --cap-add=SYS_PTRACE --label="$label" -v $PWD:/PWD -v "$pipe":"/tmux-sock" -it "$container_name" $@
|