1
0

configure-autoboot.bat 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. @echo off
  2. echo.
  3. echo [WaouW] Configuration Auto-Boot
  4. echo ===============================
  5. echo.
  6. REM Détecter la partition boot
  7. for %%d in (D E F G H I J K L M N O P Q R S T U V W X Y Z) do (
  8. if exist %%d:\cmdline.txt (
  9. set BOOT_DRIVE=%%d:
  10. goto :found_boot
  11. )
  12. )
  13. echo [ERREUR] Partition boot Raspberry Pi non detectee
  14. pause
  15. exit /b 1
  16. :found_boot
  17. echo [INFO] Partition boot detectee : %BOOT_DRIVE%
  18. echo.
  19. REM Sauvegarder l'original cmdline.txt
  20. if not exist "%BOOT_DRIVE%\cmdline.txt.backup" (
  21. echo [INFO] Sauvegarde de cmdline.txt original...
  22. copy "%BOOT_DRIVE%\cmdline.txt" "%BOOT_DRIVE%\cmdline.txt.backup"
  23. )
  24. REM Lire le contenu actuel de cmdline.txt
  25. for /f "delims=" %%i in (%BOOT_DRIVE%\cmdline.txt) do set CMDLINE=%%i
  26. REM Vérifier si notre modification est déjà présente
  27. echo %CMDLINE% | find "systemd.run_success_action" >nul
  28. if %errorlevel% equ 0 (
  29. echo [INFO] Auto-installation deja configuree dans cmdline.txt
  30. goto :create_service
  31. )
  32. REM Ajouter la configuration pour l'auto-installation
  33. echo [INFO] Modification de cmdline.txt pour auto-installation...
  34. echo %CMDLINE% systemd.run_success_action=reboot systemd.unit=waouw-autoinstall.service > "%BOOT_DRIVE%\cmdline.txt"
  35. :create_service
  36. REM Créer le service systemd pour l'auto-installation
  37. echo [INFO] Creation du service d'auto-installation...
  38. REM Créer waouw-autoinstall.service avec encodage UTF-8
  39. powershell -Command "Set-Content -Path '%BOOT_DRIVE%\waouw-autoinstall.service' -Value @'
  40. [Unit]
  41. Description=WaouW Auto Installation Service
  42. After=network-online.target
  43. Wants=network-online.target
  44. DefaultDependencies=false
  45. [Service]
  46. Type=oneshot
  47. ExecStart=/boot/firstrun.sh
  48. StandardOutput=journal+console
  49. StandardError=journal+console
  50. RemainAfterExit=yes
  51. KillMode=process
  52. TimeoutSec=0
  53. [Install]
  54. WantedBy=multi-user.target
  55. '@ -Encoding UTF8"
  56. REM Créer le script qui active le service
  57. echo [INFO] Creation du script d'activation...
  58. REM Créer bootstrap.sh avec encodage UTF-8
  59. powershell -Command "Set-Content -Path '%BOOT_DRIVE%\bootstrap.sh' -Value @'
  60. #!/bin/bash
  61. # WaouW Auto-Installation Bootstrap
  62. # Copier le service vers le bon emplacement
  63. cp /boot/waouw-autoinstall.service /etc/systemd/system/
  64. # Activer le service
  65. systemctl enable waouw-autoinstall.service
  66. # Demarrer le service maintenant
  67. systemctl start waouw-autoinstall.service
  68. '@ -Encoding UTF8"
  69. REM Modifier firstrun.sh pour qu'il soit exécutable et démarre le bootstrap
  70. echo [INFO] Mise a jour du script firstrun.sh...
  71. REM Créer firstrun_new.sh avec encodage UTF-8
  72. powershell -Command "Set-Content -Path '%BOOT_DRIVE%\firstrun_new.sh' -Value @'
  73. #!/bin/bash
  74. # WaouW Auto-Installation avec Bootstrap
  75. set +e
  76. # Rendre executable et lancer le bootstrap si première fois
  77. if [ ! -f /var/log/waouw-bootstrap.done ]; then
  78. chmod +x /boot/bootstrap.sh
  79. /boot/bootstrap.sh
  80. touch /var/log/waouw-bootstrap.done
  81. fi
  82. '@ -Encoding UTF8"
  83. REM Ajouter le contenu existant du firstrun.sh
  84. type "%BOOT_DRIVE%\firstrun.sh" >> "%BOOT_DRIVE%\firstrun_new.sh"
  85. REM Remplacer l'ancien par le nouveau
  86. move "%BOOT_DRIVE%\firstrun_new.sh" "%BOOT_DRIVE%\firstrun.sh"
  87. chmod +x "%BOOT_DRIVE%\firstrun.sh" 2>nul
  88. echo [INFO] Creation du fichier README d'instructions...
  89. REM Créer README avec encodage UTF-8
  90. powershell -Command "Set-Content -Path '%BOOT_DRIVE%\WAOUW-AUTOINSTALL-README.txt' -Value @'
  91. WaouW v2.0 - Configuration Auto-Installation
  92. ===========================================
  93. Cette carte SD est maintenant configuree pour installer
  94. automatiquement WaouW v2.0 au premier demarrage.
  95. MODIFICATION APPORTEES :
  96. - cmdline.txt modifie pour declencher l'auto-installation
  97. - Service systemd cree : waouw-autoinstall.service
  98. - Script bootstrap ajoute pour l'activation
  99. - Encodage UTF-8 corrige pour tous les fichiers
  100. PROCESSUS D'INSTALLATION :
  101. 1. Inserer cette SD dans le Raspberry Pi
  102. 2. Demarrer le Pi (AVEC connexion Internet)
  103. 3. Le Pi va demarrer et lancer automatiquement l'installation
  104. 4. Attendre 20-40 minutes pour l'installation complete
  105. 5. L'installation est terminee quand vous pouvez acceder a l'interface
  106. ACCES APRES INSTALLATION :
  107. - Interface : http://[IP-DU-PI]:7165
  108. - Login : admin / admin (a changer immediatement)
  109. VERIFICATION :
  110. - Connectez-vous en SSH : ssh pi@[IP-DU-PI]
  111. - Verifiez les logs : journalctl -u waouw-autoinstall
  112. Date configuration : %date% %time%
  113. '@ -Encoding UTF8"
  114. echo.
  115. echo ========================================
  116. echo AUTO-INSTALLATION CONFIGUREE !
  117. echo ========================================
  118. echo.
  119. echo Modifications apportees a %BOOT_DRIVE% :
  120. echo - cmdline.txt modifie pour declencher l'installation
  121. echo - waouw-autoinstall.service cree (encodage UTF-8)
  122. echo - bootstrap.sh cree pour l'activation (encodage UTF-8)
  123. echo - firstrun.sh mis a jour (encodage UTF-8)
  124. echo - README d'instructions ajoute (encodage UTF-8)
  125. echo.
  126. echo IMPORTANT :
  127. echo Cette SD va maintenant installer WaouW AUTOMATIQUEMENT
  128. echo au premier demarrage du Raspberry Pi.
  129. echo.
  130. echo PROCHAINES ETAPES :
  131. echo 1. Ejecter proprement la carte SD
  132. echo 2. Inserer dans le Raspberry Pi
  133. echo 3. Demarrer le Pi ^(AVEC connexion Internet^)
  134. echo 4. Attendre 20-40 minutes
  135. echo 5. Acceder a http://[IP-PI]:7165
  136. echo.
  137. pause