|
@@ -242,8 +242,13 @@ deploy_native() {
|
|
|
|
|
|
|
|
cd "$INSTALL_DIR"
|
|
cd "$INSTALL_DIR"
|
|
|
|
|
|
|
|
- # Create venv
|
|
|
|
|
- python3 -m venv .venv
|
|
|
|
|
|
|
+ # Create venv — if running as root (sudo), create as the real user
|
|
|
|
|
+ local real_user="${SUDO_USER:-$USER}"
|
|
|
|
|
+ if [[ $EUID -eq 0 && -n "$SUDO_USER" ]]; then
|
|
|
|
|
+ sudo -u "$SUDO_USER" python3 -m venv .venv
|
|
|
|
|
+ else
|
|
|
|
|
+ python3 -m venv .venv
|
|
|
|
|
+ fi
|
|
|
source .venv/bin/activate
|
|
source .venv/bin/activate
|
|
|
|
|
|
|
|
# Install dependencies
|
|
# Install dependencies
|
|
@@ -251,6 +256,11 @@ deploy_native() {
|
|
|
pip install --upgrade pip
|
|
pip install --upgrade pip
|
|
|
pip install -r requirements.txt
|
|
pip install -r requirements.txt
|
|
|
|
|
|
|
|
|
|
+ # Ensure venv is owned by the real user (not root)
|
|
|
|
|
+ if [[ $EUID -eq 0 && -n "$SUDO_USER" ]]; then
|
|
|
|
|
+ chown -R "$SUDO_USER:$SUDO_USER" .venv
|
|
|
|
|
+ fi
|
|
|
|
|
+
|
|
|
# Ensure nginx (www-data) can traverse to static files
|
|
# Ensure nginx (www-data) can traverse to static files
|
|
|
# chmod o+x grants traversal only, not directory listing
|
|
# chmod o+x grants traversal only, not directory listing
|
|
|
local dir="$INSTALL_DIR"
|
|
local dir="$INSTALL_DIR"
|