feat: remove socket path from commands

This commit is contained in:
yeti 2025-04-18 03:25:46 +01:00
parent 2dd0150935
commit 6cf8dbd73a
3 changed files with 12 additions and 12 deletions

View File

@ -455,6 +455,8 @@ set -g allow-passthrough on
# Enable truecolor for compatible terminals
set -gs terminal-features ',rxvt-unicode-256color:clipboard'
set-option -g socket-path /tmp/tmux-shared/dev-socket
# -- custom variables ----------------------------------------------------------
# to define a custom #{foo} variable, define a POSIX shell function between the

View File

@ -7,8 +7,6 @@ IMAGE="analytics-backend-workspace" # change to match your setup
TMUX_SESSION="analytics-backend"
DEV_USER="devuser"
TMUX_CMD=(tmux -S /tmp/tmux-shared/dev-socket)
log() {
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*"
}
@ -40,7 +38,7 @@ start_container_if_needed() {
# After devuser exits...
check_devuser_attached() {
# Get list of clients
client_users=$(podman exec "$CONTAINER" "${TMUX_CMD[@]}" list-clients -t "$TMUX_SESSION" -F "#{client_user}" 2>/dev/null)
client_users=$(podman exec "$CONTAINER" tmux list-clients -t "$TMUX_SESSION" -F "#{client_user}" 2>/dev/null)
if echo "$client_users" | grep -q "$DEV_USER"; then
log "💡 devuser still attached — container stays running"
@ -58,17 +56,17 @@ case "$MODE" in
rw)
start_container_if_needed
# Run $TMUX_CMD session inside the container
if ! podman exec -it --user "$DEV_USER" "$CONTAINER" "${TMUX_CMD[@]}" has-session -t "$TMUX_SESSION" >/dev/null 2>&1; then
if ! podman exec -it --user "$DEV_USER" "$CONTAINER" "${TMUX_CMD[@]}" new-session -d -s "$TMUX_SESSION" >/dev/null 2>&1; then
log "❌ Could not create new ${TMUX_CMD[*]} session. Please contact admin or try again later."
# Run tmux session inside the container
if ! podman exec -it --user "$DEV_USER" "$CONTAINER" tmux has-session -t "$TMUX_SESSION" >/dev/null 2>&1; then
if ! podman exec -it --user "$DEV_USER" "$CONTAINER" tmux new-session -d -s "$TMUX_SESSION" >/dev/null 2>&1; then
log "❌ Could not create new tmux session. Please contact admin or try again later."
exit 1
fi
fi
log "$PERSON is working on $CONTAINER"
if ! podman exec -it --user "$DEV_USER" "$CONTAINER" "${TMUX_CMD[@]}" attach -t "$TMUX_SESSION"; then
log "❌ Could not attach to ${TMUX_CMD[*]} session. Please contact admin or try again later."
if ! podman exec -it --user "$DEV_USER" "$CONTAINER" tmux attach -t "$TMUX_SESSION"; then
log "❌ Could not attach to tmux session. Please contact admin or try again later."
exit 1
fi
log "$PERSON finished working on $CONTAINER"
@ -79,8 +77,8 @@ rw)
ro)
if (podman container exists "$CONTAINER" && podman inspect -f '{{.State.Running}}' "$CONTAINER" | grep -q true) >/dev/null 2>&1; then
log "📜 $PERSON is viewing $CONTAINER"
if ! podman exec -it --user "$DEV_USER" "$CONTAINER" "${TMUX_CMD[@]}" attach -r -t "$TMUX_SESSION"; then
log "❌ Could not attach to ${TMUX_CMD[*]} session. Please contact admin or try again later."
if ! podman exec -it --user "$DEV_USER" "$CONTAINER" tmux attach -r -t "$TMUX_SESSION"; then
log "❌ Could not attach to tmux session. Please contact admin or try again later."
exit 1
fi
log "🏃 $PERSON stopped viewing $CONTAINER"

View File

@ -1,2 +1,2 @@
#!/bin/bash
tmux -S /tmp/tmux-shared/dev-socket new-session -s analytics-backend
tmux new-session -s analytics-backend