Compare commits

...

4 Commits

Author SHA1 Message Date
Pallav Vasa
fa06fbb9dd fix: update save path of authorized_keys 2025-05-20 14:47:35 +00:00
Pallav Vasa
4f0e173ce2 chore: add -r to yq to return quated strings 2025-05-20 14:46:57 +00:00
Pallav Vasa
aebb5eab85 feat: update logic to connect to start and attach tmux 2025-05-20 14:45:33 +00:00
Pallav Vasa
e298ee43c2 feat: change permissions on home.tar.gz to read only (600) 2025-05-20 09:27:15 +00:00
2 changed files with 18 additions and 10 deletions

View File

@@ -159,11 +159,14 @@ update)
case "${args[0]}" in case "${args[0]}" in
containerfile) update 0 Containerfile . 500 ;; containerfile) update 0 Containerfile . 500 ;;
access) update 2 access.yml . 400 ;; access) update 2 access.yml . 400 ;;
authorized_keys) update 2 authorized_keys . 400 ;; authorized_keys) update 2 authorized_keys .ssh 400 ;;
ssh_router) update 1 ssh_router.sh .local/bin 500 ;; ssh_router) update 1 ssh_router.sh .local/bin 500 ;;
gitops_router) update 1 gitops_router.sh .local/bin 500 ;; gitops_router) update 1 gitops_router.sh .local/bin 500 ;;
validate_command) update 1 validate_command_access.sh .local/bin 500 ;; validate_command) update 1 validate_command_access.sh .local/bin 500 ;;
home_tar) podman cp "$PERSON":/app/workspaces/home.tar.gz "$HOME"/ ;; home_tar)
podman cp "$PERSON":/app/workspaces/home.tar.gz "$HOME"/
chmod 600 "$HOME"/home.tar.gz
;;
gitconfig) update 0 gitconfig.template . 500 ;; gitconfig) update 0 gitconfig.template . 500 ;;
*) log ERROR "update: invalid arg '${args[0]}'" ;; *) log ERROR "update: invalid arg '${args[0]}'" ;;
esac esac

View File

@@ -98,8 +98,8 @@ generate_gitconfig() {
local userdir="$HOME/secrets/$ws" local userdir="$HOME/secrets/$ws"
local name email local name email
name=$(yq ".\"$ws\".name" "$access" 2>/dev/null || echo) name=$(yq -r ".\"$ws\".name" "$access" 2>/dev/null || echo)
email=$(yq ".\"$ws\".email" "$access" 2>/dev/null || echo) email=$(yq -r ".\"$ws\".email" "$access" 2>/dev/null || echo)
if [[ -z "$name" || -z "$email" ]]; then if [[ -z "$name" || -z "$email" ]]; then
log ERROR "Missing name/email for '$ws' in $access" log ERROR "Missing name/email for '$ws' in $access"
@@ -178,16 +178,21 @@ case "$MODE" in
rw) rw)
start_container_if_needed start_container_if_needed
# Ensure tmux session exists
if ! podman exec -it --user "$DEV_USER" "$WORKSPACE" tmux has-session -t "$TMUX_SESSION" 2>/dev/null; then
podman exec -it --user "$DEV_USER" "$WORKSPACE" \
tmux new-session -d -s "$TMUX_SESSION"
fi
log INFO "$PERSON attaching to workspace '$WORKSPACE'" log INFO "$PERSON attaching to workspace '$WORKSPACE'"
# Try to attach to session; if it fails, create and attach
if ! podman exec -it -e TERM="$TERM" --user "$DEV_USER" "$WORKSPACE" \
tmux attach -t "$TMUX_SESSION"; then
log WARN "tmux session not found, creating new session"
podman exec -it --user "$DEV_USER" "$WORKSPACE" \
tmux new-session -d -s "$TMUX_SESSION" 2>/dev/null || true
podman exec -it -e TERM="$TERM" --user "$DEV_USER" "$WORKSPACE" \ podman exec -it -e TERM="$TERM" --user "$DEV_USER" "$WORKSPACE" \
tmux attach -t "$TMUX_SESSION" tmux attach -t "$TMUX_SESSION"
fi
log INFO "$PERSON detached from '$WORKSPACE'" log INFO "$PERSON detached from '$WORKSPACE'"
check_devuser_attached check_devuser_attached
;; ;;
ro) ro)