diff --git a/config/tmux/tmux.conf.local b/config/tmux/tmux.conf.local index f458b9a..659059a 100644 --- a/config/tmux/tmux.conf.local +++ b/config/tmux/tmux.conf.local @@ -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 diff --git a/ssh_router.sh b/ssh_router.sh index 32aecf8..6b55977 100755 --- a/ssh_router.sh +++ b/ssh_router.sh @@ -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" diff --git a/start.sh b/start.sh index 39e7225..471f73f 100644 --- a/start.sh +++ b/start.sh @@ -1,2 +1,2 @@ #!/bin/bash -tmux -S /tmp/tmux-shared/dev-socket new-session -s analytics-backend +tmux new-session -s analytics-backend