Files
cbazzaandClaude Sonnet 4.5 f6106b8333 Initial commit: Lotto number generator project
This project includes multiple AI/ML-based lottery number generators for
German Lotto 6aus49, including pattern analysis, weighted predictions,
and hybrid approaches. Features automated weekly tip generation,
performance tracking, and Telegram bot integration.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-16 14:47:59 +01:00

220 lines
8.4 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
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
###############################################################################
# Lotto 6aus49 - Automatische Tipp-Generierung Setup
#
# Richtet Cron-Jobs ein für automatische wöchentliche Tipp-Generierung
#
# Zeitplan:
# - Dienstag 09:00 (vor Mittwoch-Ziehung)
# - Freitag 09:00 (vor Samstag-Ziehung)
#
# Verwendung:
# chmod +x setup_cron.sh
# ./setup_cron.sh
###############################################################################
set -e
# Farben für Output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
echo -e "${BLUE}╔═══════════════════════════════════════════════════════════╗${NC}"
echo -e "${BLUE}║ LOTTO 6AUS49 - AUTOMATISIERUNG SETUP ║${NC}"
echo -e "${BLUE}╚═══════════════════════════════════════════════════════════╝${NC}"
echo ""
# Project Directory
PROJECT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
SCRIPT_PATH="${PROJECT_DIR}/scripts/automation/weekly_tip_generator.py"
LOG_DIR="${PROJECT_DIR}/logs"
LOG_FILE="${LOG_DIR}/weekly_tips.log"
echo -e "${YELLOW}📁 Project Directory:${NC} ${PROJECT_DIR}"
echo -e "${YELLOW}🐍 Script Path:${NC} ${SCRIPT_PATH}"
echo -e "${YELLOW}📝 Log File:${NC} ${LOG_FILE}"
echo ""
# Check if script exists
if [ ! -f "${SCRIPT_PATH}" ]; then
echo -e "${RED}❌ Fehler: Script nicht gefunden: ${SCRIPT_PATH}${NC}"
exit 1
fi
# Create logs directory
mkdir -p "${LOG_DIR}"
echo -e "${GREEN}✅ Logs-Verzeichnis erstellt/überprüft${NC}"
# Check Python
PYTHON_CMD="python3"
if ! command -v ${PYTHON_CMD} &> /dev/null; then
echo -e "${RED}❌ Python3 nicht gefunden${NC}"
exit 1
fi
PYTHON_VERSION=$(${PYTHON_CMD} --version 2>&1 | awk '{print $2}')
echo -e "${GREEN}✅ Python gefunden: ${PYTHON_VERSION}${NC}"
# Check required Python packages
echo ""
echo -e "${BLUE}🔍 Überprüfe Python-Pakete...${NC}"
REQUIRED_PACKAGES=("pandas" "numpy" "sklearn" "requests")
MISSING_PACKAGES=()
for package in "${REQUIRED_PACKAGES[@]}"; do
if ${PYTHON_CMD} -c "import ${package}" 2>/dev/null; then
echo -e "${GREEN}${package}${NC}"
else
echo -e "${RED}${package} fehlt${NC}"
MISSING_PACKAGES+=("${package}")
fi
done
if [ ${#MISSING_PACKAGES[@]} -gt 0 ]; then
echo ""
echo -e "${YELLOW}⚠️ Fehlende Pakete gefunden. Installation mit:${NC}"
echo -e "${YELLOW} pip install ${MISSING_PACKAGES[*]}${NC}"
echo ""
read -p "Jetzt installieren? (j/n): " -n 1 -r
echo
if [[ $REPLY =~ ^[JjYy]$ ]]; then
pip install "${MISSING_PACKAGES[@]}"
echo -e "${GREEN}✅ Pakete installiert${NC}"
else
echo -e "${RED}❌ Installation abgebrochen${NC}"
exit 1
fi
fi
# Test script
echo ""
echo -e "${BLUE}🧪 Teste Script...${NC}"
if ${PYTHON_CMD} "${SCRIPT_PATH}" --history > /dev/null 2>&1; then
echo -e "${GREEN}✅ Script funktioniert${NC}"
else
echo -e "${RED}❌ Script-Test fehlgeschlagen${NC}"
echo -e "${YELLOW}Führe manuell aus: ${PYTHON_CMD} ${SCRIPT_PATH} --history${NC}"
exit 1
fi
# Test notifications
echo ""
echo -e "${BLUE}📲 Teste Benachrichtigungs-System...${NC}"
NOTIFIER_PATH="${PROJECT_DIR}/scripts/utils/notifier.py"
if [ -f "${NOTIFIER_PATH}" ]; then
if ${PYTHON_CMD} "${NOTIFIER_PATH}" --test 2>&1 | grep -q "erfolgreich"; then
echo -e "${GREEN}✅ Benachrichtigungen funktionieren${NC}"
else
echo -e "${YELLOW}⚠️ Benachrichtigungen nicht konfiguriert${NC}"
echo -e "${YELLOW} Konfiguriere config/notifications.json${NC}"
fi
else
echo -e "${YELLOW}⚠️ Notifier nicht gefunden${NC}"
fi
# Generate cron entries
echo ""
echo -e "${BLUE}⚙️ Erstelle Cron-Job Einträge...${NC}"
# Virtuelles Environment
VENV_PYTHON="${PROJECT_DIR}/../Eurojackpot/venv/bin/python3"
if [ ! -f "${VENV_PYTHON}" ]; then
VENV_PYTHON="${PYTHON_CMD}"
fi
UPDATE_SCRIPT="${PROJECT_DIR}/scripts/automation/auto_update_and_learn.py"
UPDATE_LOG="${LOG_DIR}/auto_update.log"
CRON_ENTRIES="# ========== LOTTO 6AUS49 AUTOMATION ==========
# Tipp-Generierung: Dienstag & Freitag um 09:00 (vor Ziehungen Mi & Sa)
0 9 * * 2,5 cd ${PROJECT_DIR} && ${VENV_PYTHON} ${SCRIPT_PATH} >> ${LOG_FILE} 2>&1
# Auto-Update & Learning: Mittwoch & Sonntag um 21:00 (nach Ziehungen)
0 21 * * 3,0 cd ${PROJECT_DIR} && ${VENV_PYTHON} ${UPDATE_SCRIPT} >> ${UPDATE_LOG} 2>&1"
echo ""
echo -e "${YELLOW}Cron-Job Einträge:${NC}"
echo "─────────────────────────────────────────────────────────"
echo "${CRON_ENTRIES}"
echo "─────────────────────────────────────────────────────────"
echo ""
# Ask to install
read -p "Cron-Job jetzt installieren? (j/n): " -n 1 -r
echo
if [[ $REPLY =~ ^[JjYy]$ ]]; then
# Backup current crontab
CRON_BACKUP="${PROJECT_DIR}/logs/crontab_backup_$(date +%Y%m%d_%H%M%S).txt"
crontab -l > "${CRON_BACKUP}" 2>/dev/null || true
echo -e "${GREEN}✅ Backup erstellt: ${CRON_BACKUP}${NC}"
# Check if entry already exists
if crontab -l 2>/dev/null | grep -q "LOTTO 6AUS49 AUTOMATION"; then
echo -e "${YELLOW}⚠️ Cron-Jobs existieren bereits${NC}"
read -p "Überschreiben? (j/n): " -n 1 -r
echo
if [[ ! $REPLY =~ ^[JjYy]$ ]]; then
echo -e "${BLUE}️ Installation abgebrochen${NC}"
exit 0
fi
# Remove old entries
crontab -l 2>/dev/null | grep -v "LOTTO 6AUS49" | grep -v "weekly_tip_generator.py" | grep -v "auto_update_and_learn.py" | crontab -
fi
# Add new entries
(crontab -l 2>/dev/null; echo "${CRON_ENTRIES}") | crontab -
echo -e "${GREEN}✅ Cron-Jobs erfolgreich installiert!${NC}"
echo ""
echo -e "${BLUE}📅 Zeitplan:${NC}"
echo " • Dienstag 09:00 - Tipps generieren (vor Mi-Ziehung)"
echo " • Mittwoch 21:00 - Auto-Update & Learning (nach Mi-Ziehung)"
echo " • Freitag 09:00 - Tipps generieren (vor Sa-Ziehung)"
echo " • Sonntag 21:00 - Auto-Update & Learning (nach Sa-Ziehung)"
echo ""
echo -e "${BLUE}📝 Logs:${NC}"
echo " • Tipps: ${LOG_FILE}"
echo " • Updates: ${UPDATE_LOG}"
echo ""
# Show current crontab
echo -e "${BLUE}🕐 Aktuelle Cron-Jobs:${NC}"
echo "─────────────────────────────────────────────────────────"
crontab -l | grep -v "^#" | grep -v "^$" || echo "Keine anderen Cron-Jobs"
echo "─────────────────────────────────────────────────────────"
else
echo -e "${BLUE}️ Installation abgebrochen${NC}"
echo ""
echo -e "${YELLOW}Manuell installieren mit:${NC}"
echo " crontab -e"
echo ""
echo "Und folgende Einträge hinzufügen:"
echo "${CRON_ENTRIES}"
fi
echo ""
echo -e "${GREEN}╔═══════════════════════════════════════════════════════════╗${NC}"
echo -e "${GREEN}║ SETUP ABGESCHLOSSEN ║${NC}"
echo -e "${GREEN}╚═══════════════════════════════════════════════════════════╝${NC}"
echo ""
echo -e "${BLUE}Nützliche Befehle:${NC}"
echo " • Cron-Jobs anzeigen: crontab -l"
echo " • Cron-Jobs entfernen: crontab -e (dann Zeilen löschen)"
echo " • Tipp-Logs anzeigen: tail -f ${LOG_FILE}"
echo " • Update-Logs anzeigen: tail -f ${UPDATE_LOG}"
echo " • Tipps manuell generieren: ${VENV_PYTHON} ${SCRIPT_PATH} --force"
echo " • Update manuell starten: ${VENV_PYTHON} ${UPDATE_SCRIPT}"
echo " • Historie anzeigen: ${VENV_PYTHON} ${SCRIPT_PATH} --history"
echo " • Test-Notification: ${VENV_PYTHON} ${NOTIFIER_PATH} --test"
echo ""
echo -e "${YELLOW}🍀 Viel Glück bei der nächsten Ziehung! 🍀${NC}"
echo ""