#!/bin/bash
echo "ending pm2";
sudo pm2 kill;

# Backup assets from the public folder (if it exists) before deletion
if [ -d "/var/www/aloethereinc.com/aloethere/public/assets" ]; then
  echo "Backing up assets from public folder...";
  sudo cp -R /var/www/aloethereinc.com/aloethere/public/assets /var/www/aloethereinc.com/assets;
else
  echo "No assets folder found in public directory. Skipping backup.";
fi

echo "removing AloeThere installation";
sudo rm -rf aloethere;
echo "removing aloethere zip";
sudo rm -rf aloethere.zip;
echo "removing auth server";
sudo rm -rf Auth-Server;
echo "removing auth zip";
sudo rm -rf Auth-Server.zip;

