SPB Git forge

spb/trouve-ka

Public ★ Pinned

Trouve-KA — moteur de recherche web indépendant, Québec-first. Crawler distribué, index OpenSearch, ranking bilingue, galerie d'images. En prod : www.trouve-ka.com

40commits 1branches 0releases
9.2 MBsize
maindefault branch
23 days agolast push
Python 51.9% TypeScript 32.7% JavaScript 4.8% CSS 4.1% Shell 2.9% HTML 1.8% SQL 1.5%
2.5 KB · 58 lines shellscript
Raw Blame History
1#!/bin/sh2# Trouve-KA — installation de la robustesse sur un node (rôle + LaunchDaemons)3# Author: Simon-Pierre Boucher4# Contact: contact@spboucher.ai5#6# Usage : SUDO_PW=... sh install-node.sh <hub|search|embed|crawler>7# Idempotent. Installe :8#   - ~/.trouveka-role9#   - io.trouveka.boot     (RunAtLoad : boot.sh au démarrage du node)10#   - hub    : + io.trouveka.watchdog (2 min) + backup-pg (03:30) + pull (04:40)11#   - search : + backup-os (04:00) + pull (04:30)1213set -eu14ROLE="${1:?role requis: hub|search|embed|crawler}"15USER_NAME=$(whoami)16HOME_DIR="$HOME"17OPS="$HOME_DIR/trouve-ka/scripts/ops"1819echo "$ROLE" > "$HOME_DIR/.trouveka-role"2021sudo_cmd() { echo "${SUDO_PW:?SUDO_PW requis}" | sudo -S "$@" 2>/dev/null; }2223install_daemon() { # $1=label $2=program-args-xml $3=extra-xml24  PLIST="/tmp/io.trouveka.$1.plist"25  cat > "$PLIST" <<EOF26<?xml version="1.0" encoding="UTF-8"?>27<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">28<plist version="1.0"><dict>29  <key>Label</key><string>io.trouveka.$1</string>30  <key>ProgramArguments</key><array><string>/bin/sh</string><string>$2</string></array>31  <key>UserName</key><string>$USER_NAME</string>32  <key>StandardErrorPath</key><string>$HOME_DIR/trouveka-launchd.log</string>33  <key>StandardOutPath</key><string>$HOME_DIR/trouveka-launchd.log</string>34  $335</dict></plist>36EOF37  sudo_cmd cp "$PLIST" "/Library/LaunchDaemons/io.trouveka.$1.plist"38  sudo_cmd launchctl bootout "system/io.trouveka.$1" 2>/dev/null || true39  sudo_cmd launchctl bootstrap system "/Library/LaunchDaemons/io.trouveka.$1.plist"40  echo "✓ daemon io.trouveka.$1"41}4243install_daemon boot "$OPS/boot.sh" "<key>RunAtLoad</key><true/>"4445case "$ROLE" in46  hub)47    install_daemon watchdog "$OPS/watchdog.sh" "<key>StartInterval</key><integer>120</integer>"48    install_daemon backup-pg "$OPS/backup-pg.sh" "<key>StartCalendarInterval</key><dict><key>Hour</key><integer>3</integer><key>Minute</key><integer>30</integer></dict>"49    install_daemon pull "$OPS/pull-backups.sh" "<key>StartCalendarInterval</key><dict><key>Hour</key><integer>4</integer><key>Minute</key><integer>40</integer></dict>"50    ;;51  search)52    install_daemon backup-os "$OPS/backup-os.sh" "<key>StartCalendarInterval</key><dict><key>Hour</key><integer>4</integer><key>Minute</key><integer>0</integer></dict>"53    install_daemon pull "$OPS/pull-backups.sh" "<key>StartCalendarInterval</key><dict><key>Hour</key><integer>4</integer><key>Minute</key><integer>30</integer></dict>"54    ;;55esac5657echo "✓ node installé (rôle: $ROLE)"58