Repository Public
1#!/bin/zsh2# =============================================================================3# SP BOUCHER | INFRASTRUCTURE & AUTOMATION4# ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5# =============================================================================6#7# Project : MacLustr SMS Gateway8# File : scripts/node-setup.sh9# Module : scripts10# Repository : https://git.spboucher.ai/maclustr-sms11# Project Website : https://sms.spboucher.ai12# Created : 2026-11-3013# Last Modified : 2026-11-3014#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 d'hébergement : base, clés, dossiers. N'écrase jamais rien d'existant.42set -euo pipefail43export PATH="/opt/homebrew/bin:/opt/homebrew/opt/postgresql@17/bin:$PATH"44DB=maclustr_sms45CONF="$HOME/.config/maclustr-sms"46REL="$HOME/maclustr-sms-data/releases"47mkdir -p "$CONF" "$REL" "$HOME/backups/maclustr-sms" "$HOME/.pm2/logs"48chmod 700 "$CONF" "$HOME/backups/maclustr-sms"49psql -d postgres -tAc "select 1 from pg_database where datname='$DB'" | grep -q 1 || createdb "$DB"50umask 07751if [ ! -f "$CONF/data.key" ]; then52 openssl rand -base64 32 > "$CONF/data.key"53 echo " clé de données créée : $CONF/data.key (SANS ELLE, les SMS et secrets stockés sont illisibles : en garder une copie hors du nœud)"54fi55if [ ! -f "$CONF/backup.key" ]; then56 openssl rand -base64 48 > "$CONF/backup.key"57 echo " clé de sauvegarde créée : $CONF/backup.key (en garder une copie hors du nœud)"58fi59# Le manifeste de version suit le dépôt ; l'APK (hors git) est déposé à côté par scripts/publish-apk.sh.60cp -f releases/android-release.json "$REL/android-release.json"61echo " nœud prêt (base $DB, config $CONF, versions $REL)"62