#!/usr/bin/env bash
exec &> /tmp/techgel-deploy.log
echo "[$(date)] Running deploy script"

JAR_DIR=/srv/uploads/ftp-service/jar
SERVICE=techgel.service

# Kiểm tra xem có file *.jar nào không
shopt -s nullglob
JARS=( "$JAR_DIR"/*.jar )
if [ ${#JARS[@]} -gt 0 ]; then
  echo "Found JAR(s): ${JARS[*]} → restarting $SERVICE"
  systemctl restart $SERVICE
else
  echo "No JAR found → stopping $SERVICE"
  systemctl stop $SERVICE
fi
