FIX(app): restore su - ubuntu -c for proper env and PATH

- su ubuntu -c may not set env vars properly
- Change to su - ubuntu -c to use login shell environment
- Projects path is hardcoded to /home/ubuntu/Projects
This commit is contained in:
2025-12-24 14:36:43 +09:00
parent d6d85eefd4
commit 355b2d1bca
2 changed files with 6 additions and 7 deletions

View File

@@ -16,5 +16,5 @@ commonLabels:
# 이미지 태그 설정 (ArgoCD Image Updater가 자동으로 업데이트)
images:
- name: gitea0213.kro.kr/bluemayne/mas
newTag: main-sha-878bf6866a72be3fd2f7064c8bcda96097093f40
newTag: main-sha-b8e84c1b6bc380490e4b313459ee02f438e3c125

View File

@@ -91,16 +91,15 @@ def execute_host(command: str, timeout: int = 30, use_sudo: bool = False) -> str
# -n: network namespace
# -i: IPC namespace
# Run as ubuntu user to avoid git "dubious ownership" errors
# Use 'su ubuntu -c' (without -) to preserve current directory context
# This allows commands to work from SSH initial directory
# Use 'su - ubuntu -c' to get proper environment variables and PATH
# Projects folder is at /home/ubuntu/Projects (hardcoded in prompts)
if use_sudo:
# For sudo commands, run directly with sudo
nsenter_command = f"nsenter -t 1 -m -u -n -i -- sh -c {subprocess.list2cmdline([f'sudo {command}'])}"
else:
# For regular commands, run as ubuntu user
# Use 'su ubuntu -c' (not 'su - ubuntu -c') to preserve current directory
# This matches SSH behavior where you start from the initial directory
nsenter_command = f"nsenter -t 1 -m -u -n -i -- su ubuntu -c {subprocess.list2cmdline([command])}"
# For regular commands, run as ubuntu user with login shell
# This ensures proper environment variables (PATH, HOME, etc.)
nsenter_command = f"nsenter -t 1 -m -u -n -i -- su - ubuntu -c {subprocess.list2cmdline([command])}"
result = subprocess.run(
nsenter_command,