34 lines
1.1 KiB
Bash
34 lines
1.1 KiB
Bash
#!/bin/bash
|
|
set -e
|
|
|
|
CONFIG_FILE="/opt/opengnsys/oggui/src/.env"
|
|
HASH_FILE="/opt/opengnsys/oggui/var/lib/oggui/oggui.config.hash"
|
|
APP_DIR="/opt/opengnsys/oggui/browser"
|
|
SRC_DIR="/opt/opengnsys/oggui/src"
|
|
COMPILED_DIR=$SRC_DIR/dist
|
|
NGINX_SERVICE="nginx"
|
|
|
|
# Verificar si el archivo de configuración cambió
|
|
if [ -f "$CONFIG_FILE" ] && [ -f "$HASH_FILE" ]; then
|
|
OLD_HASH=$(cat "$HASH_FILE")
|
|
NEW_HASH=$(md5sum "$CONFIG_FILE")
|
|
|
|
if [ "$OLD_HASH" != "$NEW_HASH" ]; then
|
|
echo "🔄 Cambios detectados en $CONFIG_FILE, recompilando Angular..."
|
|
cd "$SRC_DIR"
|
|
npm install -g @angular/cli
|
|
npm install
|
|
/usr/local/bin/ng build --base-href=/ --output-path=dist/oggui --optimization=true --configuration=production --localize=false
|
|
md5sum "$CONFIG_FILE" > "$HASH_FILE"
|
|
exit 0
|
|
else
|
|
echo "No hay cambios en $CONFIG_FILE, no es necesario recompilar."
|
|
exit 0
|
|
fi
|
|
else
|
|
echo "Archivo de configuración no encontrado o sin hash previo. No se recompilará."
|
|
exit 1
|
|
fi
|
|
|
|
# Iniciar Nginx
|
|
systemctl restart "$NGINX_SERVICE" |