1
0

auto-prep-sd.ps1 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. # WaouW v2.0 - Préparation SD Automatique
  2. param(
  3. [string]$DriveLetter = "E:"
  4. )
  5. Write-Host "=== WaouW v2.0 - Preparation SD Automatique ===" -ForegroundColor Cyan
  6. # Vérifier la lettre du lecteur
  7. if (!(Test-Path "$DriveLetter")) {
  8. Write-Host "Erreur: Lecteur $DriveLetter introuvable" -ForegroundColor Red
  9. exit 1
  10. }
  11. if (!(Test-Path "$DriveLetter\cmdline.txt")) {
  12. Write-Host "Erreur: $DriveLetter n'est pas une partition boot Raspberry Pi" -ForegroundColor Red
  13. exit 1
  14. }
  15. Write-Host "Preparation de la carte SD: $DriveLetter" -ForegroundColor Green
  16. # Copier l'archive
  17. Write-Host "Copie de l'archive WaouW..."
  18. Copy-Item "..\waouw-deploy.zip" "$DriveLetter\waouw-deploy.zip" -Force
  19. # Copier les scripts d'installation automatique
  20. Write-Host "Copie des scripts d'installation automatique..."
  21. Copy-Item "install-simple.sh" "$DriveLetter\install.sh" -Force
  22. # Script de démarrage simplifié créé dans install.sh
  23. # Créer configuration autologin
  24. Write-Host "Configuration autologin automatique..."
  25. $autologinConf = @"
  26. [Service]
  27. ExecStart=
  28. ExecStart=-/sbin/agetty --autologin pi --noclear %I `$TERM
  29. "@
  30. $autologinConf | Out-File -FilePath "$DriveLetter\autologin.conf" -Encoding UTF8 -Force
  31. # Créer script post-login
  32. Write-Host "Création du script post-login..."
  33. $postLogin = @"
  34. #!/bin/bash
  35. # WaouW Post-Login Auto-Start
  36. # Attendre un peu
  37. sleep 5
  38. # Lancer le script de démarrage
  39. if [ -f /boot/firmware/waouw-start.sh ]; then
  40. echo "Lancement WaouW..."
  41. bash /boot/firmware/waouw-start.sh
  42. fi
  43. "@
  44. $postLogin | Out-File -FilePath "$DriveLetter\post-login.sh" -Encoding UTF8 -Force
  45. # Modifier cmdline.txt pour autologin (méthode alternative)
  46. Write-Host "Configuration cmdline.txt pour autologin..."
  47. $cmdlinePath = "$DriveLetter\cmdline.txt"
  48. if (Test-Path $cmdlinePath) {
  49. $cmdline = Get-Content $cmdlinePath -Raw
  50. # Ajouter console=tty1 au cmdline pour forcer l'autologin
  51. if ($cmdline -notlike "*console=tty1*") {
  52. $cmdline = $cmdline.Trim() + " console=tty1"
  53. $cmdline | Out-File -FilePath $cmdlinePath -Encoding UTF8 -NoNewline
  54. }
  55. }
  56. # Créer le fichier .env
  57. Write-Host "Creation du fichier .env..."
  58. $envContent = @"
  59. # WaouW v2.0 - Configuration Automatique
  60. WAOUW_DOMAIN=waouw.local
  61. ACME_EMAIL=ssl-agent@waouw.tech
  62. # Database
  63. POSTGRES_PASSWORD=waouw123
  64. DATABASE_URL=postgresql://waouw:waouw123@postgres:5432/waouw
  65. # Security
  66. JWT_SECRET_KEY=auto-secret-key-2024
  67. DEVICE_HMAC_SECRET=auto-device-secret-2024
  68. # Cache
  69. REDIS_URL=redis://redis:6379/0
  70. # Email (optional services)
  71. MAIL_MYSQL_ROOT_PASSWORD=mailroot2024
  72. MAIL_MYSQL_PASSWORD=mailpass2024
  73. SMTP_PASSWORD=smtppass2024
  74. # Nextcloud (optional)
  75. NEXTCLOUD_MYSQL_ROOT_PASSWORD=nextroot2024
  76. NEXTCLOUD_MYSQL_PASSWORD=nextpass2024
  77. NEXTCLOUD_ADMIN_PASSWORD=nextadmin2024
  78. # System
  79. PHPMYADMIN_PASSWORD=phpmyadmin2024
  80. WEBMIN_ROOT_PASSWORD=webmin2024
  81. # Monitoring (optional)
  82. GRAYLOG_PASSWORD_SECRET=graylogsecret2024
  83. GRAYLOG_ROOT_PASSWORD_SHA2=8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918
  84. GRAFANA_ADMIN_PASSWORD=grafana2024
  85. # Services
  86. PROMETHEUS_ENABLED=true
  87. GRAFANA_ENABLED=true
  88. TZ=Europe/Paris
  89. "@
  90. $envContent | Out-File -FilePath "$DriveLetter\.env" -Encoding UTF8
  91. # Créer le fichier README
  92. Write-Host "Creation du fichier README..."
  93. $readme = @"
  94. WaouW v2.0 - Installation Automatique
  95. =====================================
  96. Cette carte SD est preparee pour une installation 100% automatique de WaouW v2.0.
  97. PROCESSUS :
  98. 1. Inserer cette carte SD dans votre Raspberry Pi
  99. 2. Brancher l'alimentation
  100. 3. Attendre 5-10 minutes (installation automatique)
  101. 4. Acceder a WaouW : http://waouw.local
  102. UTILISATEUR :
  103. - Login : admin
  104. - Mot de passe : admin
  105. L'installation se fait entierement automatiquement !
  106. "@
  107. $readme | Out-File -FilePath "$DriveLetter\WAOUW-README.txt" -Encoding ASCII
  108. Write-Host ""
  109. Write-Host "=== PREPARATION TERMINEE ===" -ForegroundColor Green
  110. Write-Host "Carte SD prete pour installation automatique !" -ForegroundColor Green
  111. Write-Host ""
  112. Write-Host "Prochaines etapes :" -ForegroundColor Yellow
  113. Write-Host "1. Ejecter la carte SD proprement" -ForegroundColor Yellow
  114. Write-Host "2. Inserer dans le Raspberry Pi" -ForegroundColor Yellow
  115. Write-Host "3. Brancher l'alimentation" -ForegroundColor Yellow
  116. Write-Host "4. Attendre 5-10 minutes" -ForegroundColor Yellow
  117. Write-Host "5. Acceder a http://waouw.local" -ForegroundColor Yellow
  118. Write-Host ""
  119. pause