-
Notifications
You must be signed in to change notification settings - Fork 1
Dev #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Dev #2
Changes from all commits
a45251a
7fc0df8
38fea75
67b352f
e902ce4
4ebd518
cb93507
d47857e
c9f34c1
32b461c
92000bf
de4e1c7
6476241
f056611
8595bb9
6ea2074
a1662ee
1bfa229
bc6955e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,13 @@ | ||
.DS_Store | ||
.env | ||
addons/ | ||
config/ | ||
datadir/ | ||
log/ | ||
scripts/ | ||
postgresql/ | ||
filestore/ | ||
modulos.txt | ||
.vscode/ | ||
versions/16.0/.vscode/* | ||
versions/17.0/.vscode/* |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,102 @@ | ||||||||||||||||||||||||||||
#!/bin/bash | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
# ======================== | ||||||||||||||||||||||||||||
# CARGAR VARIABLES DESDE .env | ||||||||||||||||||||||||||||
# ======================== | ||||||||||||||||||||||||||||
if [ -f .env ]; then | ||||||||||||||||||||||||||||
export $(grep -v '^#' .env | xargs) | ||||||||||||||||||||||||||||
else | ||||||||||||||||||||||||||||
echo "❌ Archivo .env no encontrado." | ||||||||||||||||||||||||||||
exit 1 | ||||||||||||||||||||||||||||
fi | ||||||||||||||||||||||||||||
Comment on lines
+6
to
+11
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Load -if [ -f .env ]; then
- export $(grep -v '^#' .env | xargs)
-else
- echo "❌ Archivo .env no encontrado."
- exit 1
-fi
+if [ ! -f .env ]; then
+ echo "❌ Archivo .env no encontrado."
+ exit 1
+fi
+set -o allexport
+source .env
+set +o allexport 📝 Committable suggestion
Suggested change
🧰 Tools🪛 Shellcheck (0.10.0)[warning] 7-7: Quote this to prevent word splitting. (SC2046) |
||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
PROD_URL="$PROD_URL" | ||||||||||||||||||||||||||||
PROD_MASTER_KEY="$PROD_MASTER_KEY" | ||||||||||||||||||||||||||||
PG_DB="$PG_DB" | ||||||||||||||||||||||||||||
ODOO_PORT="${ODOO_PORT:-8069}" # Por defecto 8069 si no está definido | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
BACKUP_FILE="odoo_backup.zip" | ||||||||||||||||||||||||||||
LOCAL_URL="http://localhost:$ODOO_PORT" | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
# ======================== | ||||||||||||||||||||||||||||
# FUNCIÓN PARA VERIFICAR CONEXIÓN A ODOO | ||||||||||||||||||||||||||||
# ======================== | ||||||||||||||||||||||||||||
function verificar_conexion() { | ||||||||||||||||||||||||||||
URL=$1 | ||||||||||||||||||||||||||||
echo "🔍 Verificando conexión a $URL ..." | ||||||||||||||||||||||||||||
if curl -k -L -s --head --request GET "$URL/web/database/manager" | grep "200 OK" > /dev/null; then | ||||||||||||||||||||||||||||
echo "✅ Conexión exitosa a $URL" | ||||||||||||||||||||||||||||
else | ||||||||||||||||||||||||||||
echo "❌ No se pudo conectar a $URL" | ||||||||||||||||||||||||||||
exit 1 | ||||||||||||||||||||||||||||
fi | ||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
# ======================== | ||||||||||||||||||||||||||||
# FUNCIÓN DE BACKUP | ||||||||||||||||||||||||||||
# ======================== | ||||||||||||||||||||||||||||
function backup_odoo() { | ||||||||||||||||||||||||||||
echo "🔵 Iniciando backup desde $PROD_URL de la base '$PG_DB'..." | ||||||||||||||||||||||||||||
verificar_conexion "$PROD_URL" | ||||||||||||||||||||||||||||
curl -k -L -X POST "https://$PROD_URL/web/database/backup" \ | ||||||||||||||||||||||||||||
-d "master_pwd=$PROD_MASTER_KEY" \ | ||||||||||||||||||||||||||||
-d "name=$PG_DB" \ | ||||||||||||||||||||||||||||
-d "backup_format=zip" \ | ||||||||||||||||||||||||||||
--output "$BACKUP_FILE" | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
if [ $? -eq 0 ]; then | ||||||||||||||||||||||||||||
echo "✅ Backup completado: $BACKUP_FILE" | ||||||||||||||||||||||||||||
else | ||||||||||||||||||||||||||||
echo "❌ Error durante el backup." | ||||||||||||||||||||||||||||
exit 1 | ||||||||||||||||||||||||||||
fi | ||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
# ======================== | ||||||||||||||||||||||||||||
# FUNCIÓN PARA ELIMINAR BASE DE DATOS LOCAL | ||||||||||||||||||||||||||||
# ======================== | ||||||||||||||||||||||||||||
function drop_local_db() { | ||||||||||||||||||||||||||||
echo "🗑️ Eliminando base '$PG_DB' en entorno local ($LOCAL_URL)..." | ||||||||||||||||||||||||||||
verificar_conexion "$LOCAL_URL" | ||||||||||||||||||||||||||||
curl -k -L -X POST "$LOCAL_URL/web/database/drop" \ | ||||||||||||||||||||||||||||
-d "master_pwd=$PROD_MASTER_KEY" \ | ||||||||||||||||||||||||||||
-d "name=$PG_DB" \ | ||||||||||||||||||||||||||||
-d "drop=true" | ||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
# ======================== | ||||||||||||||||||||||||||||
# FUNCIÓN DE RESTORE EN LOCAL | ||||||||||||||||||||||||||||
# ======================== | ||||||||||||||||||||||||||||
function restore_local() { | ||||||||||||||||||||||||||||
echo "🟡 Restaurando backup en entorno local ($LOCAL_URL) con nombre '$PG_DB'..." | ||||||||||||||||||||||||||||
verificar_conexion "$LOCAL_URL" | ||||||||||||||||||||||||||||
curl -k -L -X POST "$LOCAL_URL/web/database/restore" \ | ||||||||||||||||||||||||||||
-F "master_pwd=$PROD_MASTER_KEY" \ | ||||||||||||||||||||||||||||
-F "name=$PG_DB" \ | ||||||||||||||||||||||||||||
-F "backup_file=@$BACKUP_FILE" \ | ||||||||||||||||||||||||||||
-F "copy=true" | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
if [ $? -eq 0 ]; then | ||||||||||||||||||||||||||||
echo "✅ Restauración completada como '$PG_DB' en local" | ||||||||||||||||||||||||||||
else | ||||||||||||||||||||||||||||
echo "❌ Error durante la restauración." | ||||||||||||||||||||||||||||
exit 1 | ||||||||||||||||||||||||||||
fi | ||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
# ======================== | ||||||||||||||||||||||||||||
# FUNCIÓN PARA LIMPIAR ARCHIVOS TEMPORALES | ||||||||||||||||||||||||||||
# ======================== | ||||||||||||||||||||||||||||
function limpiar_backup() { | ||||||||||||||||||||||||||||
echo "🧹 Eliminando archivo temporal $BACKUP_FILE..." | ||||||||||||||||||||||||||||
rm -f "$BACKUP_FILE" | ||||||||||||||||||||||||||||
echo "✅ Limpieza completada." | ||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
# ======================== | ||||||||||||||||||||||||||||
# EJECUCIÓN COMPLETA | ||||||||||||||||||||||||||||
# ======================== | ||||||||||||||||||||||||||||
limpiar_backup | ||||||||||||||||||||||||||||
backup_odoo | ||||||||||||||||||||||||||||
drop_local_db | ||||||||||||||||||||||||||||
restore_local | ||||||||||||||||||||||||||||
Comment on lines
+96
to
+102
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move cleanup to end of workflow -# EJECUCIÓN COMPLETA
-limpiar_backup
-backup_odoo
-drop_local_db
-restore_local
+# EJECUCIÓN COMPLETA
+backup_odoo
+drop_local_db
+restore_local
+limpiar_backup This ensures temporary files are removed only after successful restore. |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,49 @@ | ||||||||||||||||||||||||||||
#!/bin/bash | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
Comment on lines
+1
to
+2
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Enable strict shell error handling #!/bin/bash
+set -euo pipefail 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||
# ======================== | ||||||||||||||||||||||||||||
# CARGAR VARIABLES DESDE .env | ||||||||||||||||||||||||||||
# ======================== | ||||||||||||||||||||||||||||
if [ -f .env ]; then | ||||||||||||||||||||||||||||
export $(grep -v '^#' .env | xargs) | ||||||||||||||||||||||||||||
else | ||||||||||||||||||||||||||||
echo "❌ Archivo .env no encontrado." | ||||||||||||||||||||||||||||
exit 1 | ||||||||||||||||||||||||||||
fi | ||||||||||||||||||||||||||||
Comment on lines
+6
to
+11
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Load -if [ -f .env ]; then
- export $(grep -v '^#' .env | xargs)
-else
- echo "❌ Archivo .env no encontrado."
- exit 1
-fi
+if [ ! -f .env ]; then
+ echo "❌ Archivo .env no encontrado."
+ exit 1
+fi
+set -o allexport
+source .env
+set +o allexport 📝 Committable suggestion
Suggested change
🧰 Tools🪛 Shellcheck (0.10.0)[warning] 7-7: Quote this to prevent word splitting. (SC2046) |
||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
PG_DB="$PG_DB" | ||||||||||||||||||||||||||||
PG_USER="$PG_USER" | ||||||||||||||||||||||||||||
PG_CONTAINER_NAME="$PG_CONTAINER_NAME" | ||||||||||||||||||||||||||||
ODOO_CONTAINER_NAME="$ODOO_CONTAINER_NAME" | ||||||||||||||||||||||||||||
PG_PASSWORD="$PG_PASSWORD" | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
# ======================== | ||||||||||||||||||||||||||||
# COMANDOS SQL QUE VAMOS A EJECUTAR | ||||||||||||||||||||||||||||
# ======================== | ||||||||||||||||||||||||||||
SQL=$(cat <<EOF | ||||||||||||||||||||||||||||
-- 1. Cambiar la contraseña del admin a 'admin' | ||||||||||||||||||||||||||||
UPDATE res_users | ||||||||||||||||||||||||||||
SET password = 'admin' | ||||||||||||||||||||||||||||
WHERE login = 'admin'; | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
-- 2. Eliminar servidores de correo | ||||||||||||||||||||||||||||
DELETE FROM ir_mail_server; | ||||||||||||||||||||||||||||
DELETE FROM fetchmail_server; | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
-- 3. Desactivar todos los cron jobs | ||||||||||||||||||||||||||||
UPDATE ir_cron SET active = FALSE; | ||||||||||||||||||||||||||||
EOF | ||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
# ======================== | ||||||||||||||||||||||||||||
# EJECUCIÓN DENTRO DEL CONTENEDOR DE POSTGRES | ||||||||||||||||||||||||||||
# ======================== | ||||||||||||||||||||||||||||
echo "🔧 Ejecutando limpieza en base '$PG_DB' dentro del contenedor '$PG_CONTAINER_NAME'..." | ||||||||||||||||||||||||||||
docker exec -i "$PG_CONTAINER_NAME" psql -U "$PG_USER" -d "$PG_DB" -c "$SQL" | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
if [ $? -eq 0 ]; then | ||||||||||||||||||||||||||||
echo "✅ Cambios aplicados exitosamente en '$PG_DB'" | ||||||||||||||||||||||||||||
else | ||||||||||||||||||||||||||||
echo "❌ Error al aplicar los cambios en la base de datos." | ||||||||||||||||||||||||||||
exit 1 | ||||||||||||||||||||||||||||
fi |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#!/bin/bash | ||
|
||
# Cargar variables desde el archivo .env | ||
if [ -f .env ]; then | ||
set -o allexport | ||
source .env | ||
set +o allexport | ||
fi | ||
|
||
# Definir variables | ||
MODULES_FILE="modulos.txt" | ||
ADDONS_DIR=$CUSTOM_ADDONS | ||
|
||
Comment on lines
+11
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Validate |
||
# Validar que ODOO_VERSION esté definida | ||
if [ -z "$ODOO_VERSION" ]; then | ||
echo "❌ ERROR: La variable ODOO_VERSION no está definida en el archivo .env" | ||
exit 1 | ||
fi | ||
|
||
echo "🌍 Usando la versión de Odoo: $ODOO_VERSION" | ||
|
||
# Crear la carpeta de destino si no existe | ||
mkdir -p "$ADDONS_DIR" | ||
|
||
# Verificar que el archivo de módulos existe y no está vacío | ||
if [ ! -f "$MODULES_FILE" ] || [ ! -s "$MODULES_FILE" ]; then | ||
echo "❌ ERROR: El archivo '$MODULES_FILE' no existe o está vacío." | ||
exit 1 | ||
fi | ||
|
||
echo "📂 Leyendo '$MODULES_FILE'..." | ||
|
||
# Leer el archivo y extraer enlaces de GitHub y GitLab con sus posibles branches | ||
while IFS= read -r line; do | ||
echo "🔍 Procesando línea: $line" | ||
repo_url=$(echo "$line" | grep -Eo "(https://github\.com/[^ ]+|https://gitlab\.com/[^ ]+)(\.git)?") | ||
branch=$(echo "$line" | sed -n 's/.*--branch[ ]*\"\?\([^\"]*\)\"\?.*/\1/p') | ||
|
||
# Si no se encuentra una branch en la línea, usar ODOO_VERSION | ||
branch=${branch:-$ODOO_VERSION} | ||
|
||
if [ -n "$repo_url" ]; then | ||
echo "🔗 URL detectada: $repo_url" | ||
echo "🌿 Branch seleccionada: $branch" | ||
|
||
repo_name=$(basename "$repo_url" .git) | ||
target_dir="$ADDONS_DIR/$repo_name" | ||
|
||
# Verificar si el repositorio ya existe | ||
if [ -d "$target_dir" ]; then | ||
echo "✅ El repositorio '$repo_name' ya existe en '$ADDONS_DIR', omitiendo clonación." | ||
else | ||
echo "🚀 Clonando '$repo_url' en '$target_dir' (branch '$branch')..." | ||
|
||
# Autenticación para GitLab | ||
if [[ "$repo_url" == *"gitlab.com"* ]] && [ -n "$GITLAB_USER" ] && [ -n "$GITLAB_PASSWORD" ]; then | ||
repo_url_with_auth=$(echo "$repo_url" | sed "s#https://#https://$GITLAB_USER:$GITLAB_PASSWORD@#") | ||
else | ||
repo_url_with_auth="$repo_url" | ||
fi | ||
|
||
# Intentar clonar con la branch especificada | ||
if git clone --branch "$branch" --single-branch "$repo_url_with_auth" "$target_dir" 2>/dev/null; then | ||
echo "✅ Repositorio '$repo_name' clonado en la branch '$branch'." | ||
else | ||
echo "⚠️ No se encontró la branch '$branch' en '$repo_url'. Clonando la branch por defecto..." | ||
if git clone "$repo_url_with_auth" "$target_dir"; then | ||
echo "✅ Repositorio '$repo_name' clonado en la branch por defecto." | ||
else | ||
echo "❌ Error al clonar '$repo_url'." | ||
fi | ||
fi | ||
fi | ||
else | ||
echo "⚠️ No se encontró una URL válida en la línea: $line" | ||
fi | ||
|
||
done < "$MODULES_FILE" | ||
|
||
echo "🔄 Proceso de clonación finalizado." |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
networks: | ||
odoo: | ||
|
||
services: | ||
postgres: | ||
#container_name: ${PG_CONTAINER_NAME} | ||
image: ${PG_IMAGE}:${PG_VERSION} | ||
user: root | ||
environment: | ||
- POSTGRES_DB=${PG_DB} | ||
- POSTGRES_USER=${PG_USER} | ||
- POSTGRES_PASSWORD=${PG_PASSWORD} | ||
- PGDATA=/var/lib/postgresql/data/pgdata | ||
ports: | ||
- ${PG_PORT}:5432 | ||
volumes: | ||
- ${PG_PATH}:/var/lib/postgresql/data | ||
networks: | ||
- odoo | ||
Comment on lines
+5
to
+19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid running PostgreSQL container as root 🤖 Prompt for AI Agents (early access)
|
||
|
||
odoo: | ||
#container_name: ${ODOO_CONTAINER_NAME} | ||
#image: ${ODOO_IMAGE}:${ODOO_VERSION} | ||
build: versions/16.0/. | ||
restart: unless-stopped | ||
entrypoint: ["/scripts/entrypoint.sh"] | ||
user: root | ||
depends_on: | ||
- postgres | ||
ports: | ||
- ${ODOO_PORT}:8069 | ||
volumes: | ||
- ./entrypoint.sh:/scripts/entrypoint.sh # Monta entrypoint.sh en el contenedor | ||
- ./modulos.txt:/scripts/modulos.txt # Monta modulos.txt en el contenedor | ||
- ${CONF_PATH}:/opt/etc/odoo | ||
- ${DATA_PATH}:/opt/odoo/data | ||
- ${LOG_PATH}:/var/log/odoo | ||
- ${CUSTOM_ADDONS}:/mnt/extra-addons | ||
- ${SCRIPT_PATH}:/scripts | ||
- ${FILE_PATH}:/var/lib/odoo | ||
environment: | ||
- HOST=postgres | ||
- CUSTOM_ADDONS=${CUSTOM_ADDONS} | ||
- MAIN_MODULE=${MAIN_MODULE} | ||
- POSTGRES_DB=${PG_DB} | ||
- POSTGRES_USER=${PG_USER} | ||
- POSTGRES_PASSWORD=${PG_PASSWORD} | ||
networks: | ||
- odoo |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
# Validar variables de entorno | ||
: "${HOST:?Variable HOST no definida}" | ||
: "${POSTGRES_DB:?Variable POSTGRES_DB no definida}" | ||
: "${POSTGRES_USER:?Variable POSTGRES_USER no definida}" | ||
: "${POSTGRES_PASSWORD:?Variable POSTGRES_PASSWORD no definida}" | ||
: "${MAIN_MODULE:?Variable MAIN_MODULE no definida}" | ||
|
||
# Rutas | ||
ADDONS_DIR="/mnt/extra-addons" | ||
ORIGINAL_CONFIG="/etc/odoo/odoo.conf" | ||
MODIFIED_CONFIG="/var/lib/odoo/odoo.conf" | ||
|
||
echo "Esperando a que PostgreSQL esté disponible..." | ||
for i in {1..30}; do | ||
if pg_isready -h "$HOST" -p 5432; then | ||
echo "PostgreSQL está listo." | ||
break | ||
fi | ||
echo "Esperando... intento $i/30" | ||
sleep 1 | ||
done | ||
|
||
if ! pg_isready -h "$HOST" -p 5432; then | ||
echo "❌ No se pudo conectar a PostgreSQL. Abortando..." | ||
exit 1 | ||
fi | ||
|
||
# Obtener rutas actuales de addons | ||
CUSTOM_ADDONS_PATHS=$(odoo --config="$ORIGINAL_CONFIG" --print-addon-paths 2>/dev/null | tr ':' '\n') | ||
|
||
echo "📂 Rutas de módulos en Odoo actualmente:" | ||
echo "$CUSTOM_ADDONS_PATHS" | ||
|
||
# Leer todas las carpetas dentro de /mnt/extra-addons | ||
EXTRA_PATHS=() | ||
for dir in "$ADDONS_DIR"/*/; do | ||
if [ -d "$dir" ]; then | ||
echo "Encontrado módulo/carpeta: $dir" | ||
if ! echo "$CUSTOM_ADDONS_PATHS" | grep -q "$dir"; then | ||
echo "➕ Agregando $dir a addons_path." | ||
EXTRA_PATHS+=("$dir") | ||
else | ||
echo "✅ $dir ya está en addons_path." | ||
fi | ||
fi | ||
done | ||
|
||
# Generar nuevo archivo de configuración si hay nuevas rutas | ||
if [ ${#EXTRA_PATHS[@]} -gt 0 ]; then | ||
echo "🛠️ Generando archivo de configuración modificado en $MODIFIED_CONFIG..." | ||
|
||
# Si el archivo de destino no existe, copiar el original | ||
if [ ! -f "$MODIFIED_CONFIG" ]; then | ||
cp "$ORIGINAL_CONFIG" "$MODIFIED_CONFIG" | ||
echo "📄 Copia base creada desde el archivo original." | ||
else | ||
echo "📄 Usando archivo de configuración existente en el destino." | ||
fi | ||
|
||
# Leer línea actual de addons_path | ||
ADDONS_PATH=$(grep -E '^addons_path\s*=' "$MODIFIED_CONFIG" | cut -d'=' -f2 | tr -d ' ') | ||
|
||
# Concatenar las nuevas rutas | ||
NEW_ADDONS_PATH="$ADDONS_PATH,$(IFS=,; echo "${EXTRA_PATHS[*]}")" | ||
|
||
# Reemplazar en el archivo copiado o existente | ||
sed -i "s|^addons_path\s*=.*|addons_path = $NEW_ADDONS_PATH|" "$MODIFIED_CONFIG" | ||
|
||
Comment on lines
+67
to
+71
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Escape paths when updating |
||
echo "✅ addons_path actualizado con éxito." | ||
else | ||
echo "No se encontraron nuevas rutas para agregar al addons_path." | ||
|
||
# Si no hay cambios, usar el config original solo si no existe el modificado | ||
if [ ! -f "$MODIFIED_CONFIG" ]; then | ||
cp "$ORIGINAL_CONFIG" "$MODIFIED_CONFIG" | ||
echo "📄 Copia base creada desde el archivo original (sin cambios en addons_path)." | ||
else | ||
echo "📄 Archivo de configuración ya existe. No se realizaron cambios." | ||
fi | ||
fi | ||
|
||
|
||
# Verificar si el módulo principal está instalado | ||
echo "🔍 Verificando si el módulo $MAIN_MODULE ya está instalado..." | ||
INSTALLED_MODULES=$(PGPASSWORD="$POSTGRES_PASSWORD" psql -h "$HOST" -U "$POSTGRES_USER" -d "$POSTGRES_DB" -t -c "SELECT name FROM ir_module_module WHERE state = 'installed';" | tr -d ' ' | tr ',' '\n') | ||
|
||
if echo "$INSTALLED_MODULES" | grep -Fxq "$MAIN_MODULE"; then | ||
echo "✅ El módulo $MAIN_MODULE ya está instalado. Iniciando Odoo normalmente..." | ||
exec odoo --config="$MODIFIED_CONFIG" -d "$POSTGRES_DB" --db-filter="$POSTGRES_DB" --db_host="$HOST" --db_port=5432 --db_user="$POSTGRES_USER" --db_password="$POSTGRES_PASSWORD" | ||
else | ||
echo "🚀 El módulo $MAIN_MODULE no está instalado. Procediendo con la instalación..." | ||
exec odoo --config="$MODIFIED_CONFIG" -i "$MAIN_MODULE" -d "$POSTGRES_DB" --db-filter="$POSTGRES_DB" --db_host="$HOST" --db_port=5432 --db_user="$POSTGRES_USER" --db_password="$POSTGRES_PASSWORD" --without-demo=True | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Enable strict shell error handling
Add
set -euo pipefail
immediately after the shebang to catch errors early:#!/bin/bash +set -euo pipefail