From 7e94e91753232423f020a08bacb89b0b573f768b Mon Sep 17 00:00:00 2001 From: 0xK Date: Tue, 24 Mar 2026 10:02:52 +0100 Subject: [PATCH] =?UTF-8?q?remove=20setup.sh=20=E2=80=94=20logic=20moved?= =?UTF-8?q?=20into=20start.sh?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- setup.sh | 147 ------------------------------------------------------- 1 file changed, 147 deletions(-) delete mode 100644 setup.sh diff --git a/setup.sh b/setup.sh deleted file mode 100644 index 7a2a09e..0000000 --- a/setup.sh +++ /dev/null @@ -1,147 +0,0 @@ -#!/usr/bin/env bash -# setup.sh — one-time setup for poke-mail -# Automates token creation via the Poke login SDK so you don't have to -# copy/paste API keys manually. -set -euo pipefail - -cd "$(dirname "$0")" - -echo "" -echo " poke-mail setup" -echo " ────────────────────────────────────────" -echo "" - -# ── 1. Python virtualenv ──────────────────────────────────────────────────── -if [ ! -d .venv ]; then - echo "Creating Python virtualenv (.venv)..." - python3 -m venv .venv -fi -source .venv/bin/activate -echo "Installing Python dependencies..." -pip install -q -r requirements.txt -echo " ✓ Python dependencies installed" -echo "" - -# ── 2. Poke API key (poke_api_key for config.yml) ──────────────────────────── -# The 'poke' npm package stores credentials at: -# ~/.config/poke/credentials.json → { "token": "..." } -# when the user runs: npx poke login - -POKE_CREDENTIALS_FILE="${XDG_CONFIG_HOME:-$HOME/.config}/poke/credentials.json" -POKE_API_KEY_VALUE="" - -if [ -f "$POKE_CREDENTIALS_FILE" ]; then - # Try to extract .token with python (avoids jq dependency) - POKE_API_KEY_VALUE=$(python3 -c " -import json, sys -try: - data = json.load(open('$POKE_CREDENTIALS_FILE')) - print(data.get('token', '')) -except Exception: - print('') -" 2>/dev/null || true) -fi - -if [ -n "$POKE_API_KEY_VALUE" ]; then - echo " ✓ Found Poke credentials from 'poke login'" -else - echo " Poke API key not found via 'poke login'." - echo "" - echo " Option 1 (recommended): Run the following, then re-run this script:" - echo " npx poke login" - echo "" - echo " Option 2: Paste your API key from https://poke.com/settings/advanced" - echo "" - printf " Poke API key (leave blank to set later): " - read -r POKE_API_KEY_VALUE - POKE_API_KEY_VALUE=$(echo "$POKE_API_KEY_VALUE" | tr -d '[:space:]') -fi -echo "" - -# ── 3. config.yml ──────────────────────────────────────────────────────────── -if [ ! -f config.yml ]; then - echo "Copying config.example.yml → config.yml..." - cp config.example.yml config.yml - echo " ✓ config.yml created" -else - echo " ✓ config.yml already exists — skipping copy" -fi - -# Inject poke_api_key into config.yml if we have one -if [ -n "$POKE_API_KEY_VALUE" ]; then - # Replace the placeholder value in-place (handles both quoted forms) - python3 - <"${POKE_API_KEY_VALUE}"' -new_content = re.sub(pattern, replacement, content) - -with open('config.yml', 'w') as f: - f.write(new_content) - -print(' ✓ poke_api_key written to config.yml') -EOF -else - echo " ⚠ poke_api_key not set — edit config.yml manually before running start.sh" -fi -echo "" - -# ── 4. MCP_API_KEY (.env) ──────────────────────────────────────────────────── -if [ -f .env ] && grep -q 'MCP_API_KEY=' .env && ! grep -q 'MCP_API_KEY=your-secret-key-here' .env; then - echo " ✓ .env already has MCP_API_KEY — skipping" -else - echo "Generating MCP_API_KEY..." - RANDOM_KEY=$(python3 -c " -import secrets, string -alphabet = string.ascii_letters + string.digits -print(''.join(secrets.choice(alphabet) for _ in range(48))) -") - if [ -f .env ]; then - # Update existing file - python3 - < .env - fi - echo " ✓ MCP_API_KEY generated and saved to .env" -fi -echo "" - -# ── 5. Poke npm package ─────────────────────────────────────────────────────── -if ! command -v poke &>/dev/null; then - echo "Installing the 'poke' npm package globally..." - npm install -g poke - echo " ✓ poke installed" -else - echo " ✓ poke CLI already installed ($(poke --version 2>/dev/null || echo 'version unknown'))" -fi -echo "" - -# ── Done ───────────────────────────────────────────────────────────────────── -echo " ────────────────────────────────────────" -echo " Setup complete!" -echo "" -if [ -z "$POKE_API_KEY_VALUE" ]; then - echo " Next steps:" - echo " 1. Run 'npx poke login' or add your Poke API key to config.yml" - echo " 2. Fill in your email credentials in config.yml" - echo " 3. Run ./start.sh" -else - echo " Next steps:" - echo " 1. Fill in your email credentials in config.yml" - echo " 2. Run ./start.sh" -fi -echo ""