Files
PyGuardian/deployment/scripts/install-old.sh
Andrey K. Choi 4adb00a498
Some checks reported errors
continuous-integration/drone/push Build encountered an error
feat: Complete Docker deployment environment for PyGuardian v2.1.0
🐳 DOCKER DEPLOYMENT INFRASTRUCTURE:

## New Docker Files:
- deployment/docker/Dockerfile.optimized - Multi-stage optimized builds
- docker-compose.prod.yml - Production cluster deployment
- docker-compose.dev.yml - Development environment
- deploy-docker.sh - One-command deployment script
- Makefile.docker - Advanced management commands
- .env.docker - Environment configuration template
- DOCKER_DEPLOYMENT.md - Complete deployment guide

## Container Images:
- pyguardian:controller - Cluster management (200MB)
- pyguardian:agent - Security monitoring (180MB)
- pyguardian:standalone - All-in-one deployment (220MB)
- pyguardian:development - Dev tools + Jupyter (350MB)

## Deployment Modes:
- Standalone: Single container with all features
- Cluster: Controller + scalable agents with JWT auth
- Production: Enterprise deployment with monitoring
- Development: Hot reload + debugging tools

## Key Features:
 Multi-stage Docker builds for optimization
 Privileged containers for system monitoring
 Host networking for firewall integration
 Volume persistence for data/logs/config
 Health checks and auto-restart
 Prometheus monitoring integration
 SSL/TLS support with custom certificates
 Automated backup and restore
 CI/CD ready builds

## Quick Commands:
./deploy-docker.sh standalone          # Quick start
./deploy-docker.sh cluster --scale 3   # Production cluster
make -f Makefile.docker prod-up        # Advanced management
make -f Makefile.docker health         # Health checks

Ready for enterprise Docker deployment! 🚀
2025-11-26 04:42:36 +09:00

274 lines
8.6 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
#==========================================================================
# PyGuardian Quick Installation Script
# Wrapper for the main installation system
# Author: SmartSolTech Team
# Version: 2.0
#==========================================================================
set -e
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
BLUE='\033[0;34m'
YELLOW='\033[1;33m'
NC='\033[0m'
print_header() {
echo -e "${BLUE}"
echo "================================================="
echo " PyGuardian Security System - Quick Installer"
echo "================================================="
echo -e "${NC}"
}
print_info() {
echo -e "${BLUE} $1${NC}"
}
print_success() {
echo -e "${GREEN}$1${NC}"
}
print_error() {
echo -e "${RED}$1${NC}"
}
# Check if running as root
check_root() {
if [[ $EUID -ne 0 ]]; then
print_error "This script must be run as root or with sudo"
echo "Usage: sudo ./install.sh"
exit 1
fi
}
# Show installation options
show_options() {
echo ""
print_info "Выберите тип установки:"
echo ""
echo "1) 🔧 Быстрая установка (Standalone режим)"
echo "2) 📋 Интерактивная установка с выбором режима"
echo "3) 🐳 Docker установка"
echo "4) 📖 Показать документацию"
echo "5) ❌ Выход"
echo ""
}
# Quick standalone installation
quick_install() {
print_info "Запуск быстрой установки (Standalone режим)..."
# Run the main installation script
if [[ -f "scripts/install.sh" ]]; then
chmod +x scripts/install.sh
./scripts/install.sh --mode=standalone
else
print_error "Installation script not found!"
exit 1
fi
}
# Interactive installation
interactive_install() {
print_info "Запуск интерактивной установки..."
if [[ -f "scripts/install.sh" ]]; then
chmod +x scripts/install.sh
./scripts/install.sh
else
print_error "Installation script not found!"
exit 1
fi
}
# Docker installation
docker_install() {
print_info "Запуск Docker установки..."
if [[ -f "scripts/docker-install.sh" ]]; then
chmod +x scripts/docker-install.sh
./scripts/docker-install.sh
else
print_error "Docker installation script not found!"
exit 1
fi
}
# Show documentation
show_documentation() {
echo ""
echo -e "${BLUE}📖 Документация PyGuardian${NC}"
echo ""
echo "Основные файлы документации:"
echo " • README.md - Основная документация"
echo " • docs/CLUSTER_SETUP.md - Настройка кластера"
echo " • config/config.yaml - Пример конфигурации"
echo ""
echo "Онлайн ресурсы:"
echo " • GitHub: https://github.com/your-repo/PyGuardian"
echo " • Wiki: https://github.com/your-repo/PyGuardian/wiki"
echo ""
echo "Быстрые команды после установки:"
echo " • make install - Интерактивная установка"
echo " • make standalone - Автономный сервер"
echo " • make controller - Контроллер кластера"
echo " • make agent - Агент кластера"
echo ""
}
# Main function
main() {
print_header
# Check if running as root
check_root
# If arguments provided, run directly
if [[ $# -gt 0 ]]; then
case "$1" in
--quick|--standalone)
quick_install
;;
--interactive)
interactive_install
;;
--docker)
docker_install
;;
--help|-h)
echo "Usage: $0 [--quick|--interactive|--docker|--help]"
echo ""
echo "Options:"
echo " --quick Quick standalone installation"
echo " --interactive Interactive installation with mode selection"
echo " --docker Docker-based installation"
echo " --help Show this help"
;;
*)
print_error "Unknown option: $1"
echo "Use --help for usage information"
exit 1
;;
esac
return
fi
# Interactive menu
while true; do
show_options
read -p "Выберите опцию (1-5): " choice
case $choice in
1)
quick_install
break
;;
2)
interactive_install
break
;;
3)
docker_install
break
;;
4)
show_documentation
read -p "Нажмите Enter для продолжения..."
;;
5)
print_info "Выход из установщика"
exit 0
;;
*)
print_error "Неверный выбор. Введите число от 1 до 5."
;;
esac
done
print_success "Установка завершена! Спасибо за использование PyGuardian!"
}
# Run main with all arguments
main "$@"
echo "✅ Python ${PYTHON_VERSION} обнаружен"
# Проверка pip
if ! command -v pip3 &> /dev/null; then
echo "❌ pip3 не найден. Установите python3-pip"
exit 1
fi
echo "✅ pip3 найден"
# Установка системных пакетов (опционально)
echo "📦 Установка системных зависимостей..."
if command -v apt-get &> /dev/null; then
apt-get update
apt-get install -y python3-pip python3-venv iptables
elif command -v yum &> /dev/null; then
yum install -y python3-pip python3-virtualenv iptables
elif command -v dnf &> /dev/null; then
dnf install -y python3-pip python3-virtualenv iptables
else
echo "⚠️ Автоматическая установка пакетов не поддерживается для этой системы"
echo " Убедитесь что установлены: python3-pip, iptables/nftables"
fi
# Создание директорий
echo "📁 Создание директорий..."
mkdir -p "$INSTALL_DIR"
mkdir -p "$CONFIG_DIR"
mkdir -p "$DATA_DIR"
chmod 700 "$DATA_DIR"
# Копирование файлов
echo "📋 Копирование файлов..."
cp -r src/ "$INSTALL_DIR/"
cp main.py "$INSTALL_DIR/"
cp requirements.txt "$INSTALL_DIR/"
# Копирование конфигурации
if [[ ! -f "$CONFIG_DIR/config.yaml" ]]; then
cp config/config.yaml "$CONFIG_DIR/"
echo " Конфигурация скопирована в $CONFIG_DIR/config.yaml"
else
echo "⚠️ Конфигурация уже существует в $CONFIG_DIR/config.yaml"
fi
# Установка Python зависимостей
echo "🐍 Установка Python зависимостей..."
cd "$INSTALL_DIR"
pip3 install -r requirements.txt
# Установка systemd сервиса
echo "⚙️ Установка systemd сервиса..."
sed "s|/opt/pyguardian|$INSTALL_DIR|g; s|/opt/pyguardian/config/config.yaml|$CONFIG_DIR/config.yaml|g" \
systemd/pyguardian.service > "$SERVICE_FILE"
# Права на файлы
chmod +x "$INSTALL_DIR/main.py"
chown -R root:root "$INSTALL_DIR"
# Перезагрузка systemd
systemctl daemon-reload
echo ""
echo "✅ PyGuardian успешно установлен!"
echo ""
echo "📝 Следующие шаги:"
echo "1. Настройте конфигурацию в $CONFIG_DIR/config.yaml"
echo "2. Получите токен Telegram бота от @BotFather"
echo "3. Узнайте ваш Telegram ID через @userinfobot"
echo "4. Обновите конфигурацию с токеном и ID"
echo "5. Запустите сервис: systemctl start pyguardian"
echo "6. Включите автозапуск: systemctl enable pyguardian"
echo ""
echo "🔧 Полезные команды:"
echo " systemctl status pyguardian - статус сервиса"
echo " systemctl logs pyguardian - просмотр логов"
echo " systemctl restart pyguardian - перезапуск"
echo ""
echo "📖 Документация: https://github.com/your-org/pyguardian"