SPB Git

Repository Public

node-setup.sh 3.3 KB 69 lines shellscript

1#!/bin/zsh2# =============================================================================3#                  SP BOUCHER | INFRASTRUCTURE & AUTOMATION4#             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5# =============================================================================6#7# Project          : MacLustr Identity8# File             : scripts/node-setup.sh9# Module           : scripts10# Repository       : https://git.spboucher.ai/maclustr-identity11# Project Website  : https://identity.spboucher.ai12# Created          : 2026-12-0113# Last Modified    : 2026-12-0114#15# Author           : Simon-Pierre Boucher16# Position         : Professor of Finance17# Institution      : Université du Québec en Outaouais (UQO)18# Organization     : SP Boucher19# Website          : https://spboucher.ai20# Git              : https://git.spboucher.ai21#22# Preferred Contact: admin@spboucher.ai23# Technical Contact: dev@spboucher.ai24# Security/Admin   : admin@spboucher.ai25#26# Copyright (c) 202627# Simon-Pierre Boucher28# All rights reserved where applicable. This file is governed by the29# applicable project license, copyright notices and relevant law.30# Existing third-party rights and notices remain unaffected.31#32# License          : None specified (no license file in this repository)33#34# Do not embed credentials, private keys, access tokens,35# certificates or confidential personal information.36#37# =============================================================================38# END OF SP BOUCHER SOURCE HEADER39# =============================================================================4041# Préparation idempotente du nœud : base, clé maîtresse, environnement Python, modèles, jeton du worker local. N'écrase rien d'existant.42set -euo pipefail43export PATH="/opt/homebrew/bin:/opt/homebrew/opt/postgresql@17/bin:$HOME/.local/bin:$PATH"44cd "$(dirname "$0")/.."45DB="${MLID_DB:-maclustr_identity}"46CONF="$HOME/.config/maclustr-identity"47DATA="$HOME/maclustr-identity-data"48mkdir -p "$CONF" "$DATA" "$HOME/backups/maclustr-identity"49chmod 700 "$CONF" "$DATA" "$HOME/backups/maclustr-identity"50psql -d postgres -tAc "select 1 from pg_database where datname='$DB'" | grep -q 1 || createdb "$DB"51umask 07752if [ ! -f "$CONF/master.key" ]; then53  head -c 32 /dev/urandom > "$CONF/master.key"54  echo "  clé maîtresse créée : $CONF/master.key (sans elle, pièces et secrets de webhooks sont illisibles : en garder une copie hors du nœud)"55fi56[ -f "$CONF/backup.key" ] || { openssl rand -base64 48 > "$CONF/backup.key"; echo "  clé de sauvegarde créée : $CONF/backup.key"; }57umask 02258[ -x .venv/bin/python ] || uv venv --python 3.12 .venv -q59uv pip install -q --python .venv/bin/python -r requirements.lock60zsh scripts/fetch-models.sh61export DATABASE_URL="postgres://127.0.0.1/$DB" MLID_ENV=production MLID_MASTER_KEY_FILE="$CONF/master.key" MLID_DATA_DIR="$DATA"62.venv/bin/python -m services.mlid.cli migrate63MLID_PKI_DIR="$CONF/pki" .venv/bin/python -m services.mlid.cli pki-init >/dev/null      # autorité privée + certificat du serveur interne (TLS mutuel des workers distants)64if [ ! -f "$CONF/worker.token" ]; then65  (umask 077; .venv/bin/python -m services.mlid.cli worker-register "$(hostname -s)" > "$CONF/worker.token")66  echo "  worker local enregistré"67fi68echo "  nœud prêt (base $DB, config $CONF, données $DATA)"69
Files main
Menu

Theme