feat(ssh): add information about the person logging in
This commit is contained in:
parent
f928ab5a0f
commit
c4e196f4af
@ -1,6 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
MODE="$1" # 'rw' or 'readonly'
|
||||
PERSON="$2"
|
||||
CONTAINER="$SSH_ORIGINAL_COMMAND"
|
||||
IMAGE="analytics-backend-workspace" # change to match your setup
|
||||
TMUX_SESSION="analytics-backend"
|
||||
@ -45,7 +46,7 @@ check_devuser_attached() {
|
||||
log "💡 devuser still attached — container stays running"
|
||||
return 0
|
||||
else
|
||||
log "⚠️ $CONTAINER has exited — stopping container"
|
||||
log "🏃 $PERSON has logged out — stopping container"
|
||||
podman stop "$CONTAINER" >/dev/null 2>&1
|
||||
return 1
|
||||
fi
|
||||
@ -64,8 +65,8 @@ rw)
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
log "⚡ $CONTAINER reattaching..."
|
||||
if ! podman exec -it --user "$DEV_USER" "$CONTAINER" "${TMUX_CMD[@]}" attach -t "$TMUX_SESSION" 2>/dev/null; then
|
||||
log "⚡ $PERSON is logging in..."
|
||||
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."
|
||||
exit 1
|
||||
fi
|
||||
@ -76,10 +77,12 @@ 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..."
|
||||
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."
|
||||
exit 1
|
||||
fi
|
||||
log "🏃 $PERSON stopped viewing..."
|
||||
exit 0
|
||||
else
|
||||
log "❌ Container $CONTAINER does not exist."
|
||||
|
Loading…
x
Reference in New Issue
Block a user