#!/bin/bash
################################################################################
# Script Name: version/3.9.7/UPDATE.sh
# Description: Apply version 3.9.7. Update scripts and binaries.
# Company/Brand: HiTechCloud by Pho Tue SoftWare Solutions JSC
# Copyright (c) HiTechCloud by Pho Tue SoftWare Solutions JSC
################################################################################
set -euo pipefail

echo "==> HiTechCloud Panel 3.9.7 update starting"

# 1. Sync CLI scripts (Rust implementation is authoritative)
if [ -x hitechcloudpanel/sync-hitechcloudcli-scripts.sh ]; then
  echo "==> Syncing hitechcloudcli scripts"
  ./hitechcloudpanel/sync-hitechcloudcli-scripts.sh || true
fi

# 2. Bump version marker
echo "3.9.7" > hitechcloudpanel/version 2>/dev/null || true

# 3. Reload services that embed version strings
systemctl try-reload hitechcloud-panel 2>/dev/null || true
systemctl try-reload hitechcloud-admin 2>/dev/null || true

echo "[3.9.7] version 3.9.7 applied."
exit 0
