feat(nginx): reverse-proxy services via hostnames + logs for Grafana; feat(monitoring): serve Grafana under /grafana subpath
This commit is contained in:
parent
92e702193c
commit
a3d3209b36
@ -39,6 +39,8 @@ services:
|
|||||||
environment:
|
environment:
|
||||||
- GF_SECURITY_ADMIN_PASSWORD=admin
|
- GF_SECURITY_ADMIN_PASSWORD=admin
|
||||||
- GF_USERS_ALLOW_SIGN_UP=false
|
- GF_USERS_ALLOW_SIGN_UP=false
|
||||||
|
- GF_SERVER_ROOT_URL=%(protocol)s://%(domain)s/grafana
|
||||||
|
- GF_SERVER_SERVE_FROM_SUB_PATH=true
|
||||||
volumes:
|
volumes:
|
||||||
- grafana_data:/var/lib/grafana
|
- grafana_data:/var/lib/grafana
|
||||||
- ./log/grafana-datasources.yml:/etc/grafana/provisioning/datasources/datasources.yml:ro
|
- ./log/grafana-datasources.yml:/etc/grafana/provisioning/datasources/datasources.yml:ro
|
||||||
|
@ -1,59 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
BTC_CONTAINER="4nk-bitcoin"
|
|
||||||
RELAY_CONTAINERS=("4nk-sdk-relay1" "4nk-sdk-relay2" "4nk-sdk-relay3")
|
|
||||||
STORAGE_CONTAINER="4nk-sdk-storage"
|
|
||||||
SIGNER_CONTAINER="4nk-sdk-signer"
|
|
||||||
IHMSERVER_CONTAINER="4nk-node-ihm-client"
|
|
||||||
TOR_CONTAINER="4nk-node-tor"
|
|
||||||
NGINX_CONTAINER="4nk-nginx" # si présent
|
|
||||||
|
|
||||||
# Attendre la fin de l'IBD du Bitcoin Core
|
|
||||||
echo "Relancer les healthchecks après l'IBD terminé..."
|
|
||||||
while true; do
|
|
||||||
if docker ps -q -f name="^${BTC_CONTAINER}$" >/dev/null 2>&1; then
|
|
||||||
INFO=$(docker exec "$BTC_CONTAINER" bitcoin-cli -signet getblockchaininfo 2>/dev/null || true)
|
|
||||||
if echo "$INFO" | grep -q '"initialblockdownload":false'; then
|
|
||||||
echo "IBD terminé sur $BTC_CONTAINER"
|
|
||||||
break
|
|
||||||
else
|
|
||||||
echo "IBD en cours sur $BTC_CONTAINER...";
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "Bitcoin container non trouvé, tentative de reprise..."
|
|
||||||
fi
|
|
||||||
sleep 60
|
|
||||||
done
|
|
||||||
|
|
||||||
# Redémarrer les conteneurs critiques pour relancer les healthchecks
|
|
||||||
RESTART_LIST=("$BTC_CONTAINER" "${RELAY_CONTAINERS[@]}" "$STORAGE_CONTAINER" "$SIGNER_CONTAINER" "$IHMSERVER_CONTAINER" "$TOR_CONTAINER")
|
|
||||||
for c in "${RESTART_LIST[@]}"; do
|
|
||||||
if docker ps -a | awk '{print $NF}' | tail -n +2 | grep -qx "$c"; then
|
|
||||||
echo "Redémarrage de $c ..."
|
|
||||||
docker restart "$c" >/dev/null 2>&1 || true
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# Vérification rapide des conteneurs
|
|
||||||
echo "État des conteneurs après redémarrage:"
|
|
||||||
docker ps -a
|
|
||||||
|
|
||||||
# Vérifier des endpoints simples si accessibles
|
|
||||||
echo "Vérification rapide des endpoints (si disponibles) :"
|
|
||||||
ENDPOINTS=(
|
|
||||||
"http://localhost:8081/" # storage
|
|
||||||
"http://localhost:8000/" # blindbit
|
|
||||||
"http://localhost:9090/" # signer
|
|
||||||
"http://localhost:3003/" # ihm web
|
|
||||||
"http://localhost:8091/" # relay1
|
|
||||||
"http://localhost:8093/" # relay2
|
|
||||||
"http://localhost:8095/" # relay3
|
|
||||||
)
|
|
||||||
for url in "${ENDPOINTS[@]}"; do
|
|
||||||
if curl -sS --max-time 5 "$url" >/dev/null 2>&1; then
|
|
||||||
echo "OK: $url reachable"
|
|
||||||
else
|
|
||||||
echo "WARN: $url not reachable"
|
|
||||||
fi
|
|
||||||
done
|
|
@ -1,61 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
echo "[Grafana setup] starting local Grafana and Loki/Promtail integration"
|
|
||||||
|
|
||||||
# Install Grafana if not present
|
|
||||||
if ! command -v grafana-server >/dev/null 2>&1; then
|
|
||||||
echo "Grafana not found. Please install Grafana manually or enable the apt repository and run this script again."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Grafana is installed. Ensuring service is running..."
|
|
||||||
sudo systemctl enable grafana-server
|
|
||||||
sudo systemctl start grafana-server || true
|
|
||||||
|
|
||||||
echo "Grafana service status:"
|
|
||||||
sudo systemctl is-active grafana-server || true
|
|
||||||
|
|
||||||
# Try to install Loki/Promtail if helper script exists
|
|
||||||
HELPER="/home/debian/code/4NK_dev/4NK_node/scripts/install_loki_promtail_local.sh"
|
|
||||||
if [ -x "$HELPER" ]; then
|
|
||||||
echo "Running Loki/Promtail installer..."
|
|
||||||
bash "$HELPER"
|
|
||||||
else
|
|
||||||
echo "No Loki/Promtail installer found at $HELPER; skipping."
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "[Grafana setup] completed."
|
|
||||||
#!/usr/bin/env bash
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
echo "[ Grafana setup ]: starting local Grafana installation and Loki/Promtail integration"
|
|
||||||
|
|
||||||
# Install Grafana if not present
|
|
||||||
if ! command -v grafana-server >/dev/null 2>&1; then
|
|
||||||
echo "Installing Grafana..."
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y software-properties-common wget apt-transport-https
|
|
||||||
wget -q -O - https://packages.grafana.com/grafana.key | sudo apt-key add -
|
|
||||||
echo "deb https://packages.grafana.com/oss/deb stable main" | sudo tee /etc/apt/sources.list.d/grafana.list
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y grafana
|
|
||||||
sudo systemctl enable grafana-server
|
|
||||||
sudo systemctl start grafana-server
|
|
||||||
else
|
|
||||||
echo "Grafana is already installed."
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "[ Grafana setup ]: Grafana service status ready."
|
|
||||||
|
|
||||||
# Try to install Loki/Promtail using existing helper script if present
|
|
||||||
if [ -x "/home/debian/code/4NK_dev/4NK_node/scripts/install_loki_promtail_local.sh" ]; then
|
|
||||||
echo "Running Loki/Promtail installer..."
|
|
||||||
bash /home/debian/code/4NK_dev/4NK_node/scripts/install_loki_promtail_local.sh
|
|
||||||
else
|
|
||||||
echo "Loki/Promtail installer script not found; skipping. Please install Loki/Promtail manually if needed."
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "[ Grafana setup ]: completed."
|
|
||||||
|
|
||||||
|
|
@ -1,109 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
# Version et URLs
|
|
||||||
LOKI_VER="2.9.0"
|
|
||||||
PROMTAIL_VER="2.9.0"
|
|
||||||
LOKI_URL="https://github.com/grafana/loki/releases/download/v${LOKI_VER}/loki-linux-amd64.zip"
|
|
||||||
PROMTAIL_URL="https://github.com/grafana/loki/releases/download/v${PROMTAIL_VER}/promtail-linux-amd64.zip"
|
|
||||||
|
|
||||||
# Détection Distro et dépendances
|
|
||||||
if [ -f /etc/os-release ]; then
|
|
||||||
. /etc/os-release
|
|
||||||
fi
|
|
||||||
OS_ID=${ID:-debian}
|
|
||||||
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y curl unzip
|
|
||||||
|
|
||||||
# Installer Loki
|
|
||||||
sudo mkdir -p /usr/local/bin /etc/loki /var/lib/loki
|
|
||||||
sudo curl -L -o /tmp/loki-linux-amd64.zip "$LOKI_URL"
|
|
||||||
sudo unzip -o /tmp/loki-linux-amd64.zip -d /usr/local/bin
|
|
||||||
sudo bash -lc 'cat > /etc/systemd/system/loki.service <<EOF
|
|
||||||
[Unit]
|
|
||||||
Description=Loki service
|
|
||||||
After=network-online.target
|
|
||||||
Wants=network-online.target
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
ExecStart=/usr/local/bin/loki-linux-amd64 -config.file=/etc/loki/local-config.yaml
|
|
||||||
Restart=always
|
|
||||||
User=root
|
|
||||||
Group=root
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
||||||
EOF'
|
|
||||||
|
|
||||||
sudo mkdir -p /etc/loki /var/lib/loki
|
|
||||||
sudo tee /etc/loki/local-config.yaml >/dev/null << 'EOF'
|
|
||||||
auth_enabled: false
|
|
||||||
server:
|
|
||||||
http_listen_port: 3100
|
|
||||||
grpc_listen_port: 9095
|
|
||||||
ingester:
|
|
||||||
wal:
|
|
||||||
enabled: true
|
|
||||||
storage_config:
|
|
||||||
boltdb:
|
|
||||||
directory: /var/lib/loki/chunks
|
|
||||||
limits_config:
|
|
||||||
enforce_metric_name: false
|
|
||||||
EOF
|
|
||||||
|
|
||||||
sudo systemctl daemon-reload
|
|
||||||
sudo systemctl enable loki
|
|
||||||
sudo systemctl start loki
|
|
||||||
|
|
||||||
# Installer Promtail
|
|
||||||
sudo mkdir -p /usr/local/bin /etc/promtail /var/log/promtail
|
|
||||||
sudo curl -L -o /tmp/promtail-linux-amd64.zip "$PROMTAIL_URL"
|
|
||||||
sudo unzip -o /tmp/promtail-linux-amd64.zip -d /usr/local/bin
|
|
||||||
sudo bash -lc 'cat > /etc/systemd/system/promtail.service <<EOF
|
|
||||||
[Unit]
|
|
||||||
Description=Promtail service
|
|
||||||
After=network-online.target
|
|
||||||
Wants=network-online.target
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
ExecStart=/usr/local/bin/promtail-linux-amd64 -config.file=/etc/promtail/promtail.yaml
|
|
||||||
Restart=on-failure
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
||||||
EOF'
|
|
||||||
|
|
||||||
sudo mkdir -p /etc/promtail
|
|
||||||
sudo tee /etc/promtail/promtail.yaml >/dev/null << 'EOF'
|
|
||||||
server:
|
|
||||||
http_listen_port: 9080
|
|
||||||
positions:
|
|
||||||
filename: /var/log/promtail/positions.yaml
|
|
||||||
clients:
|
|
||||||
- url: http://localhost:3100/loki/api/v1/push
|
|
||||||
scrape_configs:
|
|
||||||
- job: grafana-logs
|
|
||||||
static_configs:
|
|
||||||
- targets: [localhost]
|
|
||||||
labels:
|
|
||||||
__path__: /home/debian/code/logs/*.log
|
|
||||||
job: logs
|
|
||||||
- job: coffre-logs
|
|
||||||
static_configs:
|
|
||||||
- targets: [localhost]
|
|
||||||
labels:
|
|
||||||
__path__: /home/debian/code/4NK_dev/4NK_node/log/*.log
|
|
||||||
job: coffre_logs
|
|
||||||
EOF
|
|
||||||
|
|
||||||
sudo systemctl daemon-reload
|
|
||||||
sudo systemctl enable promtail
|
|
||||||
sudo systemctl start promtail
|
|
||||||
|
|
||||||
# Vérifications simples
|
|
||||||
echo
|
|
||||||
echo "Grafana Loki Promtail local install terminé. Vérifications:"
|
|
||||||
echo " - Grafana: http://localhost:3000"
|
|
||||||
echo " - Loki: http://localhost:3100"
|
|
||||||
echo " - Promtail: service actif (Promtail)"
|
|
@ -1,177 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Script de gestion de l'authentification et des fichiers partagés
|
|
||||||
# pour la stack 4NK_node
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
||||||
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
|
|
||||||
|
|
||||||
echo "🔐 Gestion de l'authentification et des fichiers partagés 4NK_node"
|
|
||||||
|
|
||||||
# Fonction pour vérifier si un conteneur est en cours d'exécution
|
|
||||||
container_running() {
|
|
||||||
docker ps --format "table {{.Names}}" | grep -q "$1"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Fonction pour attendre qu'un conteneur soit prêt
|
|
||||||
wait_for_container() {
|
|
||||||
local container_name="$1"
|
|
||||||
local max_wait=60
|
|
||||||
local wait_time=0
|
|
||||||
|
|
||||||
echo "⏳ Attente que le conteneur $container_name soit prêt..."
|
|
||||||
|
|
||||||
while [ $wait_time -lt $max_wait ]; do
|
|
||||||
if container_running "$container_name"; then
|
|
||||||
echo "✅ Conteneur $container_name est prêt"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
sleep 2
|
|
||||||
wait_time=$((wait_time + 2))
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "❌ Timeout en attendant le conteneur $container_name"
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
# Fonction pour vérifier et créer le fichier .cookie
|
|
||||||
setup_bitcoin_cookie() {
|
|
||||||
echo "🔍 Configuration du fichier .cookie Bitcoin..."
|
|
||||||
|
|
||||||
if ! container_running "4nk-bitcoin"; then
|
|
||||||
echo "❌ Le conteneur Bitcoin n'est pas en cours d'exécution"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Attendre que Bitcoin soit complètement démarré
|
|
||||||
wait_for_container "4nk-bitcoin"
|
|
||||||
sleep 10
|
|
||||||
|
|
||||||
# Vérifier si le fichier .cookie existe
|
|
||||||
if docker exec 4nk-bitcoin test -f /home/bitcoin/.bitcoin/signet/.cookie; then
|
|
||||||
echo "✅ Fichier .cookie Bitcoin trouvé"
|
|
||||||
|
|
||||||
# Afficher les informations du cookie
|
|
||||||
echo "📋 Informations du fichier .cookie :"
|
|
||||||
docker exec 4nk-bitcoin ls -la /home/bitcoin/.bitcoin/signet/.cookie
|
|
||||||
docker exec 4nk-bitcoin cat /home/bitcoin/.bitcoin/signet/.cookie | head -1
|
|
||||||
|
|
||||||
# Vérifier les permissions
|
|
||||||
local perms=$(docker exec 4nk-bitcoin stat -c "%a" /home/bitcoin/.bitcoin/signet/.cookie)
|
|
||||||
echo "🔐 Permissions du fichier .cookie : $perms"
|
|
||||||
|
|
||||||
# S'assurer que les permissions sont correctes (600)
|
|
||||||
if [ "$perms" != "600" ]; then
|
|
||||||
echo "🔧 Correction des permissions du fichier .cookie..."
|
|
||||||
docker exec 4nk-bitcoin chmod 600 /home/bitcoin/.bitcoin/signet/.cookie
|
|
||||||
fi
|
|
||||||
|
|
||||||
return 0
|
|
||||||
else
|
|
||||||
echo "❌ Fichier .cookie Bitcoin non trouvé"
|
|
||||||
echo "📋 Logs Bitcoin récents :"
|
|
||||||
docker logs 4nk-bitcoin --tail 10
|
|
||||||
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Fonction pour vérifier l'accès au fichier .cookie depuis d'autres services
|
|
||||||
verify_cookie_access() {
|
|
||||||
echo "🔍 Vérification de l'accès au fichier .cookie depuis d'autres services..."
|
|
||||||
|
|
||||||
local services=("4nk-blindbit" "4nk-sdk-relay1" "4nk-sdk-relay2" "4nk-sdk-relay3" "4nk-sdk-storage" "4nk-sdk-signer")
|
|
||||||
|
|
||||||
for service in "${services[@]}"; do
|
|
||||||
if container_running "$service"; then
|
|
||||||
echo "🔍 Vérification de $service..."
|
|
||||||
|
|
||||||
if docker exec "$service" test -f /home/bitcoin/.bitcoin/signet/.cookie; then
|
|
||||||
echo "✅ $service peut accéder au fichier .cookie"
|
|
||||||
|
|
||||||
# Vérifier les permissions
|
|
||||||
local perms=$(docker exec "$service" stat -c "%a" /home/bitcoin/.bitcoin/signet/.cookie)
|
|
||||||
echo " Permissions : $perms"
|
|
||||||
|
|
||||||
# Vérifier la lisibilité
|
|
||||||
if docker exec "$service" test -r /home/bitcoin/.bitcoin/signet/.cookie; then
|
|
||||||
echo " ✅ Fichier lisible"
|
|
||||||
else
|
|
||||||
echo " ❌ Fichier non lisible"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "❌ $service ne peut pas accéder au fichier .cookie"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "⏸️ $service n'est pas en cours d'exécution"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
# Fonction pour tester la connectivité RPC
|
|
||||||
test_rpc_connectivity() {
|
|
||||||
echo "🔍 Test de la connectivité RPC..."
|
|
||||||
|
|
||||||
if ! container_running "4nk-bitcoin"; then
|
|
||||||
echo "❌ Bitcoin n'est pas en cours d'exécution"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Attendre que Bitcoin soit prêt
|
|
||||||
sleep 5
|
|
||||||
|
|
||||||
# Test de la connectivité RPC via curl
|
|
||||||
echo "📡 Test de la connectivité RPC via HTTP..."
|
|
||||||
if docker exec 4nk-bitcoin curl -s --connect-timeout 5 http://localhost:18443 > /dev/null 2>&1; then
|
|
||||||
echo "✅ Connectivité RPC HTTP OK"
|
|
||||||
return 0
|
|
||||||
else
|
|
||||||
echo "❌ Connectivité RPC HTTP échouée"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Fonction pour afficher le statut des volumes partagés
|
|
||||||
show_shared_volumes() {
|
|
||||||
echo "🔍 Statut des volumes partagés..."
|
|
||||||
|
|
||||||
echo "📊 Volumes Docker :"
|
|
||||||
docker volume ls | grep 4nk_node || echo "Aucun volume 4nk_node trouvé"
|
|
||||||
|
|
||||||
echo "📊 Volumes partagés dans docker-compose :"
|
|
||||||
if [ -f "$PROJECT_DIR/docker-compose.yml" ]; then
|
|
||||||
grep -A 5 -B 5 "shared_auth" "$PROJECT_DIR/docker-compose.yml" || echo "Volume shared_auth non trouvé"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Fonction principale
|
|
||||||
main() {
|
|
||||||
case "${1:-all}" in
|
|
||||||
"cookie")
|
|
||||||
setup_bitcoin_cookie
|
|
||||||
;;
|
|
||||||
"access")
|
|
||||||
verify_cookie_access
|
|
||||||
;;
|
|
||||||
"rpc")
|
|
||||||
test_rpc_connectivity
|
|
||||||
;;
|
|
||||||
"volumes")
|
|
||||||
show_shared_volumes
|
|
||||||
;;
|
|
||||||
"all"|*)
|
|
||||||
echo "🚀 Exécution de toutes les vérifications..."
|
|
||||||
setup_bitcoin_cookie
|
|
||||||
verify_cookie_access
|
|
||||||
test_rpc_connectivity
|
|
||||||
show_shared_volumes
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
echo "✅ Gestion de l'authentification terminée"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Exécution du script
|
|
||||||
main "$@"
|
|
@ -1 +0,0 @@
|
|||||||
#!/bin/bash
|
|
@ -1,99 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
echo "🔍 Surveillance de la synchronisation entre 3 relais"
|
|
||||||
echo "=================================================="
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
# Fonction pour vérifier si Bitcoin Core a terminé l'IBD
|
|
||||||
check_bitcoin_ready() {
|
|
||||||
local bitcoin_status=$(docker exec bitcoin-signet bitcoin-cli -signet getblockchaininfo 2>/dev/null | grep -o '"initialblockdownload":false' || echo "still_downloading")
|
|
||||||
if [[ "$bitcoin_status" == "still_downloading" ]]; then
|
|
||||||
return 1
|
|
||||||
else
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Fonction pour afficher les logs de synchronisation
|
|
||||||
show_sync_logs() {
|
|
||||||
echo "📡 Logs de synchronisation des relais :"
|
|
||||||
echo "----------------------------------------"
|
|
||||||
|
|
||||||
for i in {1..3}; do
|
|
||||||
echo "🔸 Relais $i :"
|
|
||||||
docker logs sdk_relay_$i 2>&1 | grep -E "(🧪|📊|🏥|📈|🔄|🎉|❌|Relay|Sync|Mesh|Topology|🔍|✅|discover|relay)" | tail -3 || echo " Aucun message de synchronisation trouvé"
|
|
||||||
echo ""
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
# Fonction pour vérifier la connectivité entre relais
|
|
||||||
check_relay_connectivity() {
|
|
||||||
echo "🌐 Vérification de la connectivité entre relais :"
|
|
||||||
echo "------------------------------------------------"
|
|
||||||
|
|
||||||
for i in {1..3}; do
|
|
||||||
echo "🔸 Relais $i (port $((8090 + i - 1))) :"
|
|
||||||
if curl -s http://localhost:$((8090 + i - 1)) >/dev/null 2>&1; then
|
|
||||||
echo " ✅ Port WebSocket accessible"
|
|
||||||
else
|
|
||||||
echo " ❌ Port WebSocket non accessible"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
echo ""
|
|
||||||
}
|
|
||||||
|
|
||||||
# Fonction pour afficher les métriques de synchronisation
|
|
||||||
show_sync_metrics() {
|
|
||||||
echo "📊 Métriques de synchronisation :"
|
|
||||||
echo "--------------------------------"
|
|
||||||
|
|
||||||
for i in {1..3}; do
|
|
||||||
echo "🔸 Relais $i :"
|
|
||||||
docker logs sdk_relay_$i 2>&1 | grep -E "(SyncMetrics|known_relays|mesh_connections|sync_cache)" | tail -2 || echo " Aucune métrique trouvée"
|
|
||||||
echo ""
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
# Attendre que Bitcoin Core soit prêt
|
|
||||||
echo "⏳ Attente que Bitcoin Core termine le téléchargement initial..."
|
|
||||||
while ! check_bitcoin_ready; do
|
|
||||||
echo " Bitcoin Core télécharge encore les blocs..."
|
|
||||||
sleep 30
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "✅ Bitcoin Core est prêt !"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
# Attendre un peu pour que les relais se stabilisent
|
|
||||||
echo "⏳ Attente de stabilisation des relais..."
|
|
||||||
sleep 10
|
|
||||||
|
|
||||||
# Boucle de surveillance
|
|
||||||
echo "🚀 Démarrage de la surveillance de synchronisation..."
|
|
||||||
echo "Appuyez sur Ctrl+C pour arrêter"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
clear
|
|
||||||
echo "🔍 Surveillance de la synchronisation entre 3 relais"
|
|
||||||
echo "=================================================="
|
|
||||||
echo "⏰ $(date)"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
# Vérifier la connectivité
|
|
||||||
check_relay_connectivity
|
|
||||||
|
|
||||||
# Afficher les logs de synchronisation
|
|
||||||
show_sync_logs
|
|
||||||
|
|
||||||
# Afficher les métriques
|
|
||||||
show_sync_metrics
|
|
||||||
|
|
||||||
echo "🔄 Actualisation dans 30 secondes..."
|
|
||||||
sleep 30
|
|
||||||
done
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,69 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
BASE_DIR="/home/debian/code/4NK_dev/4NK_node"
|
|
||||||
cd "$BASE_DIR" || exit 1
|
|
||||||
|
|
||||||
echo "== Début de l’orchestration de démarrage des modules =="
|
|
||||||
|
|
||||||
SERVICES=(
|
|
||||||
tor
|
|
||||||
bitcoin
|
|
||||||
blindbit
|
|
||||||
sdk_storage
|
|
||||||
sdk_relay1
|
|
||||||
sdk_relay2
|
|
||||||
sdk_relay3
|
|
||||||
ihm_client
|
|
||||||
sdk_signer
|
|
||||||
coffre_back_mini
|
|
||||||
coffre_front
|
|
||||||
)
|
|
||||||
|
|
||||||
wait_for_service() {
|
|
||||||
local svc="$1"; local timeout=${2:-120}; local waited=0
|
|
||||||
while :; do
|
|
||||||
if docker compose ps "$svc" 2>/dev/null | grep -q "Up"; then
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
if [ "$waited" -ge "$timeout" ]; then
|
|
||||||
echo "[WARN] Service '$svc' n'est pas en état 'Up' après ${timeout}s" >&2
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
waited=$((waited+2))
|
|
||||||
sleep 2
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
for svc in "${SERVICES[@]}"; do
|
|
||||||
# Determine corresponding image to verify availability
|
|
||||||
case "$svc" in
|
|
||||||
tor) img="4nk-node-tor:docker-support-v2" ;;
|
|
||||||
bitcoin) img="4nk-node-bitcoin:docker-support-v2" ;;
|
|
||||||
blindbit) img="4nk-node-blindbit:docker-support-v2" ;;
|
|
||||||
sdk_storage) img="4nk-node-sdk_storage:docker-support-v2" ;;
|
|
||||||
sdk_relay1) img="4nk-node-sdk_relay1:docker-support-v2" ;;
|
|
||||||
sdk_relay2) img="4nk-node-sdk_relay2:docker-support-v2" ;;
|
|
||||||
sdk_relay3) img="4nk-node-sdk_relay3:docker-support-v2" ;;
|
|
||||||
ihm_client) img="4nk-node-ihm_client:docker-support-v2" ;;
|
|
||||||
sdk_signer) img="4nk-node-sdk_signer:docker-support-v2" ;;
|
|
||||||
coffre_back_mini) img="4nk-node-lecoffre-back-mini:latest" ;;
|
|
||||||
coffre_front) img="lecoffre-front:latest" ;;
|
|
||||||
miniback) img="4nk-node-miniback:latest" ;;
|
|
||||||
*) img="" ;;
|
|
||||||
esac
|
|
||||||
if [[ -n "$img" ]]; then
|
|
||||||
if ! docker image inspect "$img" >/dev/null 2>&1; then
|
|
||||||
echo "[WARN] Image '$img' for service '$svc' not found; skipping." >&2
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
echo "Starting service: $svc"
|
|
||||||
docker compose up -d "$svc"
|
|
||||||
wait_for_service "$svc" 180 || echo "Continuing malgré l'état potentiellement non Up pour $svc"
|
|
||||||
echo "Service $svc démarré (ou état final vérifié)."
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "== Ordre d’orchestration terminé =="
|
|
||||||
|
|
||||||
|
|
@ -1,522 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# =============================================================================
|
|
||||||
# Script de Redémarrage Complet 4NK Node
|
|
||||||
# =============================================================================
|
|
||||||
# Date: $(date)
|
|
||||||
# Motif: Redémarrage propre pour intégrer dev3.4nkweb.com
|
|
||||||
# =============================================================================
|
|
||||||
|
|
||||||
set -e # Arrêter en cas d'erreur
|
|
||||||
|
|
||||||
# =============================================================================
|
|
||||||
# CONFIGURATION
|
|
||||||
# =============================================================================
|
|
||||||
|
|
||||||
# Couleurs pour l'affichage
|
|
||||||
RED='\033[0;31m'
|
|
||||||
GREEN='\033[0;32m'
|
|
||||||
YELLOW='\033[1;33m'
|
|
||||||
BLUE='\033[0;34m'
|
|
||||||
PURPLE='\033[0;35m'
|
|
||||||
CYAN='\033[0;36m'
|
|
||||||
NC='\033[0m' # No Color
|
|
||||||
|
|
||||||
# Configuration du projet
|
|
||||||
PROJECT_NAME="4NK Node"
|
|
||||||
PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
||||||
SCRIPT_DIR="${PROJECT_DIR}"
|
|
||||||
CONFIG_FILE="$SCRIPT_DIR/conf/restart_config.conf"
|
|
||||||
if [ -f "$CONFIG_FILE" ]; then
|
|
||||||
# Import restart configuration from external file
|
|
||||||
# shellcheck disable=SC1091
|
|
||||||
# shellcheck source=/home/debian/code/4NK_dev/4NK_node/conf/restart_config.conf
|
|
||||||
source "$CONFIG_FILE"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Réseau Docker
|
|
||||||
NETWORK_NAME="4nk_network"
|
|
||||||
|
|
||||||
# Images Docker
|
|
||||||
TOR_IMAGE="4nk-node-tor:docker-support-v2"
|
|
||||||
BITCOIN_IMAGE="4nk-node-bitcoin:docker-support-v2"
|
|
||||||
BLINDBIT_IMAGE="4nk-node-blindbit:docker-support-v2"
|
|
||||||
RELAY_IMAGE="4nk-node-sdk_relay1:docker-support-v2"
|
|
||||||
|
|
||||||
# Volumes
|
|
||||||
BITCOIN_VOLUME="bitcoin_data"
|
|
||||||
BLINDBIT_VOLUME="blindbit_data"
|
|
||||||
RELAY_1_VOLUME="sdk_relay_1_data"
|
|
||||||
RELAY_2_VOLUME="sdk_relay_2_data"
|
|
||||||
RELAY_3_VOLUME="sdk_relay_3_data"
|
|
||||||
|
|
||||||
# Ports
|
|
||||||
TOR_PORTS=("9050:9050" "9051:9051")
|
|
||||||
BITCOIN_PORTS=("38333:38333" "18443:18443" "29000:29000")
|
|
||||||
BLINDBIT_PORTS=("8000:8000")
|
|
||||||
RELAY_1_PORTS=("8090:8090" "8091:8091")
|
|
||||||
RELAY_2_PORTS=("8092:8090" "8093:8091")
|
|
||||||
RELAY_3_PORTS=("8094:8090" "8095:8091")
|
|
||||||
|
|
||||||
# Chemins de configuration
|
|
||||||
BITCOIN_CONF="$PROJECT_DIR/conf/bitcoin.conf"
|
|
||||||
BLINDBIT_CONF="$PROJECT_DIR/conf/blindbit.toml"
|
|
||||||
RELAY_1_CONF="$PROJECT_DIR/conf/sdk_relay1.conf"
|
|
||||||
RELAY_2_CONF="$PROJECT_DIR/conf/sdk_relay2.conf"
|
|
||||||
RELAY_3_CONF="$PROJECT_DIR/conf/sdk_relay3.conf"
|
|
||||||
EXTERNAL_NODES_CONF="$PROJECT_DIR/scripts/sdk_relay/external_nodes.conf"
|
|
||||||
|
|
||||||
# Variables d'environnement communes
|
|
||||||
COMMON_ENV=(
|
|
||||||
"RUST_LOG=debug,bitcoincore_rpc=trace"
|
|
||||||
"HOME=/home/bitcoin"
|
|
||||||
"BITCOIN_COOKIE_PATH=/home/bitcoin/.bitcoin/signet/.cookie"
|
|
||||||
"ENABLE_SYNC_TEST=1"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Silence potential linter warnings about unused variables from imported config
|
|
||||||
: "${RELAY_1_VOLUME}"
|
|
||||||
: "${RELAY_2_VOLUME}"
|
|
||||||
: "${RELAY_3_VOLUME}"
|
|
||||||
: "${RELAY_1_PORTS[@]}"
|
|
||||||
: "${RELAY_2_PORTS[@]}"
|
|
||||||
: "${RELAY_3_PORTS[@]}"
|
|
||||||
: "${RELAY_1_CONF}"
|
|
||||||
: "${RELAY_2_CONF}"
|
|
||||||
: "${RELAY_3_CONF}"
|
|
||||||
|
|
||||||
# =============================================================================
|
|
||||||
# FONCTIONS UTILITAIRES
|
|
||||||
# =============================================================================
|
|
||||||
|
|
||||||
print_header() {
|
|
||||||
echo -e "${BLUE}=============================================================================${NC}"
|
|
||||||
echo -e "${BLUE}$1${NC}"
|
|
||||||
echo -e "${BLUE}=============================================================================${NC}"
|
|
||||||
}
|
|
||||||
|
|
||||||
print_step() {
|
|
||||||
echo -e "${CYAN}🔄 $1${NC}"
|
|
||||||
}
|
|
||||||
|
|
||||||
print_success() {
|
|
||||||
echo -e "${GREEN}✅ $1${NC}"
|
|
||||||
}
|
|
||||||
|
|
||||||
print_warning() {
|
|
||||||
echo -e "${YELLOW}⚠️ $1${NC}"
|
|
||||||
}
|
|
||||||
|
|
||||||
print_error() {
|
|
||||||
echo -e "${RED}❌ $1${NC}"
|
|
||||||
}
|
|
||||||
|
|
||||||
print_info() {
|
|
||||||
echo -e "${PURPLE}ℹ️ $1${NC}"
|
|
||||||
}
|
|
||||||
|
|
||||||
wait_for_container() {
|
|
||||||
local container_name=$1
|
|
||||||
local max_attempts=${2:-30}
|
|
||||||
local attempt=1
|
|
||||||
|
|
||||||
print_info "Attente du démarrage de $container_name..."
|
|
||||||
|
|
||||||
while [ $attempt -le $max_attempts ]; do
|
|
||||||
if docker ps --format "table {{.Names}}" | grep -q "^$container_name$"; then
|
|
||||||
if docker ps --format "table {{.Status}}" --filter "name=$container_name" | grep -q "Up"; then
|
|
||||||
print_success "$container_name est démarré"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
echo -n "."
|
|
||||||
sleep 2
|
|
||||||
((attempt++))
|
|
||||||
done
|
|
||||||
|
|
||||||
print_error "Timeout: $container_name n'a pas démarré dans les temps"
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
check_file_exists() {
|
|
||||||
local file_path=$1
|
|
||||||
local description=$2
|
|
||||||
|
|
||||||
if [ ! -f "$file_path" ]; then
|
|
||||||
print_error "Fichier manquant: $description ($file_path)"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
print_success "Fichier trouvé: $description"
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
build_port_mapping() {
|
|
||||||
local ports=("$@")
|
|
||||||
local mapping=""
|
|
||||||
|
|
||||||
for port in "${ports[@]}"; do
|
|
||||||
if [ -n "$mapping" ]; then
|
|
||||||
mapping="$mapping -p $port"
|
|
||||||
else
|
|
||||||
mapping="-p $port"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "$mapping"
|
|
||||||
}
|
|
||||||
|
|
||||||
build_env_vars() {
|
|
||||||
local env_vars=""
|
|
||||||
|
|
||||||
for env_var in "${COMMON_ENV[@]}"; do
|
|
||||||
if [ -n "$env_vars" ]; then
|
|
||||||
env_vars="$env_vars -e $env_var"
|
|
||||||
else
|
|
||||||
env_vars="-e $env_var"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "$env_vars"
|
|
||||||
}
|
|
||||||
|
|
||||||
# =============================================================================
|
|
||||||
# FONCTIONS PRINCIPALES
|
|
||||||
# =============================================================================
|
|
||||||
|
|
||||||
stop_all_services() {
|
|
||||||
print_header "ARRÊT DE TOUS LES SERVICES"
|
|
||||||
|
|
||||||
print_step "Arrêt de tous les conteneurs"
|
|
||||||
local _running_ids
|
|
||||||
_running_ids=$(docker ps -q 2>/dev/null || true)
|
|
||||||
if [ -n "${_running_ids}" ]; then
|
|
||||||
IFS=' ' read -r -a _ids_array <<< "${_running_ids}"
|
|
||||||
docker stop "${_ids_array[@]}" 2>/dev/null || true
|
|
||||||
fi
|
|
||||||
|
|
||||||
print_step "Arrêt de docker-compose"
|
|
||||||
docker-compose down -v 2>/dev/null || true
|
|
||||||
|
|
||||||
print_step "Vérification qu'aucun conteneur ne tourne"
|
|
||||||
if docker ps --format "table {{.Names}}" | grep -q .; then
|
|
||||||
print_warning "Des conteneurs sont encore en cours d'exécution"
|
|
||||||
docker ps
|
|
||||||
else
|
|
||||||
print_success "Aucun conteneur en cours d'exécution"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
cleanup_containers() {
|
|
||||||
print_header "NETTOYAGE COMPLET"
|
|
||||||
|
|
||||||
print_step "Suppression de tous les conteneurs"
|
|
||||||
local _to_remove
|
|
||||||
_to_remove=$(docker ps -aq 2>/dev/null || true)
|
|
||||||
if [ -n "$_to_remove" ]; then
|
|
||||||
IFS=' ' read -r -a _to_remove_arr <<< "$_to_remove"
|
|
||||||
local _removed
|
|
||||||
_removed=$(docker rm -f "${_to_remove_arr[@]}" 2>/dev/null || true)
|
|
||||||
if [ -n "$_removed" ]; then
|
|
||||||
print_info "Conteneurs supprimés: $_removed"
|
|
||||||
else
|
|
||||||
print_info "Aucun conteneur à supprimer"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
print_info "Aucun conteneur à supprimer"
|
|
||||||
fi
|
|
||||||
|
|
||||||
print_step "Nettoyage des réseaux"
|
|
||||||
local removed_networks
|
|
||||||
removed_networks=$(docker network prune -f 2>/dev/null || true)
|
|
||||||
if [ -n "$removed_networks" ]; then
|
|
||||||
print_info "Réseaux supprimés: $removed_networks"
|
|
||||||
else
|
|
||||||
print_info "Aucun réseau à supprimer"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
create_network() {
|
|
||||||
print_header "CRÉATION DU RÉSEAU"
|
|
||||||
|
|
||||||
print_step "Création du réseau Docker: $NETWORK_NAME"
|
|
||||||
local network_id
|
|
||||||
network_id=$(docker network create "$NETWORK_NAME" 2>/dev/null || true)
|
|
||||||
if [ -n "$network_id" ]; then
|
|
||||||
print_success "Réseau créé: $network_id"
|
|
||||||
else
|
|
||||||
print_info "Réseau déjà existant ou erreur"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
start_tor() {
|
|
||||||
print_header "DÉMARRAGE DE TOR PROXY"
|
|
||||||
|
|
||||||
print_step "Démarrage de Tor Proxy"
|
|
||||||
local tor_ports
|
|
||||||
tor_ports=$(build_port_mapping "${TOR_PORTS[@]}")
|
|
||||||
local tor_container_id
|
|
||||||
tor_container_id=$(docker run -d \
|
|
||||||
--name tor-proxy \
|
|
||||||
--network "$NETWORK_NAME" \
|
|
||||||
--network-alias tor \
|
|
||||||
$tor_ports \
|
|
||||||
"$TOR_IMAGE")
|
|
||||||
|
|
||||||
print_success "Tor Proxy démarré: $tor_container_id"
|
|
||||||
wait_for_container "tor-proxy" 10
|
|
||||||
}
|
|
||||||
|
|
||||||
start_bitcoin() {
|
|
||||||
print_header "DÉMARRAGE DE BITCOIN CORE"
|
|
||||||
|
|
||||||
# Vérification du fichier de configuration
|
|
||||||
check_file_exists "$BITCOIN_CONF" "Configuration Bitcoin"
|
|
||||||
|
|
||||||
print_step "Démarrage de Bitcoin Core"
|
|
||||||
local bitcoin_ports
|
|
||||||
bitcoin_ports=$(build_port_mapping "${BITCOIN_PORTS[@]}")
|
|
||||||
local bitcoin_container_id
|
|
||||||
bitcoin_container_id=$(docker run -d \
|
|
||||||
--name bitcoin-signet \
|
|
||||||
--network "$NETWORK_NAME" \
|
|
||||||
--network-alias bitcoin \
|
|
||||||
$bitcoin_ports \
|
|
||||||
-v "$BITCOIN_VOLUME:/home/bitcoin/.bitcoin" \
|
|
||||||
-v "$BITCOIN_CONF:/home/bitcoin/bitcoin.conf" \
|
|
||||||
"$BITCOIN_IMAGE")
|
|
||||||
|
|
||||||
print_success "Bitcoin Core démarré: $bitcoin_container_id"
|
|
||||||
wait_for_container "bitcoin-signet" 15
|
|
||||||
}
|
|
||||||
|
|
||||||
start_blindbit() {
|
|
||||||
print_header "DÉMARRAGE DE BLINDBIT ORACLE"
|
|
||||||
|
|
||||||
# Vérification du fichier de configuration
|
|
||||||
check_file_exists "$BLINDBIT_CONF" "Configuration Blindbit"
|
|
||||||
|
|
||||||
print_step "Démarrage de Blindbit Oracle"
|
|
||||||
local blindbit_ports
|
|
||||||
blindbit_ports=$(build_port_mapping "${BLINDBIT_PORTS[@]}")
|
|
||||||
local blindbit_container_id
|
|
||||||
blindbit_container_id=$(docker run -d \
|
|
||||||
--name blindbit-oracle \
|
|
||||||
--network "$NETWORK_NAME" \
|
|
||||||
--network-alias blindbit \
|
|
||||||
$blindbit_ports \
|
|
||||||
-v "$BLINDBIT_VOLUME:/data" \
|
|
||||||
-v "$BLINDBIT_CONF:/data/blindbit.toml" \
|
|
||||||
-v "$BITCOIN_VOLUME:/home/bitcoin/.bitcoin" \
|
|
||||||
"$BLINDBIT_IMAGE")
|
|
||||||
|
|
||||||
print_success "Blindbit Oracle démarré: $blindbit_container_id"
|
|
||||||
wait_for_container "blindbit-oracle" 15
|
|
||||||
}
|
|
||||||
|
|
||||||
build_relay_image() {
|
|
||||||
print_header "CONSTRUCTION DE L'IMAGE SDK_RELAY"
|
|
||||||
|
|
||||||
print_step "Construction de l'image sdk_relay"
|
|
||||||
print_info "Cette étape peut prendre plusieurs minutes..."
|
|
||||||
|
|
||||||
if docker build -f sdk_relay/Dockerfile -t "$RELAY_IMAGE" ..; then
|
|
||||||
print_success "Image sdk_relay construite avec succès"
|
|
||||||
else
|
|
||||||
print_error "Échec de la construction de l'image sdk_relay"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
start_relay() {
|
|
||||||
local relay_number=$1
|
|
||||||
local relay_name="sdk_relay_$relay_number"
|
|
||||||
local relay_conf_var="RELAY_${relay_number}_CONF"
|
|
||||||
local relay_conf="${!relay_conf_var}"
|
|
||||||
local relay_volume_var="RELAY_${relay_number}_VOLUME"
|
|
||||||
local relay_volume="${!relay_volume_var}"
|
|
||||||
local relay_ports_var="RELAY_${relay_number}_PORTS[@]"
|
|
||||||
local relay_ports=("${!relay_ports_var}")
|
|
||||||
|
|
||||||
print_header "DÉMARRAGE DE RELAY $relay_number"
|
|
||||||
|
|
||||||
# Vérification du fichier de configuration
|
|
||||||
check_file_exists "$relay_conf" "Configuration Relay $relay_number"
|
|
||||||
|
|
||||||
# Vérification du fichier de configuration externe
|
|
||||||
check_file_exists "$EXTERNAL_NODES_CONF" "Configuration des nœuds externes"
|
|
||||||
|
|
||||||
print_step "Démarrage de $relay_name"
|
|
||||||
local ports_mapping
|
|
||||||
ports_mapping=$(build_port_mapping "${relay_ports[@]}")
|
|
||||||
local env_vars
|
|
||||||
env_vars=$(build_env_vars)
|
|
||||||
|
|
||||||
local relay_container_id
|
|
||||||
relay_container_id=$(docker run -d \
|
|
||||||
--name "$relay_name" \
|
|
||||||
--network "$NETWORK_NAME" \
|
|
||||||
--network-alias "$relay_name" \
|
|
||||||
$ports_mapping \
|
|
||||||
-v "$BITCOIN_VOLUME:/home/bitcoin/.bitcoin" \
|
|
||||||
-v "$BITCOIN_CONF:/home/bitcoin/bitcoin.conf" \
|
|
||||||
-v "$relay_volume:/home/bitcoin/.4nk" \
|
|
||||||
-v "$relay_conf:/home/bitcoin/.conf.docker" \
|
|
||||||
-v "$PROJECT_DIR/sdk_relay/external_nodes.conf:/home/bitcoin/.4nk/external_nodes.conf" \
|
|
||||||
$env_vars \
|
|
||||||
"$RELAY_IMAGE" \
|
|
||||||
/bin/sh -c "cp /home/bitcoin/.conf.docker /home/bitcoin/.conf && cp /home/bitcoin/.bitcoin/signet/.cookie /home/bitcoin/.4nk/bitcoin.cookie && chmod 600 /home/bitcoin/.4nk/bitcoin.cookie && /usr/local/bin/sdk_relay --config .conf")
|
|
||||||
|
|
||||||
print_success "$relay_name démarré: $relay_container_id"
|
|
||||||
wait_for_container "$relay_name" 20
|
|
||||||
}
|
|
||||||
|
|
||||||
start_all_relays() {
|
|
||||||
print_header "DÉMARRAGE DE TOUS LES RELAYS"
|
|
||||||
|
|
||||||
start_relay 1
|
|
||||||
start_relay 2
|
|
||||||
start_relay 3
|
|
||||||
}
|
|
||||||
|
|
||||||
verify_final_status() {
|
|
||||||
print_header "VÉRIFICATION FINALE"
|
|
||||||
|
|
||||||
print_step "État de tous les services"
|
|
||||||
docker ps
|
|
||||||
|
|
||||||
print_step "Résumé des services actifs"
|
|
||||||
echo -e "${GREEN}Services en cours d'exécution:${NC}"
|
|
||||||
docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"
|
|
||||||
|
|
||||||
print_step "Vérification des ports"
|
|
||||||
local expected_services=("tor-proxy" "bitcoin-signet" "blindbit-oracle" "sdk_relay_1" "sdk_relay_2" "sdk_relay_3")
|
|
||||||
local running_services=0
|
|
||||||
|
|
||||||
for service in "${expected_services[@]}"; do
|
|
||||||
if docker ps --format "table {{.Names}}" | grep -q "^$service$"; then
|
|
||||||
print_success "$service: ✅ En cours d'exécution"
|
|
||||||
((running_services++))
|
|
||||||
else
|
|
||||||
print_error "$service: ❌ Non démarré"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
print_info "Services actifs: $running_services/${#expected_services[@]}"
|
|
||||||
|
|
||||||
if [ $running_services -eq ${#expected_services[@]} ]; then
|
|
||||||
print_success "Tous les services sont opérationnels !"
|
|
||||||
else
|
|
||||||
print_warning "Certains services ne sont pas démarrés"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
show_usage() {
|
|
||||||
echo -e "${BLUE}Usage: $0 [OPTIONS]${NC}"
|
|
||||||
echo ""
|
|
||||||
echo -e "${CYAN}Options:${NC}"
|
|
||||||
echo -e " ${GREEN}-h, --help${NC} Afficher cette aide"
|
|
||||||
echo -e " ${GREEN}-s, --stop${NC} Arrêter tous les services"
|
|
||||||
echo -e " ${GREEN}-c, --clean${NC} Nettoyer les conteneurs"
|
|
||||||
echo -e " ${GREEN}-n, --network${NC} Créer le réseau"
|
|
||||||
echo -e " ${GREEN}-t, --tor${NC} Démarrer Tor"
|
|
||||||
echo -e " ${GREEN}-b, --bitcoin${NC} Démarrer Bitcoin"
|
|
||||||
echo -e " ${GREEN}-l, --blindbit${NC} Démarrer Blindbit"
|
|
||||||
echo -e " ${GREEN}-r, --relays${NC} Démarrer les relais"
|
|
||||||
echo -e " ${GREEN}-v, --verify${NC} Vérifier le statut"
|
|
||||||
echo ""
|
|
||||||
echo -e "${CYAN}Exemples:${NC}"
|
|
||||||
echo -e " ${GREEN}$0${NC} Redémarrage complet"
|
|
||||||
echo -e " ${GREEN}$0 -s${NC} Arrêter tous les services"
|
|
||||||
echo -e " ${GREEN}$0 -r${NC} Démarrer uniquement les relais"
|
|
||||||
echo ""
|
|
||||||
}
|
|
||||||
|
|
||||||
# =============================================================================
|
|
||||||
# FONCTION PRINCIPALE
|
|
||||||
# =============================================================================
|
|
||||||
|
|
||||||
main() {
|
|
||||||
print_header "SCRIPT DE REDÉMARRAGE COMPLET $PROJECT_NAME"
|
|
||||||
print_info "Répertoire de travail: $PROJECT_DIR"
|
|
||||||
print_info "Date: $(date)"
|
|
||||||
|
|
||||||
# Traitement des arguments
|
|
||||||
if [ $# -eq 0 ]; then
|
|
||||||
# Redémarrage complet par défaut
|
|
||||||
stop_all_services
|
|
||||||
cleanup_containers
|
|
||||||
create_network
|
|
||||||
start_tor
|
|
||||||
start_bitcoin
|
|
||||||
start_blindbit
|
|
||||||
build_relay_image
|
|
||||||
start_all_relays
|
|
||||||
verify_final_status
|
|
||||||
else
|
|
||||||
# Traitement des options
|
|
||||||
while [[ $# -gt 0 ]]; do
|
|
||||||
case $1 in
|
|
||||||
-h|--help)
|
|
||||||
show_usage
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
-s|--stop)
|
|
||||||
stop_all_services
|
|
||||||
;;
|
|
||||||
-c|--clean)
|
|
||||||
cleanup_containers
|
|
||||||
;;
|
|
||||||
-n|--network)
|
|
||||||
create_network
|
|
||||||
;;
|
|
||||||
-t|--tor)
|
|
||||||
start_tor
|
|
||||||
;;
|
|
||||||
-b|--bitcoin)
|
|
||||||
start_bitcoin
|
|
||||||
;;
|
|
||||||
-l|--blindbit)
|
|
||||||
start_blindbit
|
|
||||||
;;
|
|
||||||
-r|--relays)
|
|
||||||
build_relay_image
|
|
||||||
start_all_relays
|
|
||||||
;;
|
|
||||||
-v|--verify)
|
|
||||||
verify_final_status
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
print_error "Option inconnue: $1"
|
|
||||||
show_usage
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
shift
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
print_header "REDÉMARRAGE TERMINÉ"
|
|
||||||
print_success "L'infrastructure $PROJECT_NAME est maintenant opérationnelle !"
|
|
||||||
print_info "Services actifs: $(docker ps --format "table {{.Names}}" | wc -l)"
|
|
||||||
print_info "Ports exposés: $(docker ps --format "table {{.Ports}}" | grep -o '[0-9]*->[0-9]*' | wc -l)"
|
|
||||||
}
|
|
||||||
|
|
||||||
# =============================================================================
|
|
||||||
# EXÉCUTION
|
|
||||||
# =============================================================================
|
|
||||||
|
|
||||||
# Vérification de Docker
|
|
||||||
if ! command -v docker &> /dev/null; then
|
|
||||||
print_error "Docker n'est pas installé ou n'est pas dans le PATH"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Vérification que Docker daemon est en cours d'exécution
|
|
||||||
if ! docker info &> /dev/null; then
|
|
||||||
print_error "Docker daemon n'est pas en cours d'exécution"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Exécution du script principal
|
|
||||||
main "$@"
|
|
@ -4,7 +4,7 @@ set -e
|
|||||||
|
|
||||||
# Configuration
|
# Configuration
|
||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
CONFIG_FILE="$SCRIPT_DIR/sdk_relay/external_nodes.conf"
|
CONFIG_FILE="$SCRIPT_DIR/external_nodes.conf"
|
||||||
|
|
||||||
# Couleurs pour l'affichage
|
# Couleurs pour l'affichage
|
||||||
RED='\033[0;31m'
|
RED='\033[0;31m'
|
@ -1,20 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
BASE_DIR="/home/debian/code/4NK_dev/4NK_node"
|
|
||||||
TOR_CONF="$BASE_DIR/conf/tor.conf"
|
|
||||||
|
|
||||||
LINE2=""
|
|
||||||
if [[ -f "$TOR_CONF" ]]; then
|
|
||||||
LINE2=$(awk 'NR==2{print $0}' "$TOR_CONF" 2>/dev/null)
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "$LINE2" == "TorEnabled true" ]]; then
|
|
||||||
echo "No change detected in tor.conf line 2 (TorEnabled true)."
|
|
||||||
exit 0
|
|
||||||
else
|
|
||||||
echo "Change detected in tor.conf line 2: '$LINE2'"
|
|
||||||
echo "Running orchestration to apply changes..."
|
|
||||||
bash "$BASE_DIR/scripts/orchestrate_start.sh"
|
|
||||||
fi
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user