taler-windows

Windows packaging
Log | Files | Refs

commit aa2d6e34829953dd49221c258ba02cd5a0c43911
parent 34e7157c1a2c25517aceab9a62a3c5f34d81a50d
Author: Leayawi <lea.oualli@outlook.fr>
Date:   Sun, 29 Jun 2025 21:35:07 +0200

Ajout de l'installateur avec correction

Diffstat:
Minstall-taler-from-apt.sh | 75++++++++++++++++++++++++++++++++-------------------------------------------
Mlogo-header.bmp | 0
Mlogo-welcome.bmp | 0
Msetup-wsl-debian.bat | 160+++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------
Mtaler-installer-taler.nsi | 297++++++++++++++++++++++++++++++++++++++++++++++---------------------------------
Atest/test.bat | 35+++++++++++++++++++++++++++++++++++
Atest/test.nsi | 19+++++++++++++++++++
Atest/test/rootfs.text | 0
Atest/test/test.bat | 32++++++++++++++++++++++++++++++++
9 files changed, 396 insertions(+), 222 deletions(-)

diff --git a/install-taler-from-apt.sh b/install-taler-from-apt.sh @@ -7,62 +7,46 @@ set -e set -x trap 'echo "Error occurred on line $LINENO." >&2' ERR -exec > >(tee -a /tmp/install-output.log) 2>&1 -mkdir -p /home/taleruser/taler-installer -echo "ARGS: $1 $2 $3 $4" >> /home/taleruser/taler-installer/install.log +LOGFILE="/mnt/c/Users/Public/taler-sh.log" +exec > >(tee -a "$LOGFILE") 2>&1 + +mkdir -p /home/taleruser/taler-installer WSL_USER="taleruser" TALER_DB_USER="taler-merchant-httpd" ############################################# # -------- HTTPS / Reverse Proxy -----------# -# Utilisation : ./install-taler-from-apt.sh 8 <domain> <distro> <proxy_mode> +############################################# +# Si le script est appelé avec "8" et un domaine, on ne fait QUE la config HTTPS/proxy : if [ "$1" = "8" ] && [ -n "$2" ]; then - PROXY_MODE="$4" # "HTTPS" ou "HTTP" DOMAIN="$2" - - # Auto: si c'est localhost ou un domaine local, prends Apache ; sinon Nginx - if [[ "$DOMAIN" == "localhost" || "$DOMAIN" == *.local ]]; then - PROXY_TYPE="APACHE" - else - PROXY_TYPE="NGINX" + echo "Configuring HTTPS reverse proxy for domain: $DOMAIN" + if ! sudo taler-merchant-rproxy-setup --acme --merchant-url="https://$DOMAIN:8888/"; then + echo "WARNING: Impossible d’obtenir un certificat HTTPS valide pour $DOMAIN (vérifie le DNS, les ports 80/443, et Internet)" | tee -a "/home/$WSL_USER/taler-installer/install-sh.log" + # On ne bloque pas toute l'install, on log juste le problème + exit 0 fi + echo "HTTPS reverse proxy configured for $DOMAIN" | tee -a "/home/$WSL_USER/taler-installer/install-sh.log" + exit 0 +fi +############################################# - echo "Configuring reverse proxy for $DOMAIN (mode: $PROXY_MODE, proxy: $PROXY_TYPE)" - - if [ "$PROXY_MODE" = "HTTPS" ]; then - if [ "$PROXY_TYPE" = "APACHE" ]; then - if ! sudo taler-merchant-rproxy-setup --domain "$DOMAIN" --apache; then - echo "WARNING: Unable to get valid HTTPS certificate for $DOMAIN (Apache)" | tee -a "/home/$WSL_USER/taler-installer/install.log" - exit 0 - fi - echo "HTTPS reverse proxy configured for $DOMAIN (Apache)" | tee -a "/home/$WSL_USER/taler-installer/install.log" - else - if ! sudo taler-merchant-rproxy-setup --domain "$DOMAIN" --nginx; then - echo "WARNING: Unable to get valid HTTPS certificate for $DOMAIN (Nginx)" | tee -a "/home/$WSL_USER/taler-installer/install.log" - exit 0 - fi - echo "HTTPS reverse proxy configured for $DOMAIN (Nginx)" | tee -a "/home/$WSL_USER/taler-installer/install.log" - fi - else # HTTP only - if [ "$PROXY_TYPE" = "APACHE" ]; then - if ! sudo taler-merchant-rproxy-setup --domain "$DOMAIN" --apache; then - echo "WARNING: Unable to configure HTTP proxy for $DOMAIN (Apache)" | tee -a "/home/$WSL_USER/taler-installer/install.log" - exit 0 - fi - echo "HTTP reverse proxy configured for $DOMAIN (Apache, no SSL)" | tee -a "/home/$WSL_USER/taler-installer/install.log" - else - if ! sudo taler-merchant-rproxy-setup --domain "$DOMAIN" --nginx; then - echo "WARNING: Unable to configure HTTP proxy for $DOMAIN (Nginx)" | tee -a "/home/$WSL_USER/taler-installer/install.log" - exit 0 - fi - echo "HTTP reverse proxy configured for $DOMAIN (Nginx, no SSL)" | tee -a "/home/$WSL_USER/taler-installer/install.log" - fi +############################################# +# ---- HTTP ONLY / Reverse Proxy HTTP ------# +############################################# +if [ "$1" = "http" ] && [ -n "$2" ]; then + DOMAIN="$2" + echo "Configuring HTTP-only reverse proxy for domain: $DOMAIN" + if ! sudo taler-merchant-rproxy-setup --domain "$DOMAIN" --httponly --apache; then + echo "WARNING: Echec configuration HTTP-only reverse proxy pour $DOMAIN" | tee -a "/home/$WSL_USER/taler-installer/install-sh.log" + exit 1 fi - + echo "HTTP-only reverse proxy configured for $DOMAIN" | tee -a "/home/$WSL_USER/taler-installer/install-sh.log" exit 0 fi +############################################# # Vérification de l'utilisateur système @@ -154,4 +138,9 @@ sudo systemctl status taler-merchant-httpd.socket --no-pager || true mkdir -p "/home/$WSL_USER/taler-installer" sudo chown -R "$WSL_USER:$WSL_USER" "/home/$WSL_USER/taler-installer" -echo "GNU Taler-Merchant installed successfully via system config" | tee "/home/$WSL_USER/taler-installer/install.log" +echo "GNU Taler-Merchant installed successfully via system config" | tee "/home/$WSL_USER/taler-installer/install-sh.log" + +echo "[`date '+%F %T'`] === END OF taler-sh.log ===" + + + diff --git a/logo-header.bmp b/logo-header.bmp Binary files differ. diff --git a/logo-welcome.bmp b/logo-welcome.bmp Binary files differ. diff --git a/setup-wsl-debian.bat b/setup-wsl-debian.bat @@ -15,9 +15,14 @@ :: :: Author: Léa Oualli -@echo off -echo %* > C:\Users\Public\debug_args.txt setlocal enabledelayedexpansion + +REM -------------------------- LOGFILE GLOBALE --------------------------- +set LOGFILE=C:\Users\Public\taler-bat.log + +echo [%DATE% %TIME%] === [START] GNU Taler-Merchant Installer === > %LOGFILE% +echo [%DATE% %TIME%] Arguments : STEP="%1" DOMAIN="%2" DISTRO="%3" PROXY_MODE="%4" >> %LOGFILE% + set WSL_USER=taleruser set STEP=%1 set DOMAIN=%2 @@ -34,6 +39,8 @@ if "%DISTRO%"=="" ( set DISTRO=Debian ) +echo [%DATE% %TIME%] Initial STEP="%STEP%", DOMAIN="%DOMAIN%", DISTRO="%DISTRO%", PROXY_MODE="%PROXY_MODE%" >> %LOGFILE% + if "%STEP%"=="1" goto step1 if "%STEP%"=="2" goto step2 if "%STEP%"=="3" goto step3 @@ -44,7 +51,7 @@ if "%STEP%"=="7" goto step7 if "%STEP%"=="8" goto step8 :step1 -echo [1/8] Checking if WSL and VirtualMachinePlatform are enabled... +echo [%DATE% %TIME%] [1/8] Checking WSL and VirtualMachinePlatform... >> %LOGFILE% :: Check if WSL is enabled powershell -Command "(Get-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux).State" | find /I "Enabled" >nul @@ -54,33 +61,34 @@ powershell -Command "(Get-WindowsOptionalFeature -Online -FeatureName VirtualMac set VMP_ENABLED=%errorlevel% if %WSL_ENABLED% equ 0 ( - echo WSL is already enabled. + echo [%DATE% %TIME%] WSL already enabled. >> %LOGFILE% ) else ( - echo Enabling WSL feature... + echo [%DATE% %TIME%] Enabling WSL feature... >> %LOGFILE% powershell.exe -Command "Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux -NoRestart" set NEED_REBOOT=1 ) if %VMP_ENABLED% equ 0 ( - echo VirtualMachinePlatform is already enabled. + echo [%DATE% %TIME%] VirtualMachinePlatform already enabled. >> %LOGFILE% ) else ( - echo Enabling VirtualMachinePlatform feature... + echo [%DATE% %TIME%] Enabling VirtualMachinePlatform feature... >> %LOGFILE% powershell.exe -Command "Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform -NoRestart" set NEED_REBOOT=1 ) if defined NEED_REBOOT ( - echo. + 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 ) else ( - echo [INFO] WSL and VirtualMachinePlatform are ready. + echo [%DATE% %TIME%] [INFO] WSL and VirtualMachinePlatform are ready. >> %LOGFILE% ) if not "%STEP%"=="ALL" exit /b -echo [INFO] Updating WSL to the latest version if needed... +echo [%DATE% %TIME%] Updating WSL to the latest version if needed... >> %LOGFILE% echo [INFO] If a black window appears, please press any key when prompted, then wait until the window closes automatically. echo [INFO] The installation will continue automatically after the update. timeout /t 3 /nobreak @@ -91,26 +99,50 @@ start /wait "" %WSL% --update if not "%STEP%"=="ALL" exit /b :step2 -echo [2/8] Installing %DISTRO%... +echo [%DATE% %TIME%] [2/8] Installing %DISTRO%... >> %LOGFILE% %WSL% --install -d %DISTRO% -timeout /t 20 /nobreak -echo Initializing %DISTRO% first launch... + +echo [%DATE% %TIME%] Initializing %DISTRO% first launch... >> %LOGFILE% %WSL% -d %DISTRO% -- bash -c "echo %DISTRO% ready" if not "%STEP%"=="ALL" exit /b :step3 -echo [3/8] Creating %DISTRO% user if needed... -%WSL% -d %DISTRO% -- bash -c "id %WSL_USER% >/dev/null 2>&1 || (sudo useradd -m %WSL_USER% && echo '%WSL_USER% ALL=(ALL) NOPASSWD:ALL' | sudo tee -a /etc/sudoers)" +echo [%DATE% %TIME%] [3/8] Creating Debian user if needed... >> %LOGFILE% +echo [%DATE% %TIME%] DISTRO="%DISTRO%", WSL_USER="%WSL_USER%" >> %LOGFILE% +%WSL% -d %DISTRO% -- bash -c "id %WSL_USER% >/dev/null 2>&1 || sudo useradd -m %WSL_USER%" + +echo [%DATE% %TIME%] Waiting for user "%WSL_USER%" to be present... >> %LOGFILE% +:wait_for_taleruser +%WSL% -d %DISTRO% -- bash -c "id %WSL_USER%" >nul 2>&1 +if %errorlevel% neq 0 ( + timeout /t 2 >nul + goto wait_for_taleruser +) +echo [%DATE% %TIME%] User "%WSL_USER%" exists in Debian! >> %LOGFILE% + +%WSL% -d %DISTRO% -- bash -c "echo '%WSL_USER% ALL=(ALL) NOPASSWD:ALL' | sudo tee /etc/sudoers.d/%WSL_USER%" +%WSL% -d %DISTRO% -- bash -c "sudo chmod 0440 /etc/sudoers.d/%WSL_USER%" +echo [%DATE% %TIME%] Sudoers file updated. >> %LOGFILE% if not "%STEP%"=="ALL" exit /b +REM Nettoie /etc/wsl.conf avant d’ajouter +%WSL% -d %DISTRO% -- bash -c "sudo sed -i '/^\[user\]/d;/^default *=/d' /etc/wsl.conf" +%WSL% -d %DISTRO% -- bash -c "echo -e '[user]\ndefault = %WSL_USER%' | sudo tee -a /etc/wsl.conf > /dev/null" +echo [%DATE% %TIME%] wsl.conf set default user. >> %LOGFILE% + +:: Pour appliquer immédiatement, termine la distro : +%WSL% --terminate %DISTRO% +echo [%DATE% %TIME%] Distro %DISTRO% terminated for user change. >> %LOGFILE% + :step4 -echo [4/8] Adding user to www-data group... +echo [%DATE% %TIME%] [4/8] Adding user to www-data group... >> %LOGFILE%echo [DEBUG] DISTRO="%DISTRO%", WSL_USER="%WSL_USER%", DOMAIN="%DOMAIN%" >> %LOGFILE% %WSL% -d %DISTRO% -- bash -c "sudo usermod -aG www-data %WSL_USER% || echo 'Warning: Could not add user to www-data (might already be a member)'" +echo [%DATE% %TIME%] User %WSL_USER% added to www-data (or already a member). >> %LOGFILE% if not "%STEP%"=="ALL" exit /b :step5 -REM -------Copy the following script ------- +echo [%DATE% %TIME%] [5/8] Preparing and copying scripts... >> %LOGFILE% REM 1. Installer dos2unix (si pas déjà installé) %WSL% -d %DISTRO% -- bash -c "sudo apt-get update && sudo apt-get install -y dos2unix" @@ -132,6 +164,7 @@ REM 5. copy the script into WSL (via tee) type "%TEMP%\install-taler-from-apt.sh" | %WSL% -d %DISTRO% -- bash -c "sudo tee /home/%WSL_USER%/taler-installer/install-taler-from-apt.sh > /dev/null" type "%TEMP%\test-db.sh" | %WSL% -d %DISTRO% -- bash -c "sudo tee /home/%WSL_USER%/taler-installer/test-db.sh > /dev/null" type "%TEMP%\set-db.sh" | %WSL% -d %DISTRO% -- bash -c "sudo tee /home/%WSL_USER%/taler-installer/set-db.sh > /dev/null" +echo [%DATE% %TIME%] Scripts copied to WSL. >> %LOGFILE% REM 6. Convert all the scripts into UNIX format %WSL% -d %DISTRO% -- bash -c "sudo dos2unix /home/%WSL_USER%/taler-installer/*.sh" @@ -144,7 +177,7 @@ REM ---------------------------------------------------------------------------- if not "%STEP%"=="ALL" exit /b :step6 -echo [6/8] Checks permissions... +echo [%DATE% %TIME%] [6/8] Checks permissions... >> %LOGFILE% REM Check the version dos2unix (pour debug) %WSL% -d %DISTRO% -- bash -c "dos2unix --version" @@ -159,62 +192,77 @@ REM Vérifier les droits d'exécution %WSL% -d %DISTRO% -- bash -c "ls -l /home/%WSL_USER%/taler-installer/*.sh" REM Fin du step -echo [6/8] Verifications finished - +echo [%DATE% %TIME%] Scripts verified (permissions/format/headers). >> %LOGFILE% if not "%STEP%"=="ALL" exit /b :step7 -echo [7/8] Restarting WSL... +echo [%DATE% %TIME%] [7/8] Restarting WSL... >> %LOGFILE% +echo [DEBUG] DISTRO="%DISTRO%" >> %LOGFILE% %WSL% --shutdown timeout /t 3 -echo Running final installation script... -%WSL% -d %DISTRO% -- bash -c "sudo -u %WSL_USER% bash /home/%WSL_USER%/taler-installer/install-taler-from-apt.sh | tee /home/%WSL_USER%/taler-installer/install.log" -%WSL% -d %DISTRO% -- bash -c "sudo cp /home/%WSL_USER%/taler-installer/install.log /mnt/c/Users/Public/install.log" +echo [%DATE% %TIME%] Running final installation script... >> %LOGFILE% +%WSL% -d %DISTRO% -- bash -c "sudo -u %WSL_USER% bash /home/%WSL_USER%/taler-installer/install-taler-from-apt.sh | tee /home/%WSL_USER%/taler-installer/install-bat.log" +%WSL% -d %DISTRO% -- bash -c "sudo cp /home/%WSL_USER%/taler-installer/install-bat.log /mnt/c/Users/Public/install-bat.log" +echo [%DATE% %TIME%] Final install script run, log copied to Windows. >> %LOGFILE% if not "%STEP%"=="ALL" exit /b :step8 -echo [8/8] Configuring reverse proxy... +echo [%DATE% %TIME%] [8/8] Configuring reverse proxy... >> %LOGFILE% +echo [%DATE% %TIME%] DISTRO="%DISTRO%", DOMAIN="%DOMAIN%", PROXY_MODE="%PROXY_MODE%" >> %LOGFILE% + +echo [%DATE% %TIME%] --- Démarrage configuration reverse proxy --- >> %LOGFILE% if "%DOMAIN%"=="" ( set DOMAIN=localhost + echo [%DATE% %TIME%] Domaine vide, fallback sur localhost >> %LOGFILE% ) -REM --- Détection du type de proxy (Apache ou Nginx) --- -set PROXY_TYPE=NGINX -if /I "%DOMAIN%"=="localhost" set PROXY_TYPE=APACHE -if /I "%DOMAIN:~-6%"==".local" set PROXY_TYPE=APACHE - -if /I "%PROXY_MODE%"=="HTTPS" ( - if /I "%PROXY_TYPE%"=="APACHE" ( - echo Setting up HTTPS with Let's Encrypt (Apache) for %DOMAIN% ... - %WSL% -d %DISTRO% -- bash -c "sudo taler-merchant-rproxy-setup --domain %DOMAIN% --apache" - ) else ( - echo Setting up HTTPS with Let's Encrypt (Nginx) for %DOMAIN% ... - %WSL% -d %DISTRO% -- bash -c "sudo taler-merchant-rproxy-setup --domain %DOMAIN% --nginx" - ) -) else ( - if /I "%PROXY_TYPE%"=="APACHE" ( - echo Setting up HTTP only (Apache) for %DOMAIN% ... - %WSL% -d %DISTRO% -- bash -c "sudo taler-merchant-rproxy-setup --domain %DOMAIN% --apache --httponly" - ) else ( - echo Setting up HTTP only (Nginx) for %DOMAIN% ... - %WSL% -d %DISTRO% -- bash -c "sudo taler-merchant-rproxy-setup --domain %DOMAIN% --nginx --httponly" - ) +if "%PROXY_MODE%"=="" ( + set PROXY_MODE=http + echo [%DATE% %TIME%] Mode proxy vide, fallback sur HTTP >> %LOGFILE% ) -REM Démarrer le bon service -if /I "%PROXY_TYPE%"=="APACHE" ( - %WSL% -d %DISTRO% -- bash -c "sudo service apache2 start" - REM Planifie Apache au démarrage WSL (optionnel) - powershell -Command "Register-ScheduledTask -Action (New-ScheduledTaskAction -Execute '%WINDIR%\System32\wsl.exe' -Argument '-d %DISTRO% -- bash -c \"sudo service apache2 start && while true; do sleep 3600; done\"') -Trigger (New-ScheduledTaskTrigger -AtLogOn) -TaskName 'StartTalerApacheWSL' -User '$env:USERNAME' -RunLevel Highest -Force" +REM Installe Apache (dans tous les cas) +echo [%DATE% %TIME%] Installation Apache2... >> %LOGFILE% +%WSL% -d %DISTRO% -- bash -c "sudo apt-get update && sudo apt-get install -y apache2" >> %LOGFILE% 2>&1 + +if /I "%PROXY_MODE%"=="https" ( + echo [%DATE% %TIME%] Mode HTTPS sélectionné pour %DOMAIN% >> %LOGFILE% + echo [%DATE% %TIME%] Setting up HTTPS with Let's Encrypt for %DOMAIN% ... >> %LOGFILE% + %WSL% -d %DISTRO% -- bash -c "sudo taler-merchant-rproxy-setup --acme --merchant-url='https://%DOMAIN%:8888/' --apache" >> %LOGFILE% 2>&1 + set CERT_STATUS=%errorlevel% + echo [%DATE% %TIME%] HTTPS return code : %CERT_STATUS% >> %LOGFILE% + if not %CERT_STATUS%==0 ( + echo [%DATE% %TIME%] [ERREUR] Certificat HTTPS échec pour %DOMAIN% >> %LOGFILE% + echo [ERREUR] Impossible d’obtenir un certificat HTTPS valide pour %DOMAIN%. + echo [ERREUR] Veuillez vérifier que le domaine pointe bien sur cette machine et soit accessible publiquement. + timeout /t 5 /nobreak + ) ) else ( - %WSL% -d %DISTRO% -- bash -c "sudo service nginx start" - REM (Optionnel : tu peux planifier nginx ici) + echo [%DATE% %TIME%] Mode HTTP sélectionné pour %DOMAIN% >> %LOGFILE% + echo [%DATE% %TIME%] Setting up HTTP only for %DOMAIN% ... >> %LOGFILE% + %WSL% -d %DISTRO% -- bash -c "sudo taler-merchant-rproxy-setup --domain %DOMAIN% --httponly --apache" >> %LOGFILE% 2>&1 + echo [%DATE% %TIME%] HTTP only proxy finished for %DOMAIN% >> %LOGFILE% ) +echo [%DATE% %TIME%] --- Fin configuration reverse proxy --- >> %LOGFILE% + + echo. -echo [INFO] Installation terminee. La fenetre se fermera dans 30 secondes... -timeout /t 120 /nobreak >nul -exit /b +echo Verifying domain configured in Apache... +%WSL% -d %DISTRO% -- bash -c "grep 'ServerName' /etc/apache2/sites-available/taler-merchant.conf || echo 'ServerName not found!'" + +REM Start Apache service +%WSL% -d %DISTRO% -- bash -c "sudo service apache2 start" + +REM Scheduled task (on next boot): Apache will start automatically +powershell -Command "Register-ScheduledTask -Action (New-ScheduledTaskAction -Execute '%WINDIR%\System32\wsl.exe' -Argument '-d %DISTRO% -- bash -c \"sudo service apache2 start && while true; do sleep 3600; done\"') -Trigger (New-ScheduledTaskTrigger -AtLogOn) -TaskName 'StartTalerApacheWSL' -User '$env:USERNAME' -RunLevel Highest -Force" +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,6 +16,8 @@ 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" @@ -30,11 +32,45 @@ 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 @@ -56,74 +92,104 @@ 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 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 the domain name:" -LangString ENTER_DOMAIN ${LANG_FRENCH} "Entrez le nom de domaine :" +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 @@ -200,46 +266,48 @@ Function DomainPageLeave ${EndIf} FunctionEnd -; --- PAGE REVERSE PROXY --- Function ReverseProxyPage - nsDialogs::Create 1018 - Pop $0 - ${If} $0 == error - Abort - ${EndIf} - ${NSD_CreateLabel} 0 10u 100% 12u $(MSG_REVERSE_PROXY_TITLE) - Pop $0 - - ${NSD_CreateRadioButton} 0 30u 100% 12u $(MSG_HTTP_ONLY) - Pop $RADIO_HTTP_ONLY - - ; Si domaine = localhost, griser/desactiver HTTPS et forcer HTTP - ${NSD_CreateRadioButton} 0 45u 100% 12u $(MSG_HTTPS) - Pop $RADIO_HTTPS - - ${NSD_GetText} $DOMAIN_INPUT $1 - ${If} $1 == "localhost" - EnableWindow $RADIO_HTTPS 0 - ${NSD_SetState} $RADIO_HTTP_ONLY 1 - ${NSD_SetState} $RADIO_HTTPS 0 - ${Else} - ${NSD_SetState} $RADIO_HTTPS 1 - ${EndIf} - nsDialogs::Show + nsDialogs::Create 1018 + Pop $0 + ${If} $0 == error + Abort + ${EndIf} + + ${NSD_CreateLabel} 0 10u 100% 12u $(MSG_REVERSE_PROXY_TITLE) + Pop $0 + + ${NSD_CreateRadioButton} 0 30u 100% 12u $(MSG_HTTP_ONLY) + Pop $RADIO_HTTP_ONLY + + ${NSD_CreateRadioButton} 0 45u 100% 12u $(MSG_HTTPS) + Pop $RADIO_HTTPS + + ; Récupère la valeur du domaine + ${NSD_GetText} $DOMAIN_INPUT $1 + + ${If} $1 == "localhost" + ; HTTPS grisé, HTTP sélectionné + EnableWindow $RADIO_HTTPS 0 + ${NSD_SetState} $RADIO_HTTP_ONLY 1 + ${NSD_SetState} $RADIO_HTTPS 0 + ${Else} + ; Les deux actifs, HTTPS sélectionné par défaut + EnableWindow $RADIO_HTTP_ONLY 1 + EnableWindow $RADIO_HTTPS 1 + ${NSD_SetState} $RADIO_HTTPS 1 + ${NSD_SetState} $RADIO_HTTP_ONLY 0 + ${EndIf} + + nsDialogs::Show FunctionEnd Function ReverseProxyPageLeave - ${NSD_GetState} $RADIO_HTTP_ONLY $0 - ${If} $0 == 1 - StrCpy $REVERSE_PROXY_MODE "HTTP" - ${EndIf} - ${NSD_GetState} $RADIO_HTTPS $0 - ${If} $0 == 1 - StrCpy $REVERSE_PROXY_MODE "HTTPS" - ${EndIf} - ${If} $REVERSE_PROXY_MODE == "" - StrCpy $REVERSE_PROXY_MODE "HTTPS" - ${EndIf} + ${NSD_GetState} $RADIO_HTTP_ONLY $0 + ${If} $0 == 1 + StrCpy $REVERSE_PROXY_MODE "http" + ${Else} + StrCpy $REVERSE_PROXY_MODE "https" + ${EndIf} FunctionEnd ; -------- SECTION INSTALL PRINCIPALE -------- @@ -251,73 +319,51 @@ Section "Install Taler-Merchant" File "test-db.sh" File "set-db.sh" - FindWindow $0 "#32770" "" $HWNDPARENT - GetDlgItem $HWND_PROGRESS_LABEL $0 1006 - - 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) + ; --- 1. Check flag reboot (phase 2 ou pas) --- + IfFileExists ${REBOOT_FLAG} after_reboot - DetailPrint "[INFO] This is the slowest step. Please be patient." - SendMessage $HWND_PROGRESS_LABEL ${WM_SETTEXT} 0 "STR:Progress: 8%" - Sleep 5000 + ; === 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 "[INFO] Do NOT close the installer. The process will continue automatically." - SendMessage $HWND_PROGRESS_LABEL ${WM_SETTEXT} 0 "STR:Progress: 12%" - Sleep 5000 +IfFileExists ${REBOOT_FLAG} do_reboot +Goto after_reboot - 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 +do_reboot: + MessageBox MB_OK $(MSG_NEED_REBOOT) + Quit +after_reboot: + DetailPrint "[2/8] Installing $WSL_DISTRO..." - SendMessage $HWND_PROGRESS_LABEL ${WM_SETTEXT} 0 "STR:Progress: 35%" + SendMessage $HWND_PROGRESS_LABEL ${WM_SETTEXT} 0 "STR:Progress: 15%" Sleep 1000 DetailPrint "[3/8] Creating $WSL_DISTRO user..." - SendMessage $HWND_PROGRESS_LABEL ${WM_SETTEXT} 0 "STR:Progress: 45%" + SendMessage $HWND_PROGRESS_LABEL ${WM_SETTEXT} 0 "STR:Progress: 25%" Sleep 1000 DetailPrint "[4/8] Adding user to www-data group..." - SendMessage $HWND_PROGRESS_LABEL ${WM_SETTEXT} 0 "STR:Progress: 55%" + SendMessage $HWND_PROGRESS_LABEL ${WM_SETTEXT} 0 "STR:Progress: 30%" Sleep 1000 DetailPrint "[5/8] Copying installer script..." - SendMessage $HWND_PROGRESS_LABEL ${WM_SETTEXT} 0 "STR:Progress: 60%" + SendMessage $HWND_PROGRESS_LABEL ${WM_SETTEXT} 0 "STR:Progress: 40%" Sleep 1000 DetailPrint "[6/8] Converting script format and setting permissions..." - SendMessage $HWND_PROGRESS_LABEL ${WM_SETTEXT} 0 "STR:Progress: 65%" + SendMessage $HWND_PROGRESS_LABEL ${WM_SETTEXT} 0 "STR:Progress: 45%" Sleep 1000 DetailPrint "[7/8] Restarting WSL and launching installation..." - SendMessage $HWND_PROGRESS_LABEL ${WM_SETTEXT} 0 "STR:Progress: 70%" + SendMessage $HWND_PROGRESS_LABEL ${WM_SETTEXT} 0 "STR:Progress: 60%" 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: 80%" - nsExec::ExecToLog '"$INSTDIR\setup-wsl-debian.bat" 8 "$DOMAIN_INPUT" "$WSL_DISTRO" "$REVERSE_PROXY_MODE"' + SendMessage $HWND_PROGRESS_LABEL ${WM_SETTEXT} 0 "STR:Progress: 75%" + nsExec::ExecToLog '"$INSTDIR\setup-wsl-debian.bat" 8 $DOMAIN_INPUT $WSL_DISTRO $REVERSE_PROXY_MODE' DetailPrint "Testing access to merchant reverse proxy..." nsExec::ExecToLog 'wsl -d $WSL_DISTRO -- bash -c "curl -v http://localhost"' @@ -413,7 +459,12 @@ FunctionEnd ; ---- PAGE FINISH : open browser ---- Function .onGUIEnd MessageBox MB_OK|MB_ICONINFORMATION "Installation is complete! Your browser will now open your domain." - ${If} $REVERSE_PROXY_MODE == "HTTPS" + +; Force WSL à démarrer Apache AVANT le navigateur +nsExec::ExecToLog 'wsl -d $WSL_DISTRO -- bash -c "sudo service apache2 restart"' +Sleep 2000 + + ${If} $REVERSE_PROXY_MODE == "https" ExecShell "open" "https://$DOMAIN_INPUT" ${Else} ExecShell "open" "http://$DOMAIN_INPUT" diff --git a/test/test.bat b/test/test.bat @@ -0,0 +1,35 @@ +@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 @@ -0,0 +1,19 @@ +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 @@ -0,0 +1,31 @@ +@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