deploy.sh 2.3 KB

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