From be748d2f9c22e2ca85fbb21918c7d2e27de7fd17 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 28 Jan 2026 00:50:00 +0000 Subject: [PATCH] feat(telegram-contacts-bot): add Mac Mini setup script https://claude.ai/code/session_01LwmhvhKpEsvVtY1ZKhYu6f --- .../telegram-contacts-bot/setup-mac-mini.sh | 144 ++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100755 services/telegram-contacts-bot/setup-mac-mini.sh diff --git a/services/telegram-contacts-bot/setup-mac-mini.sh b/services/telegram-contacts-bot/setup-mac-mini.sh new file mode 100755 index 000000000..3e20ed030 --- /dev/null +++ b/services/telegram-contacts-bot/setup-mac-mini.sh @@ -0,0 +1,144 @@ +#!/bin/bash +set -e + +echo "🚀 Setting up Telegram Contacts 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-contacts-bot + +# 4. Create database +echo -e "${YELLOW}🗄️ Creating database...${NC}" +psql -U manacore -d postgres -c "CREATE DATABASE contacts_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=3304 +NODE_ENV=production +TZ=Europe/Berlin + +# Telegram +TELEGRAM_BOT_TOKEN=8391505274:AAFaj39RulAYVZiZn9dttWxG6NCFYC6A2_8 +TELEGRAM_ALLOWED_USERS= + +# Contacts Backend API +CONTACTS_API_URL=http://localhost:3015 +MANA_CORE_AUTH_URL=http://localhost:3001 + +# Database +DATABASE_URL=postgresql://manacore:devpassword@localhost:5432/contacts_bot + +# Birthday Reminder Settings +BIRTHDAY_CHECK_ENABLED=true +BIRTHDAY_CHECK_TIME=08:00 +BIRTHDAY_CHECK_TIMEZONE=Europe/Berlin +BIRTHDAY_DAYS_AHEAD=7 +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-contacts-bot.plist << 'EOF' + + + + + Label + com.manacore.telegram-contacts-bot + ProgramArguments + + /opt/homebrew/bin/node + /Users/till/projects/manacore-monorepo/services/telegram-contacts-bot/dist/src/main.js + + WorkingDirectory + /Users/till/projects/manacore-monorepo/services/telegram-contacts-bot + EnvironmentVariables + + NODE_ENV + production + PORT + 3304 + TZ + Europe/Berlin + TELEGRAM_BOT_TOKEN + 8391505274:AAFaj39RulAYVZiZn9dttWxG6NCFYC6A2_8 + CONTACTS_API_URL + http://localhost:3015 + MANA_CORE_AUTH_URL + http://localhost:3001 + DATABASE_URL + postgresql://manacore:devpassword@localhost:5432/contacts_bot + BIRTHDAY_CHECK_ENABLED + true + BIRTHDAY_CHECK_TIME + 08:00 + BIRTHDAY_CHECK_TIMEZONE + Europe/Berlin + BIRTHDAY_DAYS_AHEAD + 7 + + RunAtLoad + + KeepAlive + + StandardOutPath + /Users/till/projects/manacore-monorepo/services/telegram-contacts-bot/logs/stdout.log + StandardErrorPath + /Users/till/projects/manacore-monorepo/services/telegram-contacts-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-contacts-bot.plist 2>/dev/null || true +launchctl load ~/Library/LaunchAgents/com.manacore.telegram-contacts-bot.plist + +# Wait a moment for startup +sleep 3 + +# 11. Check status +echo -e "${YELLOW}🔍 Checking status...${NC}" +if curl -s http://localhost:3304/health | grep -q "ok"; then + echo -e "${GREEN}✅ Telegram Contacts Bot is running!${NC}" + echo -e "${GREEN}🤖 Bot URL: https://t.me/contact_mana_bot${NC}" + echo "" + echo "Useful commands:" + echo " View logs: tail -f ~/projects/manacore-monorepo/services/telegram-contacts-bot/logs/stdout.log" + echo " Stop bot: launchctl unload ~/Library/LaunchAgents/com.manacore.telegram-contacts-bot.plist" + echo " Start bot: launchctl load ~/Library/LaunchAgents/com.manacore.telegram-contacts-bot.plist" + echo " Health check: curl http://localhost:3304/health" +else + echo -e "${YELLOW}⚠️ Bot may still be starting. Check logs:${NC}" + echo " tail -f ~/projects/manacore-monorepo/services/telegram-contacts-bot/logs/stderr.log" +fi