#!/bin/bash
source /home/orangepi/atadash/.venv/bin/activate

# Stop the services
echo "atadash stopping..."
sudo systemctl stop atadash
echo ""

# Use rsync to copy files if they are different
rsync -avv --progress /home/orangepi/atadash_master/static/ /home/orangepi/atadash/static/
rsync -avv --progress /home/orangepi/atadash_master/templates/ /home/orangepi/atadash/templates/
rsync -avv --progress /home/orangepi/atadash_master/data/ /home/orangepi/atadash/data/

# Use pyarmor to protect Python scripts in the printio directory
pyarmor gen -O /home/orangepi/atadash/src/ /home/orangepi/atadash_master/src/*.py

# Start the services back up
echo ""
sudo systemctl start atadash
echo "atadash restarted..."
