Files
cursor-free-vip/scripts/install_local.sh

114 lines
4.5 KiB
Bash
Executable File
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# Color definitions
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
NC='\033[0m' # No Color
# Logo
print_logo() {
echo -e "${CYAN}"
cat << "EOF"
██████╗██╗ ██╗██████╗ ███████╗ ██████╗ ██████╗ ██████╗ ██████╗ ██████╗
██╔════╝██║ ██║██╔══██╗██╔════╝██╔═══██╗██╔══██╗ ██╔══██╗██╔══██╗██╔═══██╗
██║ ██║ ██║██████╔╝███████╗██║ ██║██████╔╝ ██████╔╝██████╔╝██║ ██║
██║ ██║ ██║██╔══██╗╚════██║██║ ██║██╔══██╗ ██╔═══╝ ██╔══██╗██║ ██║
╚██████╗╚██████╔╝██║ ██║███████║╚██████╔╝██║ ██║ ██║ ██║ ██║╚██████╔╝
╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝
EOF
echo -e "${NC}"
}
# Get script directory
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
PROJECT_DIR="$( cd "${SCRIPT_DIR}/.." && pwd )"
# Check if Python is installed
check_python() {
echo -e "${CYAN} Проверка установки Python...${NC}"
if command -v python3 &> /dev/null; then
PYTHON_CMD="python3"
PYTHON_VERSION=$(python3 --version 2>&1 | awk '{print $2}')
echo -e "${GREEN}✅ Найден Python: ${PYTHON_VERSION}${NC}"
return 0
elif command -v python &> /dev/null; then
PYTHON_CMD="python"
PYTHON_VERSION=$(python --version 2>&1 | awk '{print $2}')
echo -e "${GREEN}✅ Найден Python: ${PYTHON_VERSION}${NC}"
return 0
else
echo -e "${RED}❌ Python не установлен${NC}"
echo -e "${YELLOW}Пожалуйста, установите Python 3.8 или выше${NC}"
exit 1
fi
}
# Check and install dependencies
check_dependencies() {
echo -e "${CYAN} Проверка зависимостей...${NC}"
if [ ! -f "${PROJECT_DIR}/requirements.txt" ]; then
echo -e "${RED}❌ Файл requirements.txt не найден${NC}"
exit 1
fi
# Check if virtual environment exists
if [ ! -d "${PROJECT_DIR}/venv" ]; then
echo -e "${YELLOW}⚠️ Виртуальное окружение не найдено. Создание...${NC}"
$PYTHON_CMD -m venv "${PROJECT_DIR}/venv"
echo -e "${GREEN}✅ Виртуальное окружение создано${NC}"
fi
# Activate virtual environment
source "${PROJECT_DIR}/venv/bin/activate"
# Install/update dependencies
echo -e "${CYAN} Установка зависимостей...${NC}"
pip install -q --upgrade pip
pip install -q -r "${PROJECT_DIR}/requirements.txt"
if [ $? -eq 0 ]; then
echo -e "${GREEN}Все зависимости установлены${NC}"
else
echo -e "${RED}❌ Ошибка при установке зависимостей${NC}"
exit 1
fi
}
# Run the main script
run_script() {
echo -e "${CYAN} Запуск Cursor Free VIP...${NC}"
# Check if running with sudo on Linux
if [ "$(uname)" == "Linux" ] && [ "$EUID" -ne 0 ]; then
echo -e "${YELLOW}⚠️ Рекомендуется запускать с правами администратора${NC}"
echo -e "${CYAN} Попытка запуска с sudo...${NC}"
sudo "${PROJECT_DIR}/venv/bin/python" "${PROJECT_DIR}/main.py"
else
"${PROJECT_DIR}/venv/bin/python" "${PROJECT_DIR}/main.py"
fi
}
# Main program
main() {
print_logo
# Check if we're in the right directory
if [ ! -f "${PROJECT_DIR}/main.py" ]; then
echo -e "${RED}❌ main.py не найден в ${PROJECT_DIR}${NC}"
echo -e "${YELLOW}Убедитесь, что скрипт запущен из директории проекта${NC}"
exit 1
fi
check_python
check_dependencies
run_script
}
# Run main program
main