deploy.sh 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/bin/bash
  2. # -----------------------------------------------------------------------------
  3. # Naked Environment Deployment Script for Ubuntu 24.04
  4. # Run this script to seamlessly fully provision the server for the AI Web App.
  5. # -----------------------------------------------------------------------------
  6. set -e
  7. echo "=========================================================="
  8. echo " Starting Full Environment Deployment for Ubuntu 24.04..."
  9. echo "=========================================================="
  10. # 1. Update system packages
  11. echo ""
  12. echo "[1/6] Updating APT cache and installing system dependencies (GCC, Python, MySQL Server)..."
  13. sudo apt update
  14. sudo apt install -y build-essential gcc python3-venv python3-dev python3-pip curl mysql-server
  15. # 2. Install Ollama natively
  16. echo ""
  17. echo "[2/6] Installing Ollama Engine..."
  18. curl -fsSL https://ollama.com/install.sh | sh
  19. # 3. Secure and setup MySQL Server configuration
  20. echo ""
  21. echo "[3/6] Configuring MySQL Server settings (Local infile & validation policies)..."
  22. # We inject the provided my.cnf configuration directly into the MySQL system config
  23. if [ -f "./my.cnf" ]; then
  24. sudo cp ./my.cnf /etc/mysql/conf.d/custom_ai_app.cnf
  25. echo "Custom MySQL configurations applied from my.cnf."
  26. else
  27. echo "Warning: my.cnf not found in the current directory."
  28. fi
  29. sudo systemctl restart mysql
  30. echo "MySQL Service restarted."
  31. # 4. Set up Python Virtual Environment (PEP 668 compliant)
  32. echo ""
  33. echo "[4/6] Setting up Python 3 Virtual Environment ('venv')..."
  34. python3 -m venv venv
  35. # From here on, we temporarily export the paths to use the new virtual env directly
  36. export PATH="$PWD/venv/bin:$PATH"
  37. # 5. Install Required Python Libraries
  38. echo ""
  39. echo "[5/6] Installing Python dependencies via pip inside venv..."
  40. pip install --upgrade pip
  41. pip install pandas pymysql myloginpath streamlit ollama bcrypt
  42. echo ""
  43. echo "=========================================================="
  44. echo " 🎉 Environment Deployment Complete! "
  45. echo "=========================================================="
  46. echo ""
  47. echo "Next steps:"
  48. echo "1. Activate your virtual environment manually: source venv/bin/activate"
  49. echo "2. Check your config.ini file details."
  50. echo "3. Run your setup script to configure database users: python setup_db.py"