SPB Git forge
0commits 0branches 0releases
0 Bsize
maindefault branch
—last push
2.1 KB · 40 lines shellscript
Raw Blame History
1#!/bin/bash2# Déploie maclustr-agentd sur le nœud hôte (AGENT_HOST) :3#  - clé SSH dédiée id_ed25519_agentd (générée si absente) autorisée sur tous les nœuds4#  - marqueurs ~/.maclustr-node partout5#  - agent + config + lanmap + launchd6set -euo pipefail7DIR="$(cd "$(dirname "$0")" && pwd)"8AGENT_HOST="${AGENT_HOST:-M4M64a}"9ALL_NODES="M3U96a M3U96b M2U64 M4M64a M4M64b M4BP48 M4BP36 M4M36 M2M32 M2M32b M2M32c m4mc M1M32 m4ma m4mb m2m16 M3BA24 M3BA16 m2m8a m2m8b"1011echo ">> clé dédiée sur $AGENT_HOST"12ssh "$AGENT_HOST" '[ -f ~/.ssh/id_ed25519_agentd ] || ssh-keygen -t ed25519 -N "" -C "maclustr-agentd" -f ~/.ssh/id_ed25519_agentd -q'13PUB=$(ssh "$AGENT_HOST" 'cat ~/.ssh/id_ed25519_agentd.pub')1415echo ">> autorisation de la clé + marqueur sur chaque nœud"16for n in $ALL_NODES; do17  (ssh -o ConnectTimeout=6 "$n" "mkdir -p ~/.ssh && chmod 700 ~/.ssh18     grep -qF '$PUB' ~/.ssh/authorized_keys 2>/dev/null || echo '$PUB' >> ~/.ssh/authorized_keys19     chmod 600 ~/.ssh/authorized_keys20     echo $n > ~/.maclustr-node" 2>/dev/null \21     && echo "  $n ok" || echo "  $n INJOIGNABLE") &22done23wait2425echo ">> agent -> $AGENT_HOST:~/maclustr-agentd/"26ssh "$AGENT_HOST" "mkdir -p ~/maclustr-agentd"27scp -q "$DIR/agentd.py" "$DIR/config.json" M4M64a:~/maclustr-agentd/ 2>/dev/null || scp -q "$DIR/agentd.py" "$DIR/config.json" "$AGENT_HOST":~/maclustr-agentd/28[ -f "$DIR/lanmap.json" ] && scp -q "$DIR/lanmap.json" "$AGENT_HOST":~/maclustr-agentd/29scp -q "$DIR/io.maclustr.agentd.plist" "$AGENT_HOST":/tmp/io.maclustr.agentd.plist30ssh "$AGENT_HOST" 'chmod 600 ~/maclustr-agentd/config.json31  PY=$(command -v /opt/homebrew/bin/python3 || command -v /usr/bin/python3)32  /usr/bin/sed -i "" "s|/opt/homebrew/bin/python3|$PY|" /tmp/io.maclustr.agentd.plist33  mkdir -p ~/Library/LaunchAgents34  cp /tmp/io.maclustr.agentd.plist ~/Library/LaunchAgents/35  launchctl bootout gui/$(id -u)/io.maclustr.agentd 2>/dev/null || true36  launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/io.maclustr.agentd.plist37  sleep 238  launchctl print gui/$(id -u)/io.maclustr.agentd | grep -E "state|pid" | head -3'39echo ">> déployé sur $AGENT_HOST."40