1
0

configure-autoboot-fixed.bat 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. @echo off
  2. echo.
  3. echo [WaouW] Configuration Auto-Boot (Version Corrigee)
  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 méthode compatible
  39. (
  40. echo [Unit]
  41. echo Description=WaouW Auto Installation Service
  42. echo After=network-online.target
  43. echo Wants=network-online.target
  44. echo DefaultDependencies=false
  45. echo.
  46. echo [Service]
  47. echo Type=oneshot
  48. echo ExecStart=/boot/firstrun.sh
  49. echo StandardOutput=journal+console
  50. echo StandardError=journal+console
  51. echo RemainAfterExit=yes
  52. echo KillMode=process
  53. echo TimeoutSec=0
  54. echo.
  55. echo [Install]
  56. echo WantedBy=multi-user.target
  57. ) > "%BOOT_DRIVE%\waouw-autoinstall.service"
  58. REM Créer le script qui active le service
  59. echo [INFO] Creation du script d'activation...
  60. REM Créer bootstrap.sh avec méthode compatible
  61. (
  62. echo #!/bin/bash
  63. echo # WaouW Auto-Installation Bootstrap
  64. echo.
  65. echo # Copier le service vers le bon emplacement
  66. echo cp /boot/waouw-autoinstall.service /etc/systemd/system/
  67. echo.
  68. echo # Activer le service
  69. echo systemctl enable waouw-autoinstall.service
  70. echo.
  71. echo # Demarrer le service maintenant
  72. echo systemctl start waouw-autoinstall.service
  73. ) > "%BOOT_DRIVE%\bootstrap.sh"
  74. REM Modifier firstrun.sh pour qu'il soit exécutable et démarre le bootstrap
  75. echo [INFO] Mise a jour du script firstrun.sh...
  76. REM Créer firstrun_new.sh avec méthode compatible
  77. (
  78. echo #!/bin/bash
  79. echo # WaouW Auto-Installation avec Bootstrap
  80. echo set +e
  81. echo.
  82. echo # Rendre executable et lancer le bootstrap si première fois
  83. echo if [ ! -f /var/log/waouw-bootstrap.done ]; then
  84. echo chmod +x /boot/bootstrap.sh
  85. echo /boot/bootstrap.sh
  86. echo touch /var/log/waouw-bootstrap.done
  87. echo fi
  88. echo.
  89. ) > "%BOOT_DRIVE%\firstrun_new.sh"
  90. REM Ajouter le contenu existant du firstrun.sh
  91. type "%BOOT_DRIVE%\firstrun.sh" >> "%BOOT_DRIVE%\firstrun_new.sh"
  92. REM Remplacer l'ancien par le nouveau
  93. move "%BOOT_DRIVE%\firstrun_new.sh" "%BOOT_DRIVE%\firstrun.sh"
  94. chmod +x "%BOOT_DRIVE%\firstrun.sh" 2>nul
  95. echo [INFO] Creation du fichier README d'instructions...
  96. REM Créer README avec méthode compatible
  97. (
  98. echo WaouW v2.0 - Configuration Auto-Installation
  99. echo ===========================================
  100. echo.
  101. echo Cette carte SD est maintenant configuree pour installer
  102. echo automatiquement WaouW v2.0 au premier demarrage.
  103. echo.
  104. echo MODIFICATION APPORTEES :
  105. echo - cmdline.txt modifie pour declencher l'auto-installation
  106. echo - Service systemd cree : waouw-autoinstall.service
  107. echo - Script bootstrap ajoute pour l'activation
  108. echo - Encodage compatible Windows
  109. echo.
  110. echo PROCESSUS D'INSTALLATION :
  111. echo 1. Inserer cette SD dans le Raspberry Pi
  112. echo 2. Demarrer le Pi ^(AVEC connexion Internet^)
  113. echo 3. Le Pi va demarrer et lancer automatiquement l'installation
  114. echo 4. Attendre 20-40 minutes pour l'installation complete
  115. echo 5. L'installation est terminee quand vous pouvez acceder a l'interface
  116. echo.
  117. echo ACCES APRES INSTALLATION :
  118. echo - Interface : http://[IP-DU-PI]:7165
  119. echo - Login : admin / admin ^(a changer immediatement^)
  120. echo.
  121. echo VERIFICATION :
  122. echo - Connectez-vous en SSH : ssh pi@[IP-DU-PI]
  123. echo - Verifiez les logs : journalctl -u waouw-autoinstall
  124. echo.
  125. echo Date configuration : %date% %time%
  126. ) > "%BOOT_DRIVE%\WAOUW-AUTOINSTALL-README.txt"
  127. echo.
  128. echo ========================================
  129. echo AUTO-INSTALLATION CONFIGUREE !
  130. echo ========================================
  131. echo.
  132. echo Modifications apportees a %BOOT_DRIVE% :
  133. echo - cmdline.txt modifie pour declencher l'installation
  134. echo - waouw-autoinstall.service cree ^(encodage compatible^)
  135. echo - bootstrap.sh cree pour l'activation ^(encodage compatible^)
  136. echo - firstrun.sh mis a jour ^(encodage compatible^)
  137. echo - README d'instructions ajoute ^(encodage compatible^)
  138. echo.
  139. echo IMPORTANT :
  140. echo Cette SD va maintenant installer WaouW AUTOMATIQUEMENT
  141. echo au premier demarrage du Raspberry Pi.
  142. echo.
  143. echo PROCHAINES ETAPES :
  144. echo 1. Ejecter proprement la carte SD
  145. echo 2. Inserer dans le Raspberry Pi
  146. echo 3. Demarrer le Pi ^(AVEC connexion Internet^)
  147. echo 4. Attendre 20-40 minutes
  148. echo 5. Acceder a http://[IP-PI]:7165
  149. echo.
  150. pause