#!/bin/sh

# Stop any running rclone process; ignore error if none running
pkill rclone 2>/dev/null || true

# Remove lock file if it exists; ignore error if already absent
rm -f "/home/manager/.cache/rclone/iCast_StackIT_StackIT-to-Netsuite..home_manager_shared.lck"

# Run a fresh bisync with --resync to rebuild the baseline
rclone bisync "iCast_StackIT:/StackIT-to-NetSuite" "/home/manager/shared/" \
  --resync \
  --exclude-from /home/manager/rclone_exclude.txt \
  --log-level INFO \
  --log-file "/home/manager/rclone.log"

sudo chmod 777 -R /var/www/html/shared/*
