taler-windows

Windows packaging
Log | Files | Refs

commit 9f9d57832f92792bef406d14bb6089ae3641489f
parent aa2d6e34829953dd49221c258ba02cd5a0c43911
Author: Leayawi <lea.oualli@outlook.fr>
Date:   Sun, 29 Jun 2025 21:46:29 +0200

Ajout de l'installateur avec correction

Diffstat:
Msetup-wsl-debian.bat | 3---
Mtaler-installer-taler.nsi | 214+++++++++++++++++++++++++++++++------------------------------------------------
Dtest/test.bat | 35-----------------------------------
Dtest/test.nsi | 19-------------------
Dtest/test/rootfs.text | 0
Dtest/test/test.bat | 32--------------------------------
6 files changed, 85 insertions(+), 218 deletions(-)

diff --git a/setup-wsl-debian.bat b/setup-wsl-debian.bat @@ -78,7 +78,6 @@ if %VMP_ENABLED% equ 0 ( if defined NEED_REBOOT ( echo [%DATE% %TIME%] [INFO] REBOOT REQUIRED! >> %LOGFILE% - echo REBOOT > C:\Users\Public\taler-reboot.flag echo [INFO] A restart is required to finish enabling WSL features. Please restart your computer and run the installer again. pause exit /b 1 @@ -262,7 +261,5 @@ powershell -Command "Register-ScheduledTask -Action (New-ScheduledTaskAction -Ex echo [%DATE% %TIME%] GNU Taler-Merchant installed successfully! >> %LOGFILE% echo [%DATE% %TIME%] === [END] GNU Taler-Merchant Installer === >> %LOGFILE% -del C:\Users\Public\taler-reboot.flag 2>nul - timeout /t 5 /nobreak >nul exit /b diff --git a/taler-installer-taler.nsi b/taler-installer-taler.nsi @@ -16,8 +16,6 @@ Unicode true !define MUI_LANGDLL_REGISTRY_ROOT "HKCU" !define MUI_LANGDLL_REGISTRY_KEY "Software\TalerInstaller" !define MUI_LANGDLL_REGISTRY_VALUENAME "InstallerLanguage" -!define REBOOT_FLAG "C:\Users\Public\taler-reboot.flag" - Name "Taler-Merchant backend" Outfile "taler-installer.exe" @@ -32,45 +30,11 @@ Icon "logo-header.ico" !define MUI_HEADERIMAGE_BITMAP_NOSTRETCH !define MUI_WELCOMEFINISHPAGE_BITMAP "logo-welcome.bmp" -Var /GLOBAL PREWELCOME_LABEL - -LangString MSG_PREWELCOME_TITLE 1033 "Windows Subsystem for Linux activation" -LangString MSG_PREWELCOME_TITLE 1036 "Activation du Windows Subsystem for Linux" - -LangString MSG_PREWELCOME_TEXT 1033 "This first step will enable the Windows features required for GNU Taler-Merchant: Windows Subsystem for Linux (WSL) and VirtualMachinePlatform.$\r$\n$\r$\nYour computer may need to reboot at the end of this step.$\r$\n$\r$\nClick 'Next' to continue with system activation. No installation will be performed yet." -LangString MSG_PREWELCOME_TEXT 1036 "Cette première étape va activer les fonctionnalités nécessaires à GNU Taler-Merchant : Windows Subsystem for Linux (WSL) et VirtualMachinePlatform.$\r$\n$\r$\nVotre ordinateur devra peut-être redémarrer à la fin de cette étape.$\r$\n$\r$\nCliquez sur 'Suivant' pour lancer l'activation système. Aucune installation ne sera faite pour l'instant." - -Function PreWelcomePage - nsDialogs::Create 1018 - Pop $0 - ${If} $0 == error - Abort - ${EndIf} - ${NSD_CreateLabel} 0 10u 100% 40u $(MSG_PREWELCOME_TEXT) - Pop $PREWELCOME_LABEL - nsDialogs::Show -FunctionEnd - -Function PreWelcomePageLeave - nsExec::ExecToLog '"$EXEDIR\setup-wsl-debian.bat" 1' - IfFileExists ${REBOOT_FLAG} 0 no_reboot - MessageBox MB_OK $(MSG_NEED_REBOOT) - Quit - no_reboot: - MessageBox MB_OK "No reboot required, you can relaunch the installer to continue." - Quit -FunctionEnd - - -PageEx custom - PageCallbacks PreWelcomePage PreWelcomePageLeave -PageExEnd !insertmacro MUI_PAGE_WELCOME !insertmacro MUI_PAGE_DIRECTORY Page custom DistroPage DistroPageLeave Page custom DomainPage DomainPageLeave Page custom ReverseProxyPage ReverseProxyPageLeave -Page custom ProgressPage ProgressPageLeave !insertmacro MUI_PAGE_INSTFILES Page custom AskExternalDBPage AskExternalDBPageLeave Page custom DBUrlPage DBUrlPageLeave @@ -92,104 +56,74 @@ Var /GLOBAL DB_URL Var /GLOBAL DBCONFIG_INPUT Var /GLOBAL ASK_DB_YESNO Var /GLOBAL USE_EXTERNAL_DB -Var /GLOBAL PHASE1 - -Function .onInit - ; PHASE 1 = pas de flag, donc il faut activer WSL - IfFileExists ${REBOOT_FLAG} 0 is_phase1 - StrCpy $PHASE1 "1" - Return - is_phase1: - StrCpy $PHASE1 "0" -FunctionEnd +LangString MSG_WELCOME_TITLE ${LANG_ENGLISH} "GNU Taler-Merchant backend for Windows" +LangString MSG_WELCOME_TITLE ${LANG_FRENCH} "Backend GNU Taler-Merchant pour Windows" +LangString MSG_WELCOME_TEXT ${LANG_ENGLISH} "This wizard will install The GNU Taler-Merchant using WSL and Debian or Ubuntu." +LangString MSG_WELCOME_TEXT ${LANG_FRENCH} "Cet assistant va installer GNU Taler-Merchant avec WSL et Debian ou Ubuntu." -LangString MSG_WELCOME_TITLE 1033 "GNU Taler-Merchant backend for Windows" -LangString MSG_WELCOME_TITLE 1036 "Backend GNU Taler-Merchant pour Windows" +LangString ENTER_DOMAIN ${LANG_ENGLISH} "Enter your Taler-Merchant domain name:" +LangString ENTER_DOMAIN ${LANG_FRENCH} "Entrez le nom de votre domaine Taler-Merchant:" -LangString MSG_WELCOME_TEXT 1033 "This wizard will install The GNU Taler-Merchant using WSL and Debian or Ubuntu." -LangString MSG_WELCOME_TEXT 1036 "Cet assistant va installer GNU Taler-Merchant avec WSL et Debian ou Ubuntu." +LangString MSG_DOMAIN_REQUIRED ${LANG_ENGLISH} "Please enter a domain name." +LangString MSG_DOMAIN_REQUIRED ${LANG_FRENCH} "Veuillez saisir un nom de domaine." -LangString ENTER_DOMAIN 1033 "Enter your Taler-Merchant domain name:" -LangString ENTER_DOMAIN 1036 "Entrez le nom de votre domaine Taler-Merchant:" +LangString MSG_LOCALHOST_WARN ${LANG_ENGLISH} "Warning: using 'localhost' means your merchant will not be publicly accessible." +LangString MSG_LOCALHOST_WARN ${LANG_FRENCH} "Attention : utiliser 'localhost' signifie que votre marchand ne sera pas accessible publiquement." -LangString MSG_DOMAIN_REQUIRED 1033 "Please enter a domain name." -LangString MSG_DOMAIN_REQUIRED 1036 "Veuillez saisir un nom de domaine." +LangString MSG_STEP1 ${LANG_ENGLISH} "Step 1: Enabling WSL and VirtualMachinePlatform.$\r$\n$\r$\nThis is the slowest step and can take several minutes (up to 10 minutes on some computers).$\r$\n$\r$\nPlease DO NOT close the installer. You will see the progress bar freeze during this step.$\r$\n$\r$\nThe installation will continue automatically once this step is done." +LangString MSG_STEP1 ${LANG_FRENCH} "Etape 1 : Activation de WSL et VirtualMachinePlatform.$\r$\n$\r$\nC'est l'etape la plus lente et cela peut prendre plusieurs minutes (jusqu'a 10 minutes sur certains ordinateurs).$\r$\n$\r$\nVeuillez NE PAS fermer l'installateur. La barre de progression peut sembler bloquee.$\r$\n$\r$\nL'installation continuera automatiquement des que cette etape sera terminee." -LangString MSG_LOCALHOST_WARN 1033 "Warning: using 'localhost' means your merchant will not be publicly accessible." -LangString MSG_LOCALHOST_WARN 1036 "Attention : utiliser 'localhost' signifie que votre marchand ne sera pas accessible publiquement." +LangString MSG_NEED_REBOOT ${LANG_ENGLISH} "WSL features have just been enabled. You must restart your computer NOW to continue the installation. Please run this installer again after reboot." +LangString MSG_NEED_REBOOT ${LANG_FRENCH} "Les fonctionnalites WSL viennent d'etre activees. Vous devez redemarrer votre ordinateur MAINTENANT pour poursuivre l'installation. Relancez cet installateur apres redemarrage." -LangString MSG_STEP1 1033 "Step 1: Enabling WSL and VirtualMachinePlatform.$\r$\n$\r$\nThis is the slowest step and can take several minutes (up to 10 minutes on some computers).$\r$\n$\r$\nPlease DO NOT close the installer. You will see the progress bar freeze during this step.$\r$\n$\r$\nThe installation will continue automatically once this step is done." -LangString MSG_STEP1 1036 "Etape 1 : Activation de WSL et VirtualMachinePlatform.$\r$\n$\r$\nC'est l'etape la plus lente et cela peut prendre plusieurs minutes (jusqu'a 10 minutes sur certains ordinateurs).$\r$\n$\r$\nVeuillez NE PAS fermer l'installateur. La barre de progression peut sembler bloquee.$\r$\n$\r$\nL'installation continuera automatiquement des que cette etape sera terminee." +LangString MSG_UPDATE_WSL ${LANG_ENGLISH} "A Windows update window will now appear to update WSL. Please follow the instructions in the black window and press any key if prompted. Click OK to continue." +LangString MSG_UPDATE_WSL ${LANG_FRENCH} "Une fenetre de mise a jour Windows va apparaitre pour mettre a jour WSL. Suivez les instructions et appuyez sur une touche si demande. Cliquez sur OK pour continuer." -LangString MSG_NEED_REBOOT 1033 "WSL features have just been enabled. You must restart your computer NOW to continue the installation. Please run this installer again after reboot." -LangString MSG_NEED_REBOOT 1036 "Les fonctionnalites WSL viennent d'etre activees. Vous devez redemarrer votre ordinateur MAINTENANT pour poursuivre l'installation. Relancez cet installateur apres redemarrage." +LangString MSG_INSTALL_FAILED ${LANG_ENGLISH} "Installation failed. Opening install.log..." +LangString MSG_INSTALL_FAILED ${LANG_FRENCH} "L'installation a echoue. Ouverture du fichier install.log..." -LangString MSG_UPDATE_WSL 1033 "A Windows update window will now appear to update WSL. Please follow the instructions in the black window and press any key if prompted. Click OK to continue." -LangString MSG_UPDATE_WSL 1036 "Une fenetre de mise a jour Windows va apparaitre pour mettre a jour WSL. Suivez les instructions et appuyez sur une touche si demande. Cliquez sur OK pour continuer." +LangString MSG_REVERSE_PROXY_TITLE ${LANG_ENGLISH} "Select reverse proxy mode:" +LangString MSG_REVERSE_PROXY_TITLE ${LANG_FRENCH} "Choisissez le mode du reverse proxy :" -LangString MSG_INSTALL_FAILED 1033 "Installation failed. Opening install.log..." -LangString MSG_INSTALL_FAILED 1036 "L'installation a echoue. Ouverture du fichier install.log..." +LangString MSG_HTTP_ONLY ${LANG_ENGLISH} "HTTP only" +LangString MSG_HTTP_ONLY ${LANG_FRENCH} "HTTP uniquement" -LangString MSG_REVERSE_PROXY_TITLE 1033 "Select reverse proxy mode:" -LangString MSG_REVERSE_PROXY_TITLE 1036 "Choisissez le mode du reverse proxy :" +LangString MSG_HTTPS ${LANG_ENGLISH} "HTTPS" +LangString MSG_HTTPS ${LANG_FRENCH} "HTTPS" -LangString MSG_HTTP_ONLY 1033 "HTTP only" -LangString MSG_HTTP_ONLY 1036 "HTTP uniquement" +LangString MSG_DOMAIN_PING_FAIL ${LANG_FRENCH} "Le domaine '$0' ne repond pas au ping.$\r$\n$\r$\nCliquez sur Retry pour reessayer ce domaine, ou Cancel pour utiliser 'localhost'. Pour changer de domaine, cliquez sur Precedent." +LangString MSG_DOMAIN_PING_FAIL ${LANG_ENGLISH} "The domain '$0' did not respond to ping.$\r$\n$\r$\nClick Retry to try this domain again, or Cancel to use 'localhost'. To change domain, click Previous." -LangString MSG_HTTPS 1033 "HTTPS" -LangString MSG_HTTPS 1036 "HTTPS" +LangString CHOOSE_DISTRO_LABEL ${LANG_ENGLISH} "Choose the WSL Linux distribution to install:" +LangString CHOOSE_DISTRO_LABEL ${LANG_FRENCH} "Choisissez la distribution Linux WSL a installer :" -LangString MSG_DOMAIN_PING_FAIL 1036 "Le domaine '$0' ne repond pas au ping.$\r$\n$\r$\nCliquez sur Retry pour reessayer ce domaine, ou Cancel pour utiliser 'localhost'. Pour changer de domaine, cliquez sur Precedent." -LangString MSG_DOMAIN_PING_FAIL 1033 "The domain '$0' did not respond to ping.$\r$\n$\r$\nClick Retry to try this domain again, or Cancel to use 'localhost'. To change domain, click Previous." -LangString CHOOSE_DISTRO_LABEL 1033 "Choose the WSL Linux distribution to install:" -LangString CHOOSE_DISTRO_LABEL 1036 "Choisissez la distribution Linux WSL a installer :" +LangString ASK_DB_LABEL ${LANG_ENGLISH} "Installation finished. Do you want to use an external PostgreSQL database?" +LangString ASK_DB_LABEL ${LANG_FRENCH} "Installation terminée. Voulez-vous utiliser une base de donnees PostgreSQL externe ?" -LangString ASK_DB_LABEL 1033 "Installation finished. Do you want to use an external PostgreSQL database?" -LangString ASK_DB_LABEL 1036 "Installation terminée. Voulez-vous utiliser une base de donnees PostgreSQL externe ?" +LangString ASK_DB_YES ${LANG_ENGLISH} "Yes, configure an external database" +LangString ASK_DB_YES ${LANG_FRENCH} "Oui, configurer une base externe" -LangString ASK_DB_YES 1033 "Yes, configure an external database" -LangString ASK_DB_YES 1036 "Oui, configurer une base externe" +LangString ASK_DB_NO ${LANG_ENGLISH} "No, use local database (default)" +LangString ASK_DB_NO ${LANG_FRENCH} "Non, utiliser la base locale (par défaut)" -LangString ASK_DB_NO 1033 "No, use local database (default)" -LangString ASK_DB_NO 1036 "Non, utiliser la base locale (par défaut)" +LangString ENTER_DB_URL_LABEL ${LANG_ENGLISH} "Enter the external PostgreSQL URL (e.g.: postgresql://user:pass@host:5432/dbname):" +LangString ENTER_DB_URL_LABEL ${LANG_FRENCH} "Entrez l'URL PostgreSQL externe (ex:postgresql://user:pass@host:5432/dbname) :" -LangString ENTER_DB_URL_LABEL 1033 "Enter the external PostgreSQL URL (e.g.: postgresql://user:pass@host:5432/dbname):" -LangString ENTER_DB_URL_LABEL 1036 "Entrez l'URL PostgreSQL externe (ex:postgresql://user:pass@host:5432/dbname) :" +LangString DB_URL_REQUIRED ${LANG_ENGLISH} "You must enter a valid URL." +LangString DB_URL_REQUIRED ${LANG_FRENCH} "Vous devez entrer une URL valide." -LangString DB_URL_REQUIRED 1033 "You must enter a valid URL." -LangString DB_URL_REQUIRED 1036 "Vous devez entrer une URL valide." +LangString DB_CONN_OK ${LANG_ENGLISH} "External database configured successfully!" +LangString DB_CONN_OK ${LANG_FRENCH} "Base externe configuree avec succès !" -LangString DB_CONN_OK 1033 "External database configured successfully!" -LangString DB_CONN_OK 1036 "Base externe configuree avec succès !" +LangString DB_CONN_FAIL ${LANG_ENGLISH} "Connection to the database failed. Retry/modify URL or Cancel to use local." +LangString DB_CONN_FAIL ${LANG_FRENCH} "La connexion a la base a echoue. Reessayer/modifier l'URL ou Annuler pour rester en local." -LangString DB_CONN_FAIL 1033 "Connection to the database failed. Retry/modify URL or Cancel to use local." -LangString DB_CONN_FAIL 1036 "La connexion a la base a echoue. Reessayer/modifier l'URL ou Annuler pour rester en local." - -Function ProgressPage - nsDialogs::Create 1018 - Pop $0 - ${NSD_CreateLabel} 0 20u 100% 12u "Progress: 0%" - Pop $HWND_PROGRESS_LABEL - nsDialogs::Show -FunctionEnd - -Function ProgressPageLeave - ; Rien à faire ici, on laisse passer à la page suivante -FunctionEnd ; --- PAGE DISTRO --- -Function showPreWelcomeIfPhase1 - ${If} $PHASE1 == "1" - Return - ${Else} - Abort - ${EndIf} -FunctionEnd - Function DistroPage nsDialogs::Create 1018 Pop $0 @@ -319,50 +253,72 @@ Section "Install Taler-Merchant" File "test-db.sh" File "set-db.sh" - ; --- 1. Check flag reboot (phase 2 ou pas) --- - IfFileExists ${REBOOT_FLAG} after_reboot + FindWindow $0 "#32770" "" $HWNDPARENT + GetDlgItem $HWND_PROGRESS_LABEL $0 1006 - ; === PHASE 1 : Activation WSL ONLY === -DetailPrint "[PHASE 1] Enabling WSL and VirtualMachinePlatform..." -MessageBox MB_OK|MB_ICONINFORMATION $(MSG_STEP1) -nsExec::ExecToLog '"$INSTDIR\setup-wsl-debian.bat" 1' -Pop $0 + DetailPrint "---------------------------------------------------------" + DetailPrint "[1/8] Enabling WSL and VirtualMachinePlatform..." + SendMessage $HWND_PROGRESS_LABEL ${WM_SETTEXT} 0 "STR:Progress: 5%" + Sleep 2000 + + MessageBox MB_OK|MB_ICONINFORMATION $(MSG_STEP1) + + DetailPrint "[INFO] This is the slowest step. Please be patient." + SendMessage $HWND_PROGRESS_LABEL ${WM_SETTEXT} 0 "STR:Progress: 8%" + Sleep 5000 -IfFileExists ${REBOOT_FLAG} do_reboot -Goto after_reboot + DetailPrint "[INFO] Do NOT close the installer. The process will continue automatically." + SendMessage $HWND_PROGRESS_LABEL ${WM_SETTEXT} 0 "STR:Progress: 12%" + Sleep 5000 -do_reboot: - MessageBox MB_OK $(MSG_NEED_REBOOT) - Quit + DetailPrint "[INFO] Windows is still enabling the required features..." + SendMessage $HWND_PROGRESS_LABEL ${WM_SETTEXT} 0 "STR:Progress: 16%" + Sleep 5000 + + DetailPrint "[INFO] This is normal. Please wait, your system is working in the background." + SendMessage $HWND_PROGRESS_LABEL ${WM_SETTEXT} 0 "STR:Progress: 20%" + Sleep 5000 + + nsExec::ExecToLog '"$INSTDIR\setup-wsl-debian.bat" 1 "" $WSL_DISTRO' + Pop $0 + ${If} $0 != 0 + MessageBox MB_OK $(MSG_NEED_REBOOT) + Quit + ${EndIf} + + MessageBox MB_OK $(MSG_UPDATE_WSL) + + DetailPrint "[INFO] WSL and VirtualMachinePlatform are enabled. Checking for WSL updates..." + SendMessage $HWND_PROGRESS_LABEL ${WM_SETTEXT} 0 "STR:Progress: 30%" + DetailPrint "NOTICE: A black window may appear for the WSL update. If it does, simply press any key when prompted." + Sleep 1000 -after_reboot: - DetailPrint "[2/8] Installing $WSL_DISTRO..." - SendMessage $HWND_PROGRESS_LABEL ${WM_SETTEXT} 0 "STR:Progress: 15%" + SendMessage $HWND_PROGRESS_LABEL ${WM_SETTEXT} 0 "STR:Progress: 35%" Sleep 1000 DetailPrint "[3/8] Creating $WSL_DISTRO user..." - SendMessage $HWND_PROGRESS_LABEL ${WM_SETTEXT} 0 "STR:Progress: 25%" + SendMessage $HWND_PROGRESS_LABEL ${WM_SETTEXT} 0 "STR:Progress: 45%" Sleep 1000 DetailPrint "[4/8] Adding user to www-data group..." - SendMessage $HWND_PROGRESS_LABEL ${WM_SETTEXT} 0 "STR:Progress: 30%" + SendMessage $HWND_PROGRESS_LABEL ${WM_SETTEXT} 0 "STR:Progress: 55%" Sleep 1000 DetailPrint "[5/8] Copying installer script..." - SendMessage $HWND_PROGRESS_LABEL ${WM_SETTEXT} 0 "STR:Progress: 40%" + SendMessage $HWND_PROGRESS_LABEL ${WM_SETTEXT} 0 "STR:Progress: 60%" Sleep 1000 DetailPrint "[6/8] Converting script format and setting permissions..." - SendMessage $HWND_PROGRESS_LABEL ${WM_SETTEXT} 0 "STR:Progress: 45%" + SendMessage $HWND_PROGRESS_LABEL ${WM_SETTEXT} 0 "STR:Progress: 65%" Sleep 1000 DetailPrint "[7/8] Restarting WSL and launching installation..." - SendMessage $HWND_PROGRESS_LABEL ${WM_SETTEXT} 0 "STR:Progress: 60%" + SendMessage $HWND_PROGRESS_LABEL ${WM_SETTEXT} 0 "STR:Progress: 70%" nsExec::ExecToLog '"$INSTDIR\setup-wsl-debian.bat" ALL "" $WSL_DISTRO' DetailPrint "[8/8] Configuring reverse proxy for $DOMAIN_INPUT in $REVERSE_PROXY_MODE mode..." - SendMessage $HWND_PROGRESS_LABEL ${WM_SETTEXT} 0 "STR:Progress: 75%" + SendMessage $HWND_PROGRESS_LABEL ${WM_SETTEXT} 0 "STR:Progress: 80%" nsExec::ExecToLog '"$INSTDIR\setup-wsl-debian.bat" 8 $DOMAIN_INPUT $WSL_DISTRO $REVERSE_PROXY_MODE' DetailPrint "Testing access to merchant reverse proxy..." diff --git a/test/test.bat b/test/test.bat @@ -1,35 +0,0 @@ -@echo off -:: 🔍 Détection du bon wsl.exe (avec Sysnative support) -if exist "%SystemRoot%\Sysnative\wsl.exe" ( - set "WSL_CMD=%SystemRoot%\Sysnative\wsl.exe" -) else ( - set "WSL_CMD=%SystemRoot%\System32\wsl.exe" -) - -:: 1. Activer WSL et plateforme VM (admin requis) -dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart >nul 2>&1 -dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart >nul 2>&1 - -echo Si un redémarrage est requis, fais-le puis relance le script. - -:: 2. Définir WSL2 par défaut + installer Debian -"%WSL_CMD%" --set-default-version 2 -"%WSL_CMD%" --install -d Debian --no-launch - -:: 3. Initialiser root -timeout /t 5 >nul -"%WSL_CMD%" -d Debian --user root -- bash -lc "echo 'root:root' | chpasswd" - -:: 4. Créer newuser + sudo sans mot de passe -"%WSL_CMD%" -d Debian --user root -- bash -lc "useradd -m -s /bin/bash newuser && passwd -d newuser" -"%WSL_CMD%" -d Debian --user root -- bash -lc "adduser newuser sudo" -"%WSL_CMD%" -d Debian --user root -- bash -lc "echo 'newuser ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers" - -:: 5. Définir newuser comme utilisateur par défaut -"%WSL_CMD%" -d Debian --user root -- bash -lc "echo '[user]' > /etc/wsl.conf" -"%WSL_CMD%" -d Debian --user root -- bash -lc "echo 'default=newuser' >> /etc/wsl.conf" - -:: 6. Finaliser -"%WSL_CMD%" -d Debian -- echo "✅ Installation terminée, newuser créé." - -exit /b 0 diff --git a/test/test.nsi b/test/test.nsi @@ -1,19 +0,0 @@ -Name "Install Debian WSL Script" -OutFile "InstallDebianWSL.exe" -RequestExecutionLevel admin - -InstallDir "$TEMP\WSLInstall" -Page instfiles - -; 🚫 Ne mets rien ici dans l'espace global - -Section "Exécution silencieuse" - SetOutPath "$INSTDIR" - File "test.bat" - - ; Lance le batch sans fenêtre visible - nsExec::Exec '"$INSTDIR\test.bat"' - Pop $0 - - DetailPrint "Le script BAT s’est terminé avec le code : $0" -SectionEnd diff --git a/test/test/rootfs.text b/test/test/rootfs.text diff --git a/test/test/test.bat b/test/test/test.bat @@ -1,31 +0,0 @@ -@echo off -setlocal - -REM 2️⃣ Installer Debian si besoin, puis mettre à jour WSL -wsl --list --online | findstr /i "Debian" >nul || wsl --update -wsl -l -v | findstr /i "Debian" >nul || wsl --install -d Debian - -REM 3️⃣ Génération d’un nom d’utilisateur aléatoire -set USERNAME=dev%RANDOM% - -REM 4️⃣ Créer un script shell temporaire pour l’instance Debian -set SCRIPTSH=%TEMP%\wsl_init.sh -( - echo #!/bin/bash - echo set -e - echo adduser --disabled-password --gecos "" %USERNAME% - echo usermod -aG sudo %USERNAME% -)>"%SCRIPTSH%" - -REM 5️⃣ Injecter et exécuter le script dans Debian -wsl -d Debian -- bash -c "cat > /root/init.sh" < "%SCRIPTSH%" -wsl -d Debian -- bash -c "chmod +x /root/init.sh && /root/init.sh" - -REM 6️⃣ Définir l’utilisateur par défaut via commande WSL -wsl --manage Debian --set-default-user %USERNAME% 2>nul - -REM 7️⃣ Final : nettoyage et confirmation -del "%SCRIPTSH%" -echo. -echo ✅ Debian est installée avec l’utilisateur "%USERNAME%" configuré comme défaut ! -pause -\ No newline at end of file