Some checks are pending
Container / meta (analyzer) (push) Waiting to run
Container / meta (api) (push) Waiting to run
Container / meta (legacy) (push) Waiting to run
Container / meta (nginx) (push) Waiting to run
Container / meta (playout) (push) Waiting to run
Container / meta (worker) (push) Waiting to run
Container / build (push) Blocked by required conditions
Project / pre-commit (push) Waiting to run
Project / test-tools (push) Waiting to run
Release-Please / release-please (push) Waiting to run
46 lines
1.8 KiB
Bash
Executable File
46 lines
1.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# Este script prepara el compose para EasyPanel.
|
|
# Si Node.js está disponible y existe easypanel/update.js, lo ejecuta.
|
|
# De lo contrario, realiza la copia y saneado en bash/perl (fallback).
|
|
|
|
BASE_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
SRC="$BASE_DIR/../docker-compose.easypanel.yml"
|
|
DEST_DIR="$BASE_DIR/code"
|
|
DEST="$DEST_DIR/docker-compose.yml"
|
|
|
|
if command -v node >/dev/null 2>&1 && [ -f "$BASE_DIR/update.js" ]; then
|
|
echo "Node.js detectado, ejecutando easypanel/update.js"
|
|
# Ejecutar con node (permitirá usar la versión JS en lugar del sed/perl)
|
|
node "$BASE_DIR/update.js"
|
|
echo "Preparado $DEST para EasyPanel (vía update.js)."
|
|
exit 0
|
|
fi
|
|
|
|
echo "Node.js no disponible o easypanel/update.js no encontrado; usando fallback shell copy"
|
|
|
|
mkdir -p "$DEST_DIR"
|
|
|
|
if [ ! -f "$SRC" ]; then
|
|
echo "ERROR: no se encuentra $SRC"
|
|
exit 2
|
|
fi
|
|
|
|
# Copiar
|
|
cp "$SRC" "$DEST"
|
|
|
|
# Eliminar container_name y ports keys (simplemente eliminamos las líneas que contienen 'container_name:' o 'ports:')
|
|
# Esto es similar a lo que hacen muchos ejemplos de EasyPanel.
|
|
if command -v perl >/dev/null 2>&1; then
|
|
perl -0777 -pe "s/^[ \t]*container_name:[^\n]*\n//mg" -i "$DEST"
|
|
perl -0777 -pe "s/^[ \t]*ports:[^\n]*\n(?:^[ \t]+-.*\n)*//mg" -i "$DEST"
|
|
else
|
|
# Fallback con awk/sed si perl no está disponible
|
|
# Elimina líneas 'container_name:' y bloques 'ports:' simples
|
|
sed -E '/^[ \t]*container_name:/d' -i "" "$DEST" 2>/dev/null || sed -E '/^[ \t]*container_name:/d' -i '$DEST'
|
|
awk 'BEGIN{skip=0} /^[ \t]*ports:[ \t]*$/ {skip=1; next} /^[ \t]*[^ \t]/ { if(skip){skip=0} } { if(!skip) print $0 }' "$DEST" > "$DEST.tmp" && mv "$DEST.tmp" "$DEST"
|
|
fi
|
|
|
|
echo "Preparado $DEST para EasyPanel. Revisa variables de entorno en el README y súbelas en la UI de EasyPanel."
|