#!/bin/bash # Bark TTS Cleanup Script for t-800 # This script removes all Bark TTS components from the server set -e T800_HOST="t-800" T800_USER="juan" echo "==========================================" echo " Bark TTS Cleanup for t-800" echo "==========================================" echo "" echo "This script will completely remove Bark TTS from t-800" echo "Including:" echo " - Systemd service" echo " - Installation directory (/opt/bark)" echo " - User account (bark)" echo " - All cached models (~3.6 GB)" echo "" read -p "Continue? [y/N]: " confirm if [ "$confirm" != "y" ] && [ "$confirm" != "Y" ]; then echo "❌ Cancelled" exit 0 fi echo "" echo "πŸ“€ Copying cleanup script to t-800..." # Create cleanup script cat > /tmp/cleanup_bark_remote.sh << 'INNEREOF' #!/bin/bash set -e echo "" echo "=== Stopping Bark Service ===" sudo systemctl stop bark-tts 2>/dev/null && echo "βœ… Service stopped" || echo "⚠️ Service not running" echo "" echo "=== Disabling Bark Service ===" sudo systemctl disable bark-tts 2>/dev/null && echo "βœ… Service disabled" || echo "⚠️ Service not enabled" echo "" echo "=== Removing Systemd Service ===" if [ -f /etc/systemd/system/bark-tts.service ]; then sudo rm -f /etc/systemd/system/bark-tts.service sudo systemctl daemon-reload echo "βœ… Systemd service removed" else echo "⚠️ Systemd service not found" fi echo "" echo "=== Removing Installation Directory ===" if [ -d /opt/bark ]; then SIZE=$(du -sh /opt/bark 2>/dev/null | cut -f1) echo "πŸ“Š Directory size: $SIZE" sudo rm -rf /opt/bark echo "βœ… Directory removed" else echo "⚠️ Directory /opt/bark not found" fi echo "" echo "=== Removing User Account ===" if id bark &>/dev/null; then sudo userdel -r bark 2>/dev/null && echo "βœ… User removed" || echo "⚠️ Could not remove user" else echo "⚠️ User 'bark' does not exist" fi echo "" echo "=== Cleaning Python Cache ===" sudo rm -rf /root/.cache/pip 2>/dev/null || true echo "βœ… Cache cleaned" echo "" echo "==========================================" echo " Verification" echo "==========================================" echo "" echo "Services:" if systemctl list-unit-files 2>/dev/null | grep -q bark; then echo "❌ Bark services still exist:" systemctl list-unit-files 2>/dev/null | grep bark else echo "βœ… No Bark services found" fi echo "" echo "Directories:" if [ -d /opt/bark ]; then echo "❌ Directory still exists: /opt/bark" else echo "βœ… No Bark directories found" fi echo "" echo "Users:" if id bark &>/dev/null 2>&1; then echo "❌ User 'bark' still exists" else echo "βœ… User 'bark' removed" fi echo "" echo "Processes:" if ps aux | grep -v grep | grep -q "bark_api"; then echo "❌ Bark processes still running" ps aux | grep -v grep | grep "bark_api" else echo "βœ… No Bark processes running" fi echo "" echo "Ports:" if sudo netstat -tlnp 2>/dev/null | grep -q 8443; then echo "❌ Port 8443 still in use" sudo netstat -tlnp 2>/dev/null | grep 8443 else echo "βœ… Port 8443 is free" fi echo "" echo "Disk Space Recovered:" echo "Previous: $(df -h /opt 2>/dev/null | tail -1 | awk '{print $4}') available" echo "" echo "==========================================" echo " βœ… Cleanup Complete!" echo "==========================================" echo "" echo "Next steps:" echo " 1. Verify disk space: df -h" echo " 2. Check available ports: sudo netstat -tlnp" echo " 3. Continue with OpenCCB features" echo "" INNEREOF # Copy to t-800 scp /tmp/cleanup_bark_remote.sh ${T800_USER}@${T800_HOST}:/tmp/cleanup_bark_remote.sh echo "" echo "πŸ”Œ Connecting to t-800 and running cleanup..." echo "" # Execute on t-800 ssh -t ${T800_USER}@${T800_HOST} << 'ENDSSH' chmod +x /tmp/cleanup_bark_remote.sh sudo /tmp/cleanup_bark_remote.sh # Clean up temp file rm /tmp/cleanup_bark_remote.sh ENDSSH echo "" echo "==========================================" echo " Local Cleanup Complete" echo "==========================================" echo "" # Clean up local temp file rm -f /tmp/cleanup_bark_remote.sh echo "βœ… All Bark TTS components have been removed from t-800" echo "" echo "πŸ“Š Next Steps - Choose What to Do Next:" echo "" echo " 1️⃣ Question Bank (sin audio)" echo " - Crear preguntas manualmente" echo " - Importar desde MySQL" echo " - Generar con IA" echo " - Acceder: /question-bank" echo "" echo " 2️⃣ Token Usage Dashboard" echo " - Ver consumo de IA por usuario" echo " - Monitorear costos" echo " - Detectar alto consumo" echo " - Acceder: /admin/token-usage" echo "" echo " 3️⃣ Importar Preguntas desde MySQL" echo " - Traer preguntas del sistema legacy" echo " - Marcar para no duplicar" echo " - Asignar skills automΓ‘ticamente" echo "" echo "πŸ’‘ Recommended: Try all three!" echo "" echo " cd /home/juan/dev/openccb" echo " # Start Studio" echo " cd web/studio && npm run dev" echo ""