diff --git a/terraform-gpu-devservers/docker/bash_profile b/terraform-gpu-devservers/docker/bash_profile index ec3955cd..a4b1abe8 100644 --- a/terraform-gpu-devservers/docker/bash_profile +++ b/terraform-gpu-devservers/docker/bash_profile @@ -8,8 +8,5 @@ if [ -f ~/.bashrc ]; then source ~/.bashrc fi -# Show MOTD only for interactive login shells (skip for Claude Code, scripts, etc.) -# Check: stdin is a terminal AND stdout is a terminal -if [ -t 0 ] && [ -t 1 ] && [ -f /etc/motd ]; then - cat /etc/motd -fi \ No newline at end of file +# MOTD is now handled by .bashrc_ext with proper TTY checks +# This ensures it works correctly on persistent disks without needing profile updates \ No newline at end of file diff --git a/terraform-gpu-devservers/docker/bashrc_ext b/terraform-gpu-devservers/docker/bashrc_ext index ef4898fd..855dc05b 100644 --- a/terraform-gpu-devservers/docker/bashrc_ext +++ b/terraform-gpu-devservers/docker/bashrc_ext @@ -5,6 +5,12 @@ # User identification (set by Lambda on startup) export GPU_DEV_USER_ID="dev" +# Show MOTD once per session, only for interactive terminals (skip for Claude Code, scripts, etc.) +if [ -z "$GPU_DEV_MOTD_SHOWN" ] && [ -t 0 ] && [ -t 1 ] && [ -f /etc/motd ]; then + cat /etc/motd + export GPU_DEV_MOTD_SHOWN=1 +fi + # Function to check for GPU reservation expiry warnings and startup script status check_warnings() { # Check for startup script still running diff --git a/terraform-gpu-devservers/docker/profile b/terraform-gpu-devservers/docker/profile index 493cf2f1..9027d2ca 100644 --- a/terraform-gpu-devservers/docker/profile +++ b/terraform-gpu-devservers/docker/profile @@ -8,8 +8,5 @@ if [ -n "$BASH_VERSION" ] && [ -f ~/.bashrc ]; then source ~/.bashrc fi -# Show MOTD only for interactive login shells (skip for Claude Code, scripts, etc.) -# Check: stdin is a terminal AND stdout is a terminal -if [ -t 0 ] && [ -t 1 ] && [ -f /etc/motd ]; then - cat /etc/motd -fi \ No newline at end of file +# MOTD is now handled by .bashrc_ext with proper TTY checks +# This ensures it works correctly on persistent disks without needing profile updates \ No newline at end of file diff --git a/terraform-gpu-devservers/docker/zprofile b/terraform-gpu-devservers/docker/zprofile index cf90429b..89046b5d 100644 --- a/terraform-gpu-devservers/docker/zprofile +++ b/terraform-gpu-devservers/docker/zprofile @@ -3,8 +3,5 @@ if [ -f ~/.zshrc ]; then source ~/.zshrc fi -# Show MOTD only for interactive login shells (skip for Claude Code, scripts, etc.) -# Check: stdin is a terminal AND stdout is a terminal -if [ -t 0 ] && [ -t 1 ] && [ -f /etc/motd ]; then - cat /etc/motd -fi \ No newline at end of file +# MOTD is now handled by .zshrc_ext with proper TTY checks +# This ensures it works correctly on persistent disks without needing profile updates \ No newline at end of file diff --git a/terraform-gpu-devservers/docker/zshrc_ext b/terraform-gpu-devservers/docker/zshrc_ext index 03bfe774..9a6749ff 100644 --- a/terraform-gpu-devservers/docker/zshrc_ext +++ b/terraform-gpu-devservers/docker/zshrc_ext @@ -5,6 +5,12 @@ # User identification (set by Lambda on startup) export GPU_DEV_USER_ID="dev" +# Show MOTD once per session, only for interactive terminals (skip for Claude Code, scripts, etc.) +if [[ -z "$GPU_DEV_MOTD_SHOWN" ]] && [[ -t 0 ]] && [[ -t 1 ]] && [[ -f /etc/motd ]]; then + cat /etc/motd + export GPU_DEV_MOTD_SHOWN=1 +fi + # Function to check for GPU reservation expiry warnings and startup script status check_warnings() { # Check for startup script still running diff --git a/terraform-gpu-devservers/lambda/reservation_processor/index.py b/terraform-gpu-devservers/lambda/reservation_processor/index.py index 40e3c586..aed0b522 100644 --- a/terraform-gpu-devservers/lambda/reservation_processor/index.py +++ b/terraform-gpu-devservers/lambda/reservation_processor/index.py @@ -3913,6 +3913,12 @@ def create_pod( # User identification export GPU_DEV_USER_ID="{user_id or 'dev'}" +# Show MOTD once per session, only for interactive terminals (skip for Claude Code, scripts, etc.) +if [ -z "\$GPU_DEV_MOTD_SHOWN" ] && [ -t 0 ] && [ -t 1 ] && [ -f /etc/motd ]; then + cat /etc/motd + export GPU_DEV_MOTD_SHOWN=1 +fi + # Function to check for GPU reservation expiry warnings and startup script status check_warnings() {{ # Check for startup script still running @@ -3941,6 +3947,12 @@ def create_pod( # User identification export GPU_DEV_USER_ID="{user_id or 'dev'}" +# Show MOTD once per session, only for interactive terminals (skip for Claude Code, scripts, etc.) +if [[ -z "\$GPU_DEV_MOTD_SHOWN" ]] && [[ -t 0 ]] && [[ -t 1 ]] && [[ -f /etc/motd ]]; then + cat /etc/motd + export GPU_DEV_MOTD_SHOWN=1 +fi + # Function to check for GPU reservation expiry warnings and startup script status check_warnings() {{ # Check for startup script still running @@ -3980,6 +3992,19 @@ def create_pod( done echo "[STARTUP] ✓ Shell extension sourcing configured" + # Always update system profile files (these control login behavior) + # MOTD is now handled by extension files, so remove from profiles + echo "[STARTUP] Updating system profile files..." + if [ -d "/devserver-setup" ]; then + for profile_file in .bash_profile .zprofile .profile; do + if [ -f "/devserver-setup/$profile_file" ]; then + cp "/devserver-setup/$profile_file" "/home/dev/$profile_file" + echo "[STARTUP] ✓ Updated $profile_file" + fi + done + fi + echo "[STARTUP] ✓ System profile files updated" + # Ensure correct ownership chown -R dev:dev /home/dev