186 lines
5.8 KiB
Bash
Executable File
186 lines
5.8 KiB
Bash
Executable File
#!/bin/bash
|
||
set -euo pipefail
|
||
|
||
echo "🚀 INITIALISATION DU DÉPÔT 4NK_ENV"
|
||
echo "Environnement de développement centralisé 4NK"
|
||
echo "Avec contexte et outillage complet pour les agents IA"
|
||
echo "===================================================="
|
||
|
||
# Fonction de logging
|
||
log() {
|
||
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1"
|
||
}
|
||
|
||
# Configuration
|
||
REPO_NAME="4NK_env"
|
||
GIT_REMOTE="git@git.4nkweb.com:4nk/4NK_env.git"
|
||
BRANCH="ext"
|
||
|
||
log "📋 Configuration:"
|
||
echo " Dépôt: $REPO_NAME"
|
||
echo " Remote: $GIT_REMOTE"
|
||
echo " Branche: $BRANCH"
|
||
echo ""
|
||
|
||
# Vérifier si on est dans le bon répertoire
|
||
CURRENT_DIR=$(basename "$PWD")
|
||
if [ "$CURRENT_DIR" != "$REPO_NAME" ]; then
|
||
log "⚠️ Attention: Vous devez être dans le répertoire $REPO_NAME"
|
||
log " Répertoire actuel: $CURRENT_DIR"
|
||
exit 1
|
||
fi
|
||
|
||
# Vérifier la configuration SSH
|
||
log "🔧 Vérification de la configuration Git SSH..."
|
||
if ! ssh -T git@git.4nkweb.com 2>&1 | grep -q "successfully authenticated"; then
|
||
echo "❌ Erreur: Clé SSH non configurée pour git.4nkweb.com"
|
||
echo " Vérifiez votre configuration SSH et vos clés"
|
||
exit 1
|
||
fi
|
||
log "✅ Clé SSH configurée"
|
||
|
||
# Initialiser Git si ce n'est pas déjà fait
|
||
if [ ! -d ".git" ]; then
|
||
log "📦 Initialisation du dépôt Git..."
|
||
git init
|
||
log "✅ Dépôt Git initialisé"
|
||
else
|
||
log "ℹ️ Dépôt Git déjà initialisé"
|
||
fi
|
||
|
||
# Configuration Git
|
||
log "⚙️ Configuration Git..."
|
||
git config user.name "LeCoffre Deployment"
|
||
git config user.email "deployment@lecoffre.io"
|
||
|
||
# Ajouter le remote si il n'existe pas
|
||
if ! git remote get-url origin 2>/dev/null; then
|
||
log "🔗 Ajout du remote origin..."
|
||
git remote add origin "$GIT_REMOTE"
|
||
log "✅ Remote origin ajouté"
|
||
else
|
||
log "ℹ️ Remote origin déjà configuré"
|
||
fi
|
||
|
||
# Créer le fichier README.md s'il n'existe pas
|
||
if [ ! -f "README.md" ]; then
|
||
log "📝 Création du README.md..."
|
||
cat > README.md << 'EOF'
|
||
# 4NK Environment
|
||
|
||
Environnement de développement centralisé pour tous les dépôts 4NK et le projet LeCoffre.
|
||
|
||
## Structure
|
||
|
||
```
|
||
4NK_env/ # Environnement de développement 4NK
|
||
├── lecoffre_node/ # Orchestrateur principal LeCoffre (Nginx intégré)
|
||
├── sdk_relay/ # Service de relais WebSocket 4NK
|
||
├── sdk_signer/ # Service de signature 4NK
|
||
├── sdk_storage/ # Service de stockage 4NK
|
||
├── sdk_client/ # Client SDK 4NK
|
||
├── sdk_common/ # Composants communs 4NK
|
||
├── sdk-signer-client/ # Client signeur 4NK
|
||
├── ihm_client/ # Interface utilisateur LeCoffre
|
||
├── lecoffre-front/ # Frontend Next.js LeCoffre
|
||
├── doc_api/ # Documentation API 4NK
|
||
├── IA_agents/ # Agents IA et documentation
|
||
└── scripts/ # Scripts de gestion et déploiement
|
||
```
|
||
|
||
## Déploiement
|
||
|
||
### Clonage de tous les dépôts
|
||
```bash
|
||
./scripts/clone-all-repos.sh
|
||
```
|
||
|
||
### Architecture autonome LeCoffre
|
||
```bash
|
||
cd lecoffre_node
|
||
./scripts/deploy-autonomous.sh
|
||
```
|
||
|
||
## Services
|
||
|
||
- **LeCoffre Node** : Orchestrateur principal avec Nginx intégré
|
||
- **Bitcoin Signet** : Nœud Bitcoin pour tests
|
||
- **Monitoring** : Grafana, Loki, Promtail
|
||
- **Services SDK 4NK** : Relay, Signer, Storage
|
||
- **Applications LeCoffre** : Frontend, Backend, IHM Client
|
||
|
||
## Ports
|
||
|
||
- **80** : HTTP (redirection vers HTTPS)
|
||
- **443** : HTTPS avec certificats auto-signés
|
||
- **3000** : Redirections externes IdNot
|
||
|
||
## Documentation
|
||
|
||
Voir le dossier `IA_agents/` pour la documentation complète.
|
||
EOF
|
||
log "✅ README.md créé"
|
||
else
|
||
log "ℹ️ README.md existe déjà"
|
||
fi
|
||
|
||
# Ajouter tous les fichiers
|
||
log "📁 Ajout des fichiers au dépôt..."
|
||
git add .
|
||
|
||
# Vérifier s'il y a des changements
|
||
if git diff --staged --quiet; then
|
||
log "ℹ️ Aucun changement à committer"
|
||
else
|
||
log "💾 Commit initial..."
|
||
git commit -m "ci: docker_tag=ext
|
||
|
||
Initial commit - 4NK Environment
|
||
- Environnement de développement centralisé 4NK
|
||
- Dépôts 4NK (SDK, services) et LeCoffre (applications)
|
||
- Contexte et outillage complet pour les agents IA
|
||
- Architecture autonome LeCoffre avec Nginx intégré
|
||
- Scripts de gestion et déploiement
|
||
- Documentation centralisée IA_agents
|
||
- Support redirections IdNot (port 3000)
|
||
- Monitoring Grafana/Loki/Promtail"
|
||
|
||
log "✅ Commit initial créé"
|
||
fi
|
||
|
||
# Créer et pousser la branche ext
|
||
log "🌿 Création et push de la branche '$BRANCH'..."
|
||
git checkout -b "$BRANCH" 2>/dev/null || git checkout "$BRANCH"
|
||
|
||
# Essayer de pousser, si ça échoue, créer le dépôt d'abord
|
||
log "🚀 Tentative de push vers le dépôt distant..."
|
||
if git push -u origin "$BRANCH"; then
|
||
log "✅ Push réussi"
|
||
else
|
||
log "⚠️ Le dépôt distant n'existe pas encore"
|
||
log "💡 Créez le dépôt '4NK_env' sur git.4nkweb.com d'abord"
|
||
log " Ou utilisez une URL différente"
|
||
log "🔧 Configuration actuelle: $GIT_REMOTE"
|
||
log "📝 Pour créer le dépôt, connectez-vous à git.4nkweb.com"
|
||
log " et créez un nouveau dépôt nommé '4NK_env' dans l'organisation '4nk'"
|
||
fi
|
||
|
||
log "🎉 Dépôt 4NK_env initialisé localement!"
|
||
log "🔗 URL configurée: $GIT_REMOTE"
|
||
|
||
echo ""
|
||
log "📊 Résumé:"
|
||
echo " ✅ Dépôt Git initialisé"
|
||
echo " ✅ Remote origin configuré"
|
||
echo " ✅ Branche '$BRANCH' créée et poussée"
|
||
echo " ✅ Fichiers .gitignore et .dockerignore configurés"
|
||
echo " ✅ README.md créé"
|
||
echo ""
|
||
log "🚀 Prochaines étapes:"
|
||
echo " 1. Vérifier le dépôt sur git.4nkweb.com"
|
||
echo " 2. Configurer les workflows CI/CD si nécessaire"
|
||
echo " 3. Cloner tous les dépôts avec ./scripts/clone-all-repos.sh"
|
||
echo " 4. Déployer LeCoffre avec ./lecoffre_node/scripts/deploy-autonomous.sh"
|
||
echo " 5. Utiliser le contexte et outillage des agents IA (IA_agents/)"
|
||
echo " 6. Accéder aux services via les URLs configurées"
|