|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +check_python() { |
| 4 | + # Check for Python installation |
| 5 | + if ! command -v python3 &>/dev/null; then |
| 6 | + echo "Python is not installed." |
| 7 | + read -p "Do you want to install Python 3.10.12? (y/n): " install_python |
| 8 | + if [[ "$install_python" == "y" ]]; then |
| 9 | + install_python |
| 10 | + else |
| 11 | + echo "Exiting." |
| 12 | + exit 1 |
| 13 | + fi |
| 14 | + else |
| 15 | + PYTHON_VERSION=$(python3 --version | grep -oP '\d+\.\d+') |
| 16 | + if (( $(echo "$PYTHON_VERSION < 3.10" | bc -l) )); then |
| 17 | + echo "Python version is less than 3.10." |
| 18 | + read -p "Do you want to update to Python 3.10.12? (y/n): " update_python |
| 19 | + if [[ "$update_python" == "y" ]]; then |
| 20 | + install_python |
| 21 | + else |
| 22 | + echo "Exiting." |
| 23 | + exit 1 |
| 24 | + fi |
| 25 | + fi |
| 26 | + fi |
| 27 | +} |
| 28 | + |
| 29 | +install_python() { |
| 30 | + echo "Installing Python 3.10.12..." |
| 31 | + if [[ "$OSTYPE" == "linux-gnu"* ]]; then |
| 32 | + sudo apt update |
| 33 | + sudo apt install -y python3.10 python3-pip |
| 34 | + elif [[ "$OSTYPE" == "darwin"* ]]; then |
| 35 | + |
| 36 | + else |
| 37 | + echo "Unsupported OS for automatic Python installation." |
| 38 | + exit 1 |
| 39 | + fi |
| 40 | +} |
| 41 | + |
| 42 | +upgrade_pip() { |
| 43 | + # Upgrade pip |
| 44 | + python3 -m pip install --upgrade pip |
| 45 | +} |
| 46 | + |
| 47 | +check_mastermind_ai() { |
| 48 | + # Check if mastermind-ai is installed |
| 49 | + if ! pip show mastermind-ai &>/dev/null; then |
| 50 | + echo "mastermind-ai is not installed. Installing..." |
| 51 | + pip install mastermind-ai |
| 52 | + else |
| 53 | + echo "mastermind-ai is already installed." |
| 54 | + if pip list --outdated | grep mastermind-ai &>/dev/null; then |
| 55 | + read -p "An update for mastermind-ai is available. Do you want to update it? (y/n): " update_package |
| 56 | + if [[ "$update_package" == "y" ]]; then |
| 57 | + pip install --upgrade mastermind-ai |
| 58 | + fi |
| 59 | + fi |
| 60 | + fi |
| 61 | +} |
| 62 | + |
| 63 | +# Main execution |
| 64 | +check_python |
| 65 | +upgrade_pip # Call to upgrade pip |
| 66 | +check_mastermind_ai # Call to check mastermind-ai installation |
| 67 | + |
| 68 | +# Clear the screen and run mastermind |
| 69 | +clear |
| 70 | +mastermind |
0 commit comments