life-todo

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

setup.sh (3597B)


      1 #!/usr/bin/env zsh
      2 set -e
      3 
      4 REPO_ROOT="$(cd "$(dirname "${0}")/.." && pwd)"
      5 cd "$REPO_ROOT"
      6 
      7 echo "=== life-todo setup ==="
      8 
      9 # Check Node version
     10 NODE_VERSION=$(node --version 2>/dev/null | sed 's/v//' | cut -d. -f1)
     11 if [ -z "$NODE_VERSION" ] || [ "$NODE_VERSION" -lt 20 ]; then
     12   echo "ERROR: Node.js 20+ is required. Found: $(node --version 2>/dev/null || echo 'not installed')"
     13   exit 1
     14 fi
     15 echo "✓ Node.js $(node --version)"
     16 
     17 # Check git
     18 if ! command -v git &>/dev/null; then
     19   echo "ERROR: git is not installed."
     20   exit 1
     21 fi
     22 echo "✓ git $(git --version | awk '{print $3}')"
     23 
     24 # Check .env
     25 if [ ! -f .env ]; then
     26   cp .env.example .env
     27   echo "✓ Created .env from .env.example — fill in your credentials before starting."
     28 else
     29   echo "✓ .env already exists"
     30 fi
     31 
     32 # Install dependencies
     33 echo "Installing npm dependencies..."
     34 npm install
     35 echo "✓ Dependencies installed"
     36 
     37 # Create tmp directory (gitignored, outside the data repo)
     38 mkdir -p data/tmp
     39 echo "✓ data/tmp directory ready"
     40 
     41 # Set up the data repo (todo list + conversation history)
     42 DATA_REPO="$REPO_ROOT/data/repo"
     43 if [ ! -d "$DATA_REPO/.git" ]; then
     44   echo "Initializing data repo..."
     45   mkdir -p "$DATA_REPO/conversations" "$DATA_REPO/archive"
     46   git -C "$DATA_REPO" init
     47   git -C "$DATA_REPO" remote add origin git@michaelpercival.com:/var/www/gitcom/todo-list.git
     48   TODAY=$(date +%Y-%m-%d)
     49   printf "# Todo — %snn## Tasksnn## Donen" "$TODAY" > "$DATA_REPO/today.md"
     50   printf "## Urgentnn## Somedayn" > "$DATA_REPO/backlog.md"
     51   git -C "$DATA_REPO" add .
     52   git -C "$DATA_REPO" commit -m "Initialize todo list repo"
     53   git -C "$DATA_REPO" push -u origin master || echo "  WARNING: push failed — check remote access"
     54   echo "✓ Data repo initialized"
     55 else
     56   echo "✓ Data repo already initialized"
     57 fi
     58 
     59 # Check Python + faster-whisper for voice transcription
     60 if ! command -v python3 &>/dev/null; then
     61   echo "WARNING: python3 not found — voice messages will not be transcribed."
     62   echo "  Install Python 3 and run: pip install faster-whisper"
     63 elif ! python3 -c "import faster_whisper" &>/dev/null; then
     64   echo "WARNING: faster-whisper not installed — voice messages will not be transcribed."
     65   echo "  Run: pip install faster-whisper"
     66 else
     67   echo "✓ faster-whisper available"
     68 fi
     69 
     70 # Check SSH key for git push
     71 if ! ssh-add -l &>/dev/null && [ -z "$SSH_AUTH_SOCK" ]; then
     72   echo ""
     73   echo "WARNING: No SSH agent detected. Git push may fail."
     74   echo "Run: eval $(ssh-agent -s) && ssh-add ~/.ssh/id_ed25519"
     75 fi
     76 
     77 # Check git remote
     78 REMOTE=$(git remote get-url origin 2>/dev/null || echo "")
     79 if [ -z "$REMOTE" ]; then
     80   echo ""
     81   echo "WARNING: No git remote configured. Set one with:"
     82   echo "  git remote add origin git@github.com:you/life-todo.git"
     83 else
     84   echo "✓ Git remote: $REMOTE"
     85 fi
     86 
     87 # Check git user config
     88 GIT_NAME=$(git config user.name 2>/dev/null || echo "")
     89 GIT_EMAIL=$(git config user.email 2>/dev/null || echo "")
     90 if [ -z "$GIT_NAME" ] || [ -z "$GIT_EMAIL" ]; then
     91   echo ""
     92   echo "WARNING: Git user not configured. Set with:"
     93   echo "  git config user.name 'Your Name'"
     94   echo "  git config user.email 'you@example.com'"
     95 else
     96   echo "✓ Git user: $GIT_NAME <$GIT_EMAIL>"
     97 fi
     98 
     99 echo ""
    100 echo "=== Setup complete ==="
    101 echo ""
    102 echo "Next steps:"
    103 echo "  1. Fill in .env with your TELEGRAM_BOT_TOKEN, ANTHROPIC_API_KEY, and ALLOWED_USER_IDS"
    104 echo "  2. Get your Telegram user ID by messaging @userinfobot on Telegram"
    105 echo "  3. Run: npm start"
    106 echo ""
    107 echo "To run persistently with pm2:"
    108 echo "  npm install -g pm2"
    109 echo "  pm2 start src/index.js --name life-todo"
    110 echo "  pm2 save && pm2 startup"