From 4737d75b7fc7328c4c9dde15ac22ff743ed83b63 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 28 Jan 2026 00:33:09 +0000 Subject: [PATCH] feat(telegram-calendar-bot): add Mac Mini setup script - Complete automated setup script for Mac Mini deployment - Creates database, installs deps, builds, and starts service - Uses launchd for persistent service on macOS - Includes health check and helpful commands https://claude.ai/code/session_01LwmhvhKpEsvVtY1ZKhYu6f --- .../telegram-calendar-bot/setup-mac-mini.sh | 144 ++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100755 services/telegram-calendar-bot/setup-mac-mini.sh diff --git a/services/telegram-calendar-bot/setup-mac-mini.sh b/services/telegram-calendar-bot/setup-mac-mini.sh new file mode 100755 index 000000000..cfe856e2e --- /dev/null +++ b/services/telegram-calendar-bot/setup-mac-mini.sh @@ -0,0 +1,144 @@ +#!/bin/bash +set -e + +echo "🚀 Setting up Telegram Calendar Bot on Mac Mini..." + +# Colors +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +NC='\033[0m' + +# 1. Navigate to project +echo -e "${YELLOW}📂 Navigating to project...${NC}" +cd ~/projects/manacore-monorepo + +# 2. Fetch and checkout branch +echo -e "${YELLOW}📥 Fetching latest code...${NC}" +git fetch origin claude/research-telegram-bots-LrdWJ +git checkout claude/research-telegram-bots-LrdWJ +git pull origin claude/research-telegram-bots-LrdWJ + +# 3. Navigate to bot directory +cd services/telegram-calendar-bot + +# 4. Create database +echo -e "${YELLOW}🗄️ Creating database...${NC}" +psql -U manacore -d postgres -c "CREATE DATABASE calendar_bot;" 2>/dev/null || echo "Database already exists" + +# 5. Install dependencies +echo -e "${YELLOW}📦 Installing dependencies...${NC}" +pnpm install + +# 6. Create .env file +echo -e "${YELLOW}⚙️ Creating .env file...${NC}" +cat > .env << 'EOF' +# Server +PORT=3303 +NODE_ENV=production +TZ=Europe/Berlin + +# Telegram +TELEGRAM_BOT_TOKEN=8226852885:AAHyfshVf8qOtdc626ZzAHDVcVtx0KpQ50g +TELEGRAM_ALLOWED_USERS= + +# Calendar Backend API +CALENDAR_API_URL=http://localhost:3016 +MANA_CORE_AUTH_URL=http://localhost:3001 + +# Database +DATABASE_URL=postgresql://manacore:devpassword@localhost:5432/calendar_bot + +# Reminder Settings +REMINDER_CHECK_INTERVAL=60000 +MORNING_BRIEFING_ENABLED=true +MORNING_BRIEFING_TIME=07:00 +MORNING_BRIEFING_TIMEZONE=Europe/Berlin +EOF + +# 7. Push database schema +echo -e "${YELLOW}🗂️ Pushing database schema...${NC}" +pnpm db:push + +# 8. Build +echo -e "${YELLOW}🔨 Building...${NC}" +pnpm build + +# 9. Create launchd plist for macOS +echo -e "${YELLOW}🍎 Creating launchd service...${NC}" +cat > ~/Library/LaunchAgents/com.manacore.telegram-calendar-bot.plist << 'EOF' + + + + + Label + com.manacore.telegram-calendar-bot + ProgramArguments + + /opt/homebrew/bin/node + /Users/till/projects/manacore-monorepo/services/telegram-calendar-bot/dist/src/main.js + + WorkingDirectory + /Users/till/projects/manacore-monorepo/services/telegram-calendar-bot + EnvironmentVariables + + NODE_ENV + production + PORT + 3303 + TZ + Europe/Berlin + TELEGRAM_BOT_TOKEN + 8226852885:AAHyfshVf8qOtdc626ZzAHDVcVtx0KpQ50g + CALENDAR_API_URL + http://localhost:3016 + MANA_CORE_AUTH_URL + http://localhost:3001 + DATABASE_URL + postgresql://manacore:devpassword@localhost:5432/calendar_bot + REMINDER_CHECK_INTERVAL + 60000 + MORNING_BRIEFING_ENABLED + true + MORNING_BRIEFING_TIME + 07:00 + MORNING_BRIEFING_TIMEZONE + Europe/Berlin + + RunAtLoad + + KeepAlive + + StandardOutPath + /Users/till/projects/manacore-monorepo/services/telegram-calendar-bot/logs/stdout.log + StandardErrorPath + /Users/till/projects/manacore-monorepo/services/telegram-calendar-bot/logs/stderr.log + + +EOF + +# Create logs directory +mkdir -p logs + +# 10. Load and start service +echo -e "${YELLOW}▶️ Starting service...${NC}" +launchctl unload ~/Library/LaunchAgents/com.manacore.telegram-calendar-bot.plist 2>/dev/null || true +launchctl load ~/Library/LaunchAgents/com.manacore.telegram-calendar-bot.plist + +# Wait a moment for startup +sleep 3 + +# 11. Check status +echo -e "${YELLOW}🔍 Checking status...${NC}" +if curl -s http://localhost:3303/health | grep -q "ok"; then + echo -e "${GREEN}✅ Telegram Calendar Bot is running!${NC}" + echo -e "${GREEN}🤖 Bot URL: https://t.me/calendar_mana_bot${NC}" + echo "" + echo "Useful commands:" + echo " View logs: tail -f ~/projects/manacore-monorepo/services/telegram-calendar-bot/logs/stdout.log" + echo " Stop bot: launchctl unload ~/Library/LaunchAgents/com.manacore.telegram-calendar-bot.plist" + echo " Start bot: launchctl load ~/Library/LaunchAgents/com.manacore.telegram-calendar-bot.plist" + echo " Health check: curl http://localhost:3303/health" +else + echo -e "${YELLOW}⚠️ Bot may still be starting. Check logs:${NC}" + echo " tail -f ~/projects/manacore-monorepo/services/telegram-calendar-bot/logs/stderr.log" +fi