diff --git a/install.sh b/install.sh index 1bd4e61..8c75297 100644 --- a/install.sh +++ b/install.sh @@ -30,7 +30,18 @@ LOG_DIR="/var/log/${SERVICE_NAME}" # ─── Root check ──────────────────────────────────────────────────────────────── [[ $EUID -ne 0 ]] && err "Ejecutá este script con sudo: sudo bash install.sh" -[[ ! -f "${APP_DIR}/app.py" ]] && err "No se encontró app.py en ${APP_DIR}. ¿Estás en el directorio correcto?" + +# Si el directorio está dentro de /root, lo movemos a /opt para evitar problemas de permisos +if [[ "${APP_DIR}" == /root/* ]]; then + NEW_DIR="/opt/admin-edu-space" + warn "Detectado directorio en ${APP_DIR}. Moviendo a ${NEW_DIR} para evitar errores de permisos..." + mkdir -p /opt + mv "${APP_DIR}" "${NEW_DIR}" + cd "${NEW_DIR}" + exec bash install.sh +fi + +[[ ! -f "${APP_DIR}/wsgi.py" ]] && err "No se encontró wsgi.py en ${APP_DIR}. ¿Estás en el directorio correcto?" echo -e "\n${BOLD}${CYAN}" echo "╔══════════════════════════════════════════════════════════════╗" @@ -120,7 +131,7 @@ else # Admin Edu-Space — Configuración de producción # Generado automáticamente el $(date '+%Y-%m-%d %H:%M:%S') -FLASK_APP=app.py +FLASK_APP=wsgi.py FLASK_ENV=production SECRET_KEY=${SECRET_KEY} @@ -207,7 +218,7 @@ else LC_ALL=en_US.UTF-8 \ PYTHONUTF8=1 \ PYTHONIOENCODING=utf-8 \ - FLASK_APP=app.py \ + FLASK_APP=wsgi.py \ "${VENV_DIR}/bin/python" -X utf8 init_db.py ok "Esquema, roles, edificios y usuario admin inicializados" @@ -254,6 +265,7 @@ Environment="LC_ALL=en_US.UTF-8" Environment="PYTHONUTF8=1" Environment="PYTHONIOENCODING=utf-8" Environment="FLASK_ENV=production" +Environment="HOME=${APP_DIR}" ExecStart=${GUNICORN_BIN} \ --workers 3 \ --bind 0.0.0.0:5000 \ @@ -261,7 +273,7 @@ ExecStart=${GUNICORN_BIN} \ --access-logfile ${LOG_DIR}/access.log \ --error-logfile ${LOG_DIR}/error.log \ --log-level info \ - app:app + wsgi:app Restart=always RestartSec=5 StandardOutput=journal diff --git a/app.py b/wsgi.py similarity index 100% rename from app.py rename to wsgi.py