#!/bin/bash if [ -f .env ]; then source .env else echo ".env file not found. Please create one with JBOSS_HOME and JAVA_HOME variables." exit 1 fi # war folder SOURCE_DIR="../../stub-war/target" # jboss deployment DEST_DIR="$JBOSS_HOME/standalone/deployments" UPDATE_TIME=$(($UPDATE_TIME)) # war to monitor FILE_TO_MONITOR="stub-war.war" echo "Controllo esistenza delle directory..." if [ ! -d "$DEST_DIR" ]; then echo "DEST_DIR non esiste: $DEST_DIR" exit 1 fi if [ ! -d "$SOURCE_DIR" ]; then echo "SOURCE_DIR non esiste: $SOURCE_DIR" exit 1 fi # Ottieni la data di modifica iniziale del file LAST_MODIFIED=$(stat -c %Y "$SOURCE_DIR/$FILE_TO_MONITOR") while true; do # Ottieni la data di modifica attuale del file CURRENT_MODIFIED=$(stat -c %Y "$SOURCE_DIR/$FILE_TO_MONITOR") # Confronta le date di modifica if [ "$CURRENT_MODIFIED" -ne "$LAST_MODIFIED" ]; then # Sposta il file se รจ stato modificato cp "$SOURCE_DIR/$FILE_TO_MONITOR" "$DEST_DIR/" echo "File copiato in $DEST_DIR/" # Aggiorna la data di modifica LAST_MODIFIED=$CURRENT_MODIFIED fi sleep $UPDATE_TIME done