taler-installer-taler.nsi (16724B)
1 ; This file is part of GNU Taler. 2 ; Copyright (C) 2025 Taler Systems SA 3 ; 4 ; Author: Léa Oualli 5 6 Unicode true 7 8 !include "MUI2.nsh" 9 !include "LogicLib.nsh" 10 !include "FileFunc.nsh" 11 !include "WinMessages.nsh" 12 !include "nsDialogs.nsh" 13 14 !define MUI_ABORTWARNING 15 !define MUI_LANGDLL_DISPLAY 16 !define MUI_LANGDLL_REGISTRY_ROOT "HKCU" 17 !define MUI_LANGDLL_REGISTRY_KEY "Software\TalerInstaller" 18 !define MUI_LANGDLL_REGISTRY_VALUENAME "InstallerLanguage" 19 20 Name "Taler-Merchant backend" 21 Outfile "taler-installer.exe" 22 InstallDir "$PROGRAMFILES\TalerMerchant" 23 RequestExecutionLevel admin 24 25 Icon "logo-header.ico" 26 !define MUI_ICON "logo-header.ico" 27 !define MUI_HEADERIMAGE 28 !define MUI_HEADERIMAGE_RIGHT 29 !define MUI_HEADERIMAGE_BITMAP "logo-header.bmp" 30 !define MUI_HEADERIMAGE_BITMAP_NOSTRETCH 31 !define MUI_WELCOMEFINISHPAGE_BITMAP "logo-welcome.bmp" 32 33 !insertmacro MUI_PAGE_WELCOME 34 !insertmacro MUI_PAGE_DIRECTORY 35 Page custom DistroPage DistroPageLeave 36 Page custom DomainPage DomainPageLeave 37 Page custom ReverseProxyPage ReverseProxyPageLeave 38 !insertmacro MUI_PAGE_INSTFILES 39 Page custom AskExternalDBPage AskExternalDBPageLeave 40 Page custom DBUrlPage DBUrlPageLeave 41 !insertmacro MUI_PAGE_FINISH 42 43 !insertmacro MUI_LANGUAGE "English" 44 !insertmacro MUI_LANGUAGE "French" 45 46 Var /GLOBAL HWND_PROGRESS_LABEL 47 Var /GLOBAL DOMAIN_INPUT 48 Var /GLOBAL WSL_DISTRO 49 Var /GLOBAL RADIO_DEBIAN 50 Var /GLOBAL RADIO_UBUNTU 51 Var /GLOBAL REVERSE_PROXY_MODE 52 Var /GLOBAL RADIO_HTTP_ONLY 53 Var /GLOBAL RADIO_HTTPS 54 Var /GLOBAL WSL_SCRIPT_DIR 55 Var /GLOBAL DB_URL 56 Var /GLOBAL DBCONFIG_INPUT 57 Var /GLOBAL ASK_DB_YESNO 58 Var /GLOBAL USE_EXTERNAL_DB 59 60 LangString MSG_WELCOME_TITLE ${LANG_ENGLISH} "GNU Taler-Merchant backend for Windows" 61 LangString MSG_WELCOME_TITLE ${LANG_FRENCH} "Backend GNU Taler-Merchant pour Windows" 62 63 LangString MSG_WELCOME_TEXT ${LANG_ENGLISH} "This wizard will install The GNU Taler-Merchant using WSL and Debian or Ubuntu." 64 LangString MSG_WELCOME_TEXT ${LANG_FRENCH} "Cet assistant va installer GNU Taler-Merchant avec WSL et Debian ou Ubuntu." 65 66 LangString ENTER_DOMAIN ${LANG_ENGLISH} "Enter your Taler-Merchant domain name:" 67 LangString ENTER_DOMAIN ${LANG_FRENCH} "Entrez le nom de votre domaine Taler-Merchant:" 68 69 LangString MSG_DOMAIN_REQUIRED ${LANG_ENGLISH} "Please enter a domain name." 70 LangString MSG_DOMAIN_REQUIRED ${LANG_FRENCH} "Veuillez saisir un nom de domaine." 71 72 LangString MSG_LOCALHOST_WARN ${LANG_ENGLISH} "Warning: using 'localhost' means your merchant will not be publicly accessible." 73 LangString MSG_LOCALHOST_WARN ${LANG_FRENCH} "Attention : utiliser 'localhost' signifie que votre marchand ne sera pas accessible publiquement." 74 75 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." 76 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." 77 78 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." 79 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." 80 81 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." 82 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." 83 84 LangString MSG_INSTALL_FAILED ${LANG_ENGLISH} "Installation failed. Opening install.log..." 85 LangString MSG_INSTALL_FAILED ${LANG_FRENCH} "L'installation a echoue. Ouverture du fichier install.log..." 86 87 LangString MSG_REVERSE_PROXY_TITLE ${LANG_ENGLISH} "Select reverse proxy mode:" 88 LangString MSG_REVERSE_PROXY_TITLE ${LANG_FRENCH} "Choisissez le mode du reverse proxy :" 89 90 LangString MSG_HTTP_ONLY ${LANG_ENGLISH} "HTTP only" 91 LangString MSG_HTTP_ONLY ${LANG_FRENCH} "HTTP uniquement" 92 93 LangString MSG_HTTPS ${LANG_ENGLISH} "HTTPS" 94 LangString MSG_HTTPS ${LANG_FRENCH} "HTTPS" 95 96 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." 97 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." 98 99 LangString CHOOSE_DISTRO_LABEL ${LANG_ENGLISH} "Choose the WSL Linux distribution to install:" 100 LangString CHOOSE_DISTRO_LABEL ${LANG_FRENCH} "Choisissez la distribution Linux WSL a installer :" 101 102 103 LangString ASK_DB_LABEL ${LANG_ENGLISH} "Installation finished. Do you want to use an external PostgreSQL database?" 104 LangString ASK_DB_LABEL ${LANG_FRENCH} "Installation terminée. Voulez-vous utiliser une base de donnees PostgreSQL externe ?" 105 106 LangString ASK_DB_YES ${LANG_ENGLISH} "Yes, configure an external database" 107 LangString ASK_DB_YES ${LANG_FRENCH} "Oui, configurer une base externe" 108 109 LangString ASK_DB_NO ${LANG_ENGLISH} "No, use local database (default)" 110 LangString ASK_DB_NO ${LANG_FRENCH} "Non, utiliser la base locale (par défaut)" 111 112 LangString ENTER_DB_URL_LABEL ${LANG_ENGLISH} "Enter the external PostgreSQL URL (e.g.: postgresql://user:pass@host:5432/dbname):" 113 LangString ENTER_DB_URL_LABEL ${LANG_FRENCH} "Entrez l'URL PostgreSQL externe (ex:postgresql://user:pass@host:5432/dbname) :" 114 115 LangString DB_URL_REQUIRED ${LANG_ENGLISH} "You must enter a valid URL." 116 LangString DB_URL_REQUIRED ${LANG_FRENCH} "Vous devez entrer une URL valide." 117 118 LangString DB_CONN_OK ${LANG_ENGLISH} "External database configured successfully!" 119 LangString DB_CONN_OK ${LANG_FRENCH} "Base externe configuree avec succès !" 120 121 LangString DB_CONN_FAIL ${LANG_ENGLISH} "Connection to the database failed. Retry/modify URL or Cancel to use local." 122 LangString DB_CONN_FAIL ${LANG_FRENCH} "La connexion a la base a echoue. Reessayer/modifier l'URL ou Annuler pour rester en local." 123 124 125 126 ; --- PAGE DISTRO --- 127 Function DistroPage 128 nsDialogs::Create 1018 129 Pop $0 130 ${If} $0 == error 131 Abort 132 ${EndIf} 133 ${NSD_CreateLabel} 0 10u 100% 12u $(CHOOSE_DISTRO_LABEL) 134 Pop $0 135 ${NSD_CreateRadioButton} 0 30u 100% 12u "Debian" 136 Pop $RADIO_DEBIAN 137 ${NSD_CreateRadioButton} 0 45u 100% 12u "Ubuntu" 138 Pop $RADIO_UBUNTU 139 ${NSD_SetState} $RADIO_DEBIAN 1 140 nsDialogs::Show 141 FunctionEnd 142 143 Function DistroPageLeave 144 ${NSD_GetState} $RADIO_DEBIAN $0 145 ${If} $0 == 1 146 StrCpy $WSL_DISTRO "Debian" 147 ${EndIf} 148 ${NSD_GetState} $RADIO_UBUNTU $0 149 ${If} $0 == 1 150 StrCpy $WSL_DISTRO "Ubuntu" 151 ${EndIf} 152 ${If} $WSL_DISTRO == "" 153 StrCpy $WSL_DISTRO "Debian" 154 ${EndIf} 155 FunctionEnd 156 157 ; --- PAGE DOMAINE --- 158 Function DomainPage 159 nsDialogs::Create 1018 160 Pop $0 161 ${If} $0 == error 162 Abort 163 ${EndIf} 164 ${NSD_CreateLabel} 0 10u 100% 12u $(ENTER_DOMAIN) 165 Pop $0 166 ${NSD_CreateText} 0 25u 100% 12u "" 167 Pop $DOMAIN_INPUT 168 nsDialogs::Show 169 FunctionEnd 170 171 Function DomainPageLeave 172 ${NSD_GetText} $DOMAIN_INPUT $0 173 ${If} $0 == "" 174 MessageBox MB_OK|MB_ICONEXCLAMATION $(MSG_DOMAIN_REQUIRED) 175 Abort 176 ${EndIf} 177 ${If} $0 == "localhost" 178 MessageBox MB_OK $(MSG_LOCALHOST_WARN) 179 StrCpy $DOMAIN_INPUT $0 180 Return 181 ${EndIf} 182 StrCpy $1 0 183 loop_ping: 184 nsExec::ExecToStack 'ping -n 1 -w 1000 $0' 185 Pop $2 186 ${If} $2 == 0 187 StrCpy $DOMAIN_INPUT $0 188 Return 189 ${Else} 190 Push $0 191 MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION "$(MSG_DOMAIN_PING_FAIL)" IDRETRY retry_ping IDCANCEL use_localhost 192 retry_ping: 193 IntOp $1 $1 + 1 194 ${If} $1 < 3 195 Goto loop_ping 196 ${EndIf} 197 use_localhost: 198 StrCpy $DOMAIN_INPUT "localhost" 199 MessageBox MB_OK $(MSG_LOCALHOST_WARN) 200 ${EndIf} 201 FunctionEnd 202 203 Function ReverseProxyPage 204 nsDialogs::Create 1018 205 Pop $0 206 ${If} $0 == error 207 Abort 208 ${EndIf} 209 210 ${NSD_CreateLabel} 0 10u 100% 12u $(MSG_REVERSE_PROXY_TITLE) 211 Pop $0 212 213 ${NSD_CreateRadioButton} 0 30u 100% 12u $(MSG_HTTP_ONLY) 214 Pop $RADIO_HTTP_ONLY 215 216 ${NSD_CreateRadioButton} 0 45u 100% 12u $(MSG_HTTPS) 217 Pop $RADIO_HTTPS 218 219 ; Récupère la valeur du domaine 220 ${NSD_GetText} $DOMAIN_INPUT $1 221 222 ${If} $1 == "localhost" 223 ; HTTPS grisé, HTTP sélectionné 224 EnableWindow $RADIO_HTTPS 0 225 ${NSD_SetState} $RADIO_HTTP_ONLY 1 226 ${NSD_SetState} $RADIO_HTTPS 0 227 ${Else} 228 ; Les deux actifs, HTTPS sélectionné par défaut 229 EnableWindow $RADIO_HTTP_ONLY 1 230 EnableWindow $RADIO_HTTPS 1 231 ${NSD_SetState} $RADIO_HTTPS 1 232 ${NSD_SetState} $RADIO_HTTP_ONLY 0 233 ${EndIf} 234 235 nsDialogs::Show 236 FunctionEnd 237 238 Function ReverseProxyPageLeave 239 ${NSD_GetState} $RADIO_HTTP_ONLY $0 240 ${If} $0 == 1 241 StrCpy $REVERSE_PROXY_MODE "http" 242 ${Else} 243 StrCpy $REVERSE_PROXY_MODE "https" 244 ${EndIf} 245 FunctionEnd 246 247 ; -------- SECTION INSTALL PRINCIPALE -------- 248 Section "Install Taler-Merchant" 249 SetOutPath "$INSTDIR" 250 SetDetailsView show 251 File "setup-wsl-debian.bat" 252 File "install-taler-from-apt.sh" 253 File "test-db.sh" 254 File "set-db.sh" 255 256 FindWindow $0 "#32770" "" $HWNDPARENT 257 GetDlgItem $HWND_PROGRESS_LABEL $0 1006 258 259 DetailPrint "---------------------------------------------------------" 260 DetailPrint "[1/8] Enabling WSL and VirtualMachinePlatform..." 261 SendMessage $HWND_PROGRESS_LABEL ${WM_SETTEXT} 0 "STR:Progress: 5%" 262 Sleep 2000 263 264 MessageBox MB_OK|MB_ICONINFORMATION $(MSG_STEP1) 265 266 DetailPrint "[INFO] This is the slowest step. Please be patient." 267 SendMessage $HWND_PROGRESS_LABEL ${WM_SETTEXT} 0 "STR:Progress: 8%" 268 Sleep 5000 269 270 DetailPrint "[INFO] Do NOT close the installer. The process will continue automatically." 271 SendMessage $HWND_PROGRESS_LABEL ${WM_SETTEXT} 0 "STR:Progress: 12%" 272 Sleep 5000 273 274 DetailPrint "[INFO] Windows is still enabling the required features..." 275 SendMessage $HWND_PROGRESS_LABEL ${WM_SETTEXT} 0 "STR:Progress: 16%" 276 Sleep 5000 277 278 DetailPrint "[INFO] This is normal. Please wait, your system is working in the background." 279 SendMessage $HWND_PROGRESS_LABEL ${WM_SETTEXT} 0 "STR:Progress: 20%" 280 Sleep 5000 281 282 nsExec::ExecToLog '"$INSTDIR\setup-wsl-debian.bat" 1 "" $WSL_DISTRO' 283 Pop $0 284 ${If} $0 != 0 285 MessageBox MB_OK $(MSG_NEED_REBOOT) 286 Quit 287 ${EndIf} 288 289 MessageBox MB_OK $(MSG_UPDATE_WSL) 290 291 DetailPrint "[INFO] WSL and VirtualMachinePlatform are enabled. Checking for WSL updates..." 292 SendMessage $HWND_PROGRESS_LABEL ${WM_SETTEXT} 0 "STR:Progress: 30%" 293 DetailPrint "NOTICE: A black window may appear for the WSL update. If it does, simply press any key when prompted." 294 Sleep 1000 295 296 DetailPrint "[2/8] Installing $WSL_DISTRO..." 297 SendMessage $HWND_PROGRESS_LABEL ${WM_SETTEXT} 0 "STR:Progress: 35%" 298 Sleep 1000 299 300 DetailPrint "[3/8] Creating $WSL_DISTRO user..." 301 SendMessage $HWND_PROGRESS_LABEL ${WM_SETTEXT} 0 "STR:Progress: 45%" 302 Sleep 1000 303 304 DetailPrint "[4/8] Adding user to www-data group..." 305 SendMessage $HWND_PROGRESS_LABEL ${WM_SETTEXT} 0 "STR:Progress: 55%" 306 Sleep 1000 307 308 DetailPrint "[5/8] Copying installer script..." 309 SendMessage $HWND_PROGRESS_LABEL ${WM_SETTEXT} 0 "STR:Progress: 60%" 310 Sleep 1000 311 312 DetailPrint "[6/8] Converting script format and setting permissions..." 313 SendMessage $HWND_PROGRESS_LABEL ${WM_SETTEXT} 0 "STR:Progress: 65%" 314 Sleep 1000 315 316 DetailPrint "[7/8] Restarting WSL and launching installation..." 317 SendMessage $HWND_PROGRESS_LABEL ${WM_SETTEXT} 0 "STR:Progress: 70%" 318 nsExec::ExecToLog '"$INSTDIR\setup-wsl-debian.bat" ALL "" $WSL_DISTRO' 319 320 DetailPrint "[8/8] Configuring reverse proxy for $DOMAIN_INPUT in $REVERSE_PROXY_MODE mode..." 321 SendMessage $HWND_PROGRESS_LABEL ${WM_SETTEXT} 0 "STR:Progress: 80%" 322 nsExec::ExecToLog '"$INSTDIR\setup-wsl-debian.bat" 8 $DOMAIN_INPUT $WSL_DISTRO $REVERSE_PROXY_MODE' 323 324 DetailPrint "Testing access to merchant reverse proxy..." 325 nsExec::ExecToLog 'wsl -d $WSL_DISTRO -- bash -c "curl -v http://localhost"' 326 SendMessage $HWND_PROGRESS_LABEL ${WM_SETTEXT} 0 "STR:Progress: 85%" 327 Sleep 2000 328 329 DetailPrint "Checking passed domain in $WSL_DISTRO..." 330 nsExec::ExecToLog 'wsl -d $WSL_DISTRO -- bash -c "echo Received domain: '\''$DOMAIN_INPUT'\''"' 331 SendMessage $HWND_PROGRESS_LABEL ${WM_SETTEXT} 0 "STR:Progress: 90%" 332 Sleep 2000 333 334 SendMessage $HWND_PROGRESS_LABEL ${WM_SETTEXT} 0 "STR:Progress: 99%" 335 Sleep 1000 336 DetailPrint "Installation complete." 337 SendMessage $HWND_PROGRESS_LABEL ${WM_SETTEXT} 0 "STR:Progress: 100%" 338 CreateShortCut "$SMPROGRAMS\Taler-Merchant.lnk" "$INSTDIR\taler-installer.exe" 339 SectionEnd 340 341 ; -------- PAGE DB CHOIX (avant URL) -------- 342 Function AskExternalDBPage 343 nsDialogs::Create 1018 344 Pop $0 345 ${If} $0 == error 346 Abort 347 ${EndIf} 348 ${NSD_CreateLabel} 10u 10u 80% 12u $(ASK_DB_LABEL) 349 Pop $1 350 ${NSD_CreateRadioButton} 10u 35u 80u 12u $(ASK_DB_YES) 351 Pop $ASK_DB_YESNO 352 ${NSD_CreateRadioButton} 10u 55u 80u 12u $(ASK_DB_NO) 353 Pop $0 354 ${NSD_SetState} $0 1 ; "No" checked by default 355 nsDialogs::Show 356 FunctionEnd 357 358 Function AskExternalDBPageLeave 359 ${NSD_GetState} $ASK_DB_YESNO $0 360 ${If} $0 == 1 361 StrCpy $USE_EXTERNAL_DB "1" 362 ${Else} 363 StrCpy $USE_EXTERNAL_DB "0" 364 ${EndIf} 365 Return 366 FunctionEnd 367 368 ; -------- PAGE FORMULAIRE URL DB (apparait si Oui) -------- 369 Function DBUrlPage 370 ${If} $USE_EXTERNAL_DB != "1" 371 Abort 372 ${EndIf} 373 nsDialogs::Create 1018 374 Pop $0 375 ${If} $0 == error 376 Abort 377 ${EndIf} 378 ${NSD_CreateLabel} 0 10u 100% 12u $(ENTER_DB_URL_LABEL) 379 Pop $1 380 ${NSD_CreateText} 0 25u 100% 12u "" 381 Pop $DBCONFIG_INPUT 382 nsDialogs::Show 383 FunctionEnd 384 385 Function DBUrlPageLeave 386 ${If} $USE_EXTERNAL_DB != "1" 387 Return 388 ${EndIf} 389 ${NSD_GetText} $DBCONFIG_INPUT $DB_URL 390 391 ${If} $DB_URL == "" 392 MessageBox MB_OK|MB_ICONEXCLAMATION $(DB_URL_REQUIRED) 393 Abort 394 ${EndIf} 395 396 DetailPrint "Testing connection to the external database..." 397 StrCpy $WSL_SCRIPT_DIR "/home/taleruser/taler-installer" 398 DetailPrint "Testing with DB_URL='$DB_URL'" 399 nsExec::ExecToStack 'wsl -d $WSL_DISTRO -- bash -c "/home/taleruser/taler-installer/test-db.sh ''$DB_URL''"' 400 Pop $0 401 402 ${If} $0 == 0 403 DetailPrint "Connection succeeded. Updating configuration..." 404 nsExec::ExecToStack 'wsl -d $WSL_DISTRO -- bash -c "/home/taleruser/taler-installer/set-db.sh ''$DB_URL''"' 405 MessageBox MB_OK $(DB_CONN_OK) 406 ${Else} 407 MessageBox MB_RETRYCANCEL $(DB_CONN_FAIL) IDRETRY retry_dburl IDCANCEL fin_dburl 408 retry_dburl: 409 Abort 410 fin_dburl: 411 ${EndIf} 412 Return 413 FunctionEnd 414 415 ; ---- PAGE FINISH : open browser ---- 416 Function .onGUIEnd 417 MessageBox MB_OK|MB_ICONINFORMATION "Installation is complete! Your browser will now open your domain." 418 419 ; Force WSL à démarrer Apache AVANT le navigateur 420 nsExec::ExecToLog 'wsl -d $WSL_DISTRO -- bash -c "sudo service apache2 restart"' 421 Sleep 2000 422 423 ${If} $REVERSE_PROXY_MODE == "https" 424 ExecShell "open" "https://$DOMAIN_INPUT" 425 ${Else} 426 ExecShell "open" "http://$DOMAIN_INPUT" 427 ${EndIf} 428 FunctionEnd 429 430 Function .onInstFailed 431 MessageBox MB_OK $(MSG_INSTALL_FAILED) 432 ExecShell "open" "C:\Users\Public\install.log" 433 FunctionEnd