#!/bin/sh
# Rigenera CSS tema next22 per vte.ego.it
# Uso: sudo bash /var/www/html/server-ops/ego/install-sass-and-compile-next22.sh

set -eu

THEME_DIR="/var/www/html/vte23083_2711/themes/next22"

if [ "$(id -u)" -ne 0 ]; then
	echo "[ERR] Esegui con sudo" >&2
	exit 1
fi

if ! command -v sass >/dev/null 2>&1; then
	export DEBIAN_FRONTEND=noninteractive
	apt-get update -qq
	apt-get install -y ruby-sass
fi

cd "$THEME_DIR"
for f in style.css jquery-ui.css vte_materialize.css dp.css style_login.css datetimepicker.css; do
	[ -f "$f" ] && cp -p -- "$f" "$f.pre-recompile" || true
done
sudo -u www-data php ./compile.sh
echo "[OK] CSS next22 ricompilati."
