commit cc04ea54dc6a2201383db8bfedd5875a8610f5f6
parent 72e5fd7b1da5137be6eecf3aec607b4bb30d81fe
Author: Leayawi <lea.oualli@outlook.fr>
Date: Wed, 18 Jun 2025 13:17:04 +0200
Add installer scripts, setup files and images for GNU Taler
Diffstat:
7 files changed, 303 insertions(+), 221 deletions(-)
diff --git a/install-taler-from-apt.sh b/install-taler-from-apt.sh
@@ -2,43 +2,66 @@
# This file is part of GNU Taler.
# Copyright (C) 2025 Taler Systems SA
#
-# TALER is free software; you can redistribute it and/or modify it under the
-# terms of the GNU Lesser General Public License as published by the Free Software
-# Foundation; either version 2.1, or (at your option) any later version.
-#
-# TALER is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public License along with
-# TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
-#
# Author: Léa Oualli
set -e
set -x
trap 'echo "Error occurred on line $LINENO." >&2' ERR
exec > >(tee -a /tmp/install-output.log) 2>&1
+echo "ARGS: $1 $2 $3 $4" >> /home/taleruser/taler-installer/install.log
+
WSL_USER="taleruser"
TALER_DB_USER="taler-merchant-httpd"
#############################################
# -------- HTTPS / Reverse Proxy -----------#
-#############################################
-# Si le script est appelé avec "8" et un domaine, on ne fait QUE la config HTTPS/proxy :
+# Utilisation : ./install-taler-from-apt.sh 8 <domain> <distro> <proxy_mode>
if [ "$1" = "8" ] && [ -n "$2" ]; then
+ PROXY_MODE="$4" # "HTTPS" ou "HTTP"
DOMAIN="$2"
- 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.log"
- # On ne bloque pas toute l'install, on log juste le problème
- exit 0
+
+ # 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"
fi
- echo "HTTPS reverse proxy configured for $DOMAIN" | tee -a "/home/$WSL_USER/taler-installer/install.log"
+
+ 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
+ if [ "$PROXY_TYPE" = "APACHE" ]; then
+ if ! sudo taler-merchant-rproxy-setup --domain "$DOMAIN" --apache --no-certbot; 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 --no-certbot; 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
+ fi
+
exit 0
fi
-#############################################
# Vérification de l'utilisateur système
if ! id "$WSL_USER" &>/dev/null; then
@@ -98,6 +121,11 @@ sudo apt-get install -y taler-merchant || {
exit 1
}
+sudo apt-get install -y certbot python3-certbot-nginx || {
+ echo "Certbot installation failed." >&2
+ exit 1
+}
+
echo "Creating /etc/taler/merchant.conf..."
sudo mkdir -p /etc/taler
echo "[merchant]
diff --git a/readme.txt b/readme.txt
@@ -1,86 +0,0 @@
-GNU Taler-Merchant Backend for Windows (NSIS Installer)
-Overview
-
-This project provides a Windows graphical installer (NSIS) to easily deploy the GNU Taler-Merchant backend on Windows using the Windows Subsystem for Linux (WSL) with Debian or Ubuntu. The installer guides the user step by step through the installation and setup process, requiring minimal manual intervention.
-Features
-
- Automated installation of WSL and the chosen Linux distribution (Debian or Ubuntu)
-
- Guided selection of domain and reverse proxy mode (HTTP or HTTPS)
-
- Installs and configures GNU Taler-Merchant backend inside WSL
-
- Multi-language support: English and French
-
- User-friendly GUI with branding and progress messages
-
- Automatic reboot handling if required
-
-Prerequisites
-
- Windows 10 or 11 with administrator privileges
-
- Internet connection
-
- No pre-existing WSL installation required (the installer handles everything)
-
- No services running on ports 80/443 if using HTTP/HTTPS
-
-Files Included
-File Name Description
-taler-installer.exe Main Windows installer (NSIS executable)
-taler-installer-taler.nsi NSIS script source code
-setup-wsl-debian.bat Windows batch script for enabling WSL & installing Debian/Ubuntu
-install-taler-from-apt.sh Bash script run inside WSL to install Taler-Merchant
-logo-header.ico/.bmp Installer icons and header images
-logo-welcome.bmp Welcome page image
-Installation Steps
-
- Clone or download this repository on your Windows machine.
-
- Run taler-installer.exe as administrator (right-click → "Run as administrator").
-
- Select the desired Linux distribution (Debian or Ubuntu).
-
- Enter the domain name for your Taler-Merchant instance (localhost can be used for testing or local-only installs).
-
- Choose the reverse proxy mode: HTTP or HTTPS.
-
- The installer will automatically:
-
- Enable WSL and install the chosen Linux distribution.
-
- Copy and execute scripts inside the WSL environment.
-
- Install and configure GNU Taler-Merchant backend.
-
- At the end, the installer offers to open the Taler-Merchant web interface in your browser.
-
-If a system reboot is required (for WSL activation), the installer will prompt you and provide a "Restart now" button.
-Important Notes
-
- No external PostgreSQL database setup is included in this version. The backend will use the default local PostgreSQL setup.
-
- For public domain/HTTPS usage, ensure your DNS and firewall are configured properly.
-
- Installation logs are written to C:\Users\Public\install.log in case of errors.
-
-Uninstallation
-
-To remove, simply delete the installation folder. You can also uninstall WSL from Windows settings if you no longer need it.
-Customization
-
- The NSIS script (taler-installer-taler.nsi) can be edited to add more options (e.g., advanced DB config, custom logos, more languages, etc).
-
- All branding images can be replaced as needed.
-
-License
-
-This installer is part of GNU Taler.
-Copyright © 2025 Taler Systems SA
-
-GNU Taler is free software, released under the GNU Lesser General Public License (LGPL) v2.1+.
-
-Author:
-Léa Oualli
-Taler Systems SA
-\ No newline at end of file
diff --git a/set-db.sh b/set-db.sh
@@ -0,0 +1,25 @@
+#!/bin/bash
+# set-db.sh
+# Usage: ./set-db.sh <POSTGRES_URL>
+POSTGRES_URL="$1"
+CONF_PATH="/etc/taler-merchant/taler-merchant.conf"
+
+if [ -z "$POSTGRES_URL" ]; then
+ echo "Missing PostgreSQL URL argument."
+ exit 1
+fi
+
+# Remplace ou ajoute la ligne DATABASE_URL
+if grep -q "^DATABASE_URL" "$CONF_PATH"; then
+ sudo sed -i "s|^DATABASE_URL *=.*|DATABASE_URL = $POSTGRES_URL|" "$CONF_PATH"
+else
+ echo "DATABASE_URL = $POSTGRES_URL" | sudo tee -a "$CONF_PATH"
+fi
+
+echo "Updated DATABASE_URL in $CONF_PATH"
+
+# Redémarre les services pour prendre en compte la modif
+sudo systemctl restart taler-merchant.target
+sudo systemctl restart taler-merchant-httpd.service
+
+exit 0
diff --git a/setup-wsl-debian.bat b/setup-wsl-debian.bat
@@ -15,12 +15,15 @@
::
:: Author: Léa Oualli
+@echo off
+echo %* > C:\Users\Public\debug_args.txt
setlocal enabledelayedexpansion
-set WSL=%WINDIR%\Sysnative\wsl.exe
set WSL_USER=taleruser
set STEP=%1
set DOMAIN=%2
set DISTRO=%3
+set WSL=wsl.exe
+if exist "%WINDIR%\Sysnative\wsl.exe" set WSL=%WINDIR%\Sysnative\wsl.exe
set PROXY_MODE=%4
if "%STEP%"=="" (
@@ -107,18 +110,57 @@ echo [4/8] Adding user to www-data group...
if not "%STEP%"=="ALL" exit /b
:step5
-echo [5/8] Copying installer script...
-copy /Y "%~dp0install-taler-from-apt.sh" "%TEMP%\install-taler-from-apt.sh"
+REM -------Copy the following script -------
+
+REM 1. Installer dos2unix (si pas déjà installé)
+%WSL% -d %DISTRO% -- bash -c "sudo apt-get update && sudo apt-get install -y dos2unix"
+
+REM 2. Prepare the folder
%WSL% -d %DISTRO% -- bash -c "sudo mkdir -p /home/%WSL_USER%/taler-installer"
+
+REM 3. Remove the old scripts
%WSL% -d %DISTRO% -- bash -c "sudo rm -f /home/%WSL_USER%/taler-installer/install-taler-from-apt.sh"
-type "%TEMP%\install-taler-from-apt.sh" | %WSL% -d %DISTRO% -- bash -c "sudo tee /home/%WSL_USER%/taler-installer/install-taler-from-apt.sh >nul"
+%WSL% -d %DISTRO% -- bash -c "sudo rm -f /home/%WSL_USER%/taler-installer/test-db.sh"
+%WSL% -d %DISTRO% -- bash -c "sudo rm -f /home/%WSL_USER%/taler-installer/set-db.sh"
+
+REM 4. Past the script form Windows to %TEMP%
+copy /Y "%~dp0install-taler-from-apt.sh" "%TEMP%\install-taler-from-apt.sh"
+copy /Y "%~dp0test-db.sh" "%TEMP%\test-db.sh"
+copy /Y "%~dp0set-db.sh" "%TEMP%\set-db.sh"
+
+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"
+
+REM 6. Convert all the scripts into UNIX format
+%WSL% -d %DISTRO% -- bash -c "sudo dos2unix /home/%WSL_USER%/taler-installer/*.sh"
+
+REM 7. Make the script executable
+%WSL% -d %DISTRO% -- bash -c "sudo chmod +x /home/%WSL_USER%/taler-installer/*.sh"
+
+REM ------------------------------------------------------------------------------
+
if not "%STEP%"=="ALL" exit /b
:step6
-echo [6/8] Converting script format and setting permissions...
-%WSL% -d %DISTRO% -- bash -c "sudo apt-get update && sudo apt-get install -y dos2unix"
-%WSL% -d %DISTRO% -- bash -c "sudo dos2unix /home/%WSL_USER%/taler-installer/install-taler-from-apt.sh"
-%WSL% -d %DISTRO% -- bash -c "sudo chmod +x /home/%WSL_USER%/taler-installer/install-taler-from-apt.sh"
+echo [6/8] Checks permissions...
+
+REM Check the version dos2unix (pour debug)
+%WSL% -d %DISTRO% -- bash -c "dos2unix --version"
+
+REM Display the format .sh ( ASCII text, Not CRLF)
+%WSL% -d %DISTRO% -- bash -c "file /home/%WSL_USER%/taler-installer/*.sh"
+
+REM Show the 5 firs lines of the code
+%WSL% -d %DISTRO% -- bash -c "for f in /home/%WSL_USER%/taler-installer/*.sh; do echo '----- $f'; head -n 5 \$f; done"
+
+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
+
if not "%STEP%"=="ALL" exit /b
:step7
@@ -138,26 +180,44 @@ if "%DOMAIN%"=="" (
set DOMAIN=localhost
)
+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" (
- echo Setting up HTTPS with Let's Encrypt for %DOMAIN% ...
- %WSL% -d %DISTRO% -- bash -c "sudo taler-merchant-rproxy-setup --acme --merchant-url='https://%DOMAIN%:8888/'"
- set CERT_STATUS=%errorlevel%
- if not %CERT_STATUS%==0 (
- 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
+ if "%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 (
- echo Setting up HTTP only for %DOMAIN% ...
- %WSL% -d %DISTRO% -- bash -c "sudo taler-merchant-rproxy-setup --domain %DOMAIN% --httponly"
+ if "%PROXY_TYPE%"=="APACHE" (
+ echo Setting up HTTP only (Apache) for %DOMAIN% ...
+ %WSL% -d %DISTRO% -- bash -c "sudo taler-merchant-rproxy-setup --domain %DOMAIN% --apache --no-certbot"
+ ) else (
+ echo Setting up HTTP only (Nginx) for %DOMAIN% ...
+ %WSL% -d %DISTRO% -- bash -c "sudo taler-merchant-rproxy-setup --domain %DOMAIN% --nginx --no-certbot"
+ )
)
-echo.
-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"
+if "%PROXY_TYPE%"=="APACHE" (
+ %WSL% -d %DISTRO% -- bash -c "sudo service apache2 start"
+) else (
+ %WSL% -d %DISTRO% -- bash -c "sudo service nginx start"
+)
+
+if "%PROXY_TYPE%"=="APACHE" (
+ %WSL% -d %DISTRO% -- bash -c "sudo service apache2 start"
+ REM Optionnel: planifier Apache au démarrage WSL
+ 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"
+) else (
+ %WSL% -d %DISTRO% -- bash -c "sudo service nginx start"
+ REM Tu peux planifier nginx aussi si tu veux
+)
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"
diff --git a/taler-installer-taler.nsi b/taler-installer-taler.nsi
@@ -1,17 +1,6 @@
; This file is part of GNU Taler.
; Copyright (C) 2025 Taler Systems SA
;
-; TALER is free software; you can redistribute it and/or modify it under the
-; terms of the GNU Lesser General Public License as published by the Free Software
-; Foundation; either version 2.1, or (at your option) any later version.
-;
-; TALER is distributed in the hope that it will be useful, but WITHOUT ANY
-; WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-; A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
-;
-; You should have received a copy of the GNU Lesser General Public License along with
-; TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
-;
; Author: Léa Oualli
Unicode true
@@ -47,16 +36,9 @@ Page custom DistroPage DistroPageLeave
Page custom DomainPage DomainPageLeave
Page custom ReverseProxyPage ReverseProxyPageLeave
!insertmacro MUI_PAGE_INSTFILES
-
-; -------- LangString FINISH_LINK ici, UNE SEULE FOIS ------------
-LangString MSG_FINISH_LINK 1033 "Open merchant web interface after installation"
-LangString MSG_FINISH_LINK 1036 "Ouvrir l'interface web du marchand apres l'installation"
-
-!define MUI_FINISHPAGE_SHOWREADME
-!define MUI_FINISHPAGE_SHOWREADME_FUNCTION OpenBrowser
-!define MUI_FINISHPAGE_SHOWREADME_TEXT "$(MSG_FINISH_LINK)"
+Page custom AskExternalDBPage AskExternalDBPageLeave
+Page custom DBUrlPage DBUrlPageLeave
!insertmacro MUI_PAGE_FINISH
-; ---------------------------------------------------------------
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "French"
@@ -69,6 +51,11 @@ Var /GLOBAL RADIO_UBUNTU
Var /GLOBAL REVERSE_PROXY_MODE
Var /GLOBAL RADIO_HTTP_ONLY
Var /GLOBAL RADIO_HTTPS
+Var /GLOBAL WSL_SCRIPT_DIR
+Var /GLOBAL DB_URL
+Var /GLOBAL DBCONFIG_INPUT
+Var /GLOBAL ASK_DB_YESNO
+Var /GLOBAL USE_EXTERNAL_DB
LangString MSG_WELCOME_TITLE ${LANG_ENGLISH} "GNU Taler-Merchant backend for Windows"
LangString MSG_WELCOME_TITLE ${LANG_FRENCH} "Backend GNU Taler-Merchant pour Windows"
@@ -97,7 +84,6 @@ LangString MSG_UPDATE_WSL ${LANG_FRENCH} "Une fenetre de mise a jour Windows va
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..."
-; Reverse proxy (HTTPS/HTTP) texts
LangString MSG_REVERSE_PROXY_TITLE ${LANG_ENGLISH} "Select reverse proxy mode:"
LangString MSG_REVERSE_PROXY_TITLE ${LANG_FRENCH} "Choisissez le mode du reverse proxy :"
@@ -110,21 +96,46 @@ LangString MSG_HTTPS ${LANG_FRENCH} "HTTPS"
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 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 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_YES ${LANG_ENGLISH} "Yes, configure an external database"
+LangString ASK_DB_YES ${LANG_FRENCH} "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 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 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_CONN_OK ${LANG_ENGLISH} "External database configured successfully!"
+LangString DB_CONN_OK ${LANG_FRENCH} "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 à la base a echoue. Réessayer/modifier l'URL ou Annuler pour rester en local."
+
+
+
+; --- PAGE DISTRO ---
Function DistroPage
nsDialogs::Create 1018
Pop $0
${If} $0 == error
Abort
${EndIf}
- ${NSD_CreateLabel} 0 10u 100% 12u "Choose the WSL Linux distribution to install:"
+ ${NSD_CreateLabel} 0 10u 100% 12u $(CHOOSE_DISTRO_LABEL)
Pop $0
${NSD_CreateRadioButton} 0 30u 100% 12u "Debian"
Pop $RADIO_DEBIAN
${NSD_CreateRadioButton} 0 45u 100% 12u "Ubuntu"
Pop $RADIO_UBUNTU
- ; Debian par défaut sélectionné
${NSD_SetState} $RADIO_DEBIAN 1
nsDialogs::Show
FunctionEnd
@@ -143,6 +154,7 @@ Function DistroPageLeave
${EndIf}
FunctionEnd
+; --- PAGE DOMAINE ---
Function DomainPage
nsDialogs::Create 1018
Pop $0
@@ -158,18 +170,15 @@ FunctionEnd
Function DomainPageLeave
${NSD_GetText} $DOMAIN_INPUT $0
-
${If} $0 == ""
MessageBox MB_OK|MB_ICONEXCLAMATION $(MSG_DOMAIN_REQUIRED)
Abort
${EndIf}
-
${If} $0 == "localhost"
MessageBox MB_OK $(MSG_LOCALHOST_WARN)
StrCpy $DOMAIN_INPUT $0
Return
${EndIf}
-
StrCpy $1 0
loop_ping:
nsExec::ExecToStack 'ping -n 1 -w 1000 $0'
@@ -191,7 +200,7 @@ Function DomainPageLeave
${EndIf}
FunctionEnd
-
+; --- PAGE REVERSE PROXY ---
Function ReverseProxyPage
nsDialogs::Create 1018
Pop $0
@@ -222,11 +231,14 @@ Function ReverseProxyPageLeave
${EndIf}
FunctionEnd
+; -------- SECTION INSTALL PRINCIPALE --------
Section "Install Taler-Merchant"
SetOutPath "$INSTDIR"
SetDetailsView show
File "setup-wsl-debian.bat"
File "install-taler-from-apt.sh"
+ File "test-db.sh"
+ File "set-db.sh"
FindWindow $0 "#32770" "" $HWNDPARENT
GetDlgItem $HWND_PROGRESS_LABEL $0 1006
@@ -239,7 +251,6 @@ Section "Install Taler-Merchant"
MessageBox MB_OK|MB_ICONINFORMATION $(MSG_STEP1)
DetailPrint "[INFO] This is the slowest step. Please be patient."
- DetailPrint "[INFO] Enabling Windows features can take several minutes (up to 5-10 minutes on some computers)."
SendMessage $HWND_PROGRESS_LABEL ${WM_SETTEXT} 0 "STR:Progress: 8%"
Sleep 5000
@@ -255,16 +266,12 @@ Section "Install Taler-Merchant"
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_ICONEXCLAMATION|MB_YESNO $(MSG_NEED_REBOOT) IDYES restart_now IDNO end_installer
- restart_now:
- Exec '"shutdown.exe" /r /t 0'
- Quit
- end_installer:
+ nsExec::ExecToLog '"$INSTDIR\setup-wsl-debian.bat" 1 "" $WSL_DISTRO'
+ Pop $0
+ ${If} $0 != 0
+ MessageBox MB_OK $(MSG_NEED_REBOOT)
Quit
-${EndIf}
+ ${EndIf}
MessageBox MB_OK $(MSG_UPDATE_WSL)
@@ -299,7 +306,7 @@ ${EndIf}
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'
+ 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"'
@@ -315,11 +322,86 @@ ${EndIf}
Sleep 1000
DetailPrint "Installation complete."
SendMessage $HWND_PROGRESS_LABEL ${WM_SETTEXT} 0 "STR:Progress: 100%"
-
CreateShortCut "$SMPROGRAMS\Taler-Merchant.lnk" "$INSTDIR\taler-installer.exe"
SectionEnd
-Function OpenBrowser
+; -------- PAGE DB CHOIX (avant URL) --------
+Function AskExternalDBPage
+ nsDialogs::Create 1018
+ Pop $0
+ ${If} $0 == error
+ Abort
+ ${EndIf}
+ ${NSD_CreateLabel} 10u 10u 80% 12u $(ASK_DB_LABEL)
+ Pop $1
+ ${NSD_CreateRadioButton} 10u 35u 80u 12u $(ASK_DB_YES)
+ Pop $ASK_DB_YESNO
+ ${NSD_CreateRadioButton} 10u 55u 80u 12u $(ASK_DB_NO)
+ Pop $0
+ ${NSD_SetState} $0 1 ; "No" checked by default
+ nsDialogs::Show
+FunctionEnd
+
+Function AskExternalDBPageLeave
+ ${NSD_GetState} $ASK_DB_YESNO $0
+ ${If} $0 == 1
+ StrCpy $USE_EXTERNAL_DB "1"
+ ${Else}
+ StrCpy $USE_EXTERNAL_DB "0"
+ ${EndIf}
+ Return
+FunctionEnd
+
+; -------- PAGE FORMULAIRE URL DB (apparait si Oui) --------
+Function DBUrlPage
+ ${If} $USE_EXTERNAL_DB != "1"
+ Abort
+ ${EndIf}
+ nsDialogs::Create 1018
+ Pop $0
+ ${If} $0 == error
+ Abort
+ ${EndIf}
+ ${NSD_CreateLabel} 0 10u 100% 12u $(ENTER_DB_URL_LABEL)
+ Pop $1
+ ${NSD_CreateText} 0 25u 100% 12u ""
+ Pop $DBCONFIG_INPUT
+ nsDialogs::Show
+FunctionEnd
+
+Function DBUrlPageLeave
+ ${If} $USE_EXTERNAL_DB != "1"
+ Return
+ ${EndIf}
+ ${NSD_GetText} $DBCONFIG_INPUT $DB_URL
+
+ ${If} $DB_URL == ""
+ MessageBox MB_OK|MB_ICONEXCLAMATION $(DB_URL_REQUIRED)
+ Abort
+ ${EndIf}
+
+ DetailPrint "Testing connection to the external database..."
+ StrCpy $WSL_SCRIPT_DIR "/home/taleruser/taler-installer"
+DetailPrint "Testing with DB_URL='$DB_URL'"
+ nsExec::ExecToStack 'wsl -d $WSL_DISTRO -- bash -c "/home/taleruser/taler-installer/test-db.sh ''$DB_URL''"'
+ Pop $0
+
+ ${If} $0 == 0
+ DetailPrint "Connection succeeded. Updating configuration..."
+ nsExec::ExecToStack 'wsl -d $WSL_DISTRO -- bash -c "/home/taleruser/taler-installer/set-db.sh ''$DB_URL''"'
+ MessageBox MB_OK $(DB_CONN_OK)
+ ${Else}
+ MessageBox MB_RETRYCANCEL $(DB_CONN_FAIL) IDRETRY retry_dburl IDCANCEL fin_dburl
+ retry_dburl:
+ Abort
+ fin_dburl:
+ ${EndIf}
+ Return
+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"
ExecShell "open" "https://$DOMAIN_INPUT"
${Else}
@@ -330,4 +412,4 @@ FunctionEnd
Function .onInstFailed
MessageBox MB_OK $(MSG_INSTALL_FAILED)
ExecShell "open" "C:\Users\Public\install.log"
-FunctionEnd
+FunctionEnd
+\ No newline at end of file
diff --git a/test-db.sh b/test-db.sh
@@ -0,0 +1,24 @@
+#!/bin/bash
+# test-db.sh
+# Usage: ./test-db.sh <POSTGRES_URL>
+echo "=== [DEBUG] test-db.sh called ===" | tee -a /home/taleruser/taler-installer/test-db.log
+echo "Received URL: $1" | tee -a /home/taleruser/taler-installer/test-db.log
+POSTGRES_URL="$1"
+
+echo "Testing $POSTGRES_URL" > /tmp/dbtest.log
+
+if command -v psql >/dev/null 2>&1; then
+ if psql "$POSTGRES_URL" -c '\q' >> /tmp/dbtest.log 2>&1; then
+ echo "OK"
+ echo "Exit code: 0" >> /tmp/dbtest.log
+ exit 0
+ else
+ echo "ERROR"
+ echo "Exit code: 1" >> /tmp/dbtest.log
+ exit 1
+ fi
+else
+ echo "psql command not found"
+ echo "Exit code: 2" >> /tmp/dbtest.log
+ exit 2
+fi
diff --git a/upgrade/taler-launcher.nsi b/upgrade/taler-launcher.nsi
@@ -1,51 +0,0 @@
-; Taler-Merchant Launcher with Auto-Upgrade
-; Author: Léa Oualli
-
-Unicode true
-!include "MUI2.nsh"
-
-Name "Taler-Merchant Launcher"
-Outfile "taler-launcher.exe"
-RequestExecutionLevel admin
-
-Var /GLOBAL WSL_DISTRO
-
-Section "Launch or Upgrade Taler-Merchant"
-
- ; 1. Vérifier si Debian est installée dans WSL
- nsExec::ExecToStack 'wsl -l -v'
- Pop $0
- ${If} ${Errors}
- MessageBox MB_OK "WSL does not seem to be installed. Please install Debian/WSL first."
- Abort
- ${EndIf}
- ; Cherche "Debian" dans la sortie
- StrCpy $WSL_DISTRO ""
- ${IfThen} $0 =~ "Debian" ${|} StrCpy $WSL_DISTRO "Debian" ${|}
- ${If} $WSL_DISTRO == ""
- MessageBox MB_OK "Debian is not installed in WSL. Please install Debian first."
- Abort
- ${EndIf}
-
- ; 2. Vérifier la présence de taler-merchant
- nsExec::ExecToStack 'wsl -d Debian -- bash -c "which taler-merchant"'
- Pop $0
- ${If} ${Errors}
- MessageBox MB_OK "Taler-Merchant is not installed yet. Please run the main installer first."
- Abort
- ${EndIf}
-
- ; 3. Proposer upgrade
- MessageBox MB_YESNO|MB_ICONQUESTION "Taler-Merchant is installed.$\nDo you want to upgrade Taler and system packages now?" IDYES do_upgrade IDNO skip_upgrade
-
- do_upgrade:
- nsExec::ExecToLog 'wsl -d Debian -- bash -c "sudo apt update && sudo apt upgrade -y && sudo apt install --only-upgrade taler-merchant taler-exchange -y"'
- MessageBox MB_OK "Upgrade finished!"
- Goto end_upgrade
-
- skip_upgrade:
- DetailPrint "User skipped upgrade."
-
- end_upgrade:
-
-SectionEnd