From 780b5205067623de0e3224bfeb571d6ccad9e6cd Mon Sep 17 00:00:00 2001 From: U-Bren <30356110+U-Bren@users.noreply.github.com> Date: Mon, 17 Jan 2022 23:51:25 +0100 Subject: [PATCH] Add powershell equivalents to existing batch scripts (#2561) * Add powershell equivalents to existing windows scripts Each .bat will try to invoke its .ps1 version if powershell is available, or else will fallback on the behavior previous to this commit. Should help fix bugs with accents and non-ASCII characters (issue #2327). * Add powershell equivalents to existing windows scripts Each .bat will try to invoke its .ps1 version if powershell is available, or else will fallback on the behavior previous to this commit. Should help fix bugs with accents and non-ASCII characters (issue #2327). Co-authored-by: zadam --- bin/build-win-x64.sh | 4 +--- bin/tpl/trilium-no-cert-check.bat | 3 ++- bin/tpl/trilium-no-cert-check.ps1 | 2 ++ bin/tpl/trilium-portable.bat | 3 ++- bin/tpl/trilium-portable.ps1 | 2 ++ bin/tpl/trilium-safe-mode.bat | 3 ++- bin/tpl/trilium-safe-mode.ps1 | 2 ++ 7 files changed, 13 insertions(+), 6 deletions(-) create mode 100644 bin/tpl/trilium-no-cert-check.ps1 create mode 100644 bin/tpl/trilium-portable.ps1 create mode 100644 bin/tpl/trilium-safe-mode.ps1 diff --git a/bin/build-win-x64.sh b/bin/build-win-x64.sh index 68ce53001..c1b8030e4 100755 --- a/bin/build-win-x64.sh +++ b/bin/build-win-x64.sh @@ -27,9 +27,7 @@ rm -r $BUILD_DIR/swiftshader cp bin/tpl/anonymize-database.sql $BUILD_DIR/ -cp bin/tpl/trilium-portable.bat $BUILD_DIR/ -cp bin/tpl/trilium-no-cert-check.bat $BUILD_DIR/ -cp bin/tpl/trilium-safe-mode.bat $BUILD_DIR/ +cp bin/tpl/trilium-{portable,no-cert-check,safe-mode}.{bat,ps1} $BUILD_DIR/ echo "Zipping windows x64 electron distribution..." VERSION=`jq -r ".version" package.json` diff --git a/bin/tpl/trilium-no-cert-check.bat b/bin/tpl/trilium-no-cert-check.bat index e10fa90ac..01a376685 100644 --- a/bin/tpl/trilium-no-cert-check.bat +++ b/bin/tpl/trilium-no-cert-check.bat @@ -1,4 +1,5 @@ SET DIR=%~dp0 set NODE_TLS_REJECT_UNAUTHORIZED=0 cd %DIR% -start trilium.exe +WHERE powershell.exe +IF %ERRORLEVEL% NEQ 0 (start trilium.exe) ELSE (powershell.exe ./trilium-no-cert-check.ps1) \ No newline at end of file diff --git a/bin/tpl/trilium-no-cert-check.ps1 b/bin/tpl/trilium-no-cert-check.ps1 new file mode 100644 index 000000000..43ea010b9 --- /dev/null +++ b/bin/tpl/trilium-no-cert-check.ps1 @@ -0,0 +1,2 @@ +Set-Item -Path Env:NODE_TLS_REJECT_UNAUTHORIZED -Value 0 +./trilium.exe \ No newline at end of file diff --git a/bin/tpl/trilium-portable.bat b/bin/tpl/trilium-portable.bat index ac6555599..668872d03 100644 --- a/bin/tpl/trilium-portable.bat +++ b/bin/tpl/trilium-portable.bat @@ -1,4 +1,5 @@ SET DIR=%~dp0 SET TRILIUM_DATA_DIR=%DIR%\trilium-data cd %DIR% -start trilium.exe \ No newline at end of file +WHERE powershell.exe +IF %ERRORLEVEL% NEQ 0 (start trilium.exe) ELSE (powershell.exe ./trilium-portable.ps1) \ No newline at end of file diff --git a/bin/tpl/trilium-portable.ps1 b/bin/tpl/trilium-portable.ps1 new file mode 100644 index 000000000..98bd36cb6 --- /dev/null +++ b/bin/tpl/trilium-portable.ps1 @@ -0,0 +1,2 @@ +Set-Item -Path Env:TRILIUM_DATA_DIR -Value './trilium-data' +./trilium.exe \ No newline at end of file diff --git a/bin/tpl/trilium-safe-mode.bat b/bin/tpl/trilium-safe-mode.bat index a40f03bd8..45fb21c07 100644 --- a/bin/tpl/trilium-safe-mode.bat +++ b/bin/tpl/trilium-safe-mode.bat @@ -1,4 +1,5 @@ SET DIR=%~dp0 SET TRILIUM_SAFE_MODE=1 cd %DIR% -start trilium.exe +WHERE powershell.exe +IF %ERRORLEVEL% NEQ 0 (start trilium.exe) ELSE (powershell.exe ./trilium-safe-mode.ps1) \ No newline at end of file diff --git a/bin/tpl/trilium-safe-mode.ps1 b/bin/tpl/trilium-safe-mode.ps1 new file mode 100644 index 000000000..5fafd5c3e --- /dev/null +++ b/bin/tpl/trilium-safe-mode.ps1 @@ -0,0 +1,2 @@ +Set-Item -Path Env:TRILIUM_SAFE_MODE -Value 1 +./trilium.exe \ No newline at end of file