Bläddra i källkod

parameterize patchWebDAV.ps1 and add default values to .bat file (#2251)

Co-authored-by: Armin Schrenk <armin.schrenk@skymatic.de>
Sebastian Stenzel 2 år sedan
förälder
incheckning
90f523bee8
2 ändrade filer med 14 tillägg och 4 borttagningar
  1. 5 1
      dist/win/contrib/patchWebDAV.bat
  2. 9 3
      dist/win/contrib/patchWebDAV.ps1

+ 5 - 1
dist/win/contrib/patchWebDAV.bat

@@ -1,3 +1,7 @@
 @echo off
+:: Default values for Cryptomator builds
+SET LOOPBACK_ALIAS="cryptomator-vault"
+
 cd %~dp0
-powershell -NoLogo -NonInteractive -ExecutionPolicy Unrestricted -Command .\patchWebDAV.ps1
+powershell -NoLogo -NonInteractive -ExecutionPolicy Unrestricted -Command .\patchWebDAV.ps1^
+ -LoopbackAlias %LOOPBACK_ALIAS%

+ 9 - 3
dist/win/contrib/patchWebDAV.ps1

@@ -1,10 +1,16 @@
 #Requires -RunAsAdministrator
+Param(
+	[Parameter(Mandatory, HelpMessage="Please provide an alias for 127.0.0.1")][string] $LoopbackAlias
+)
 
-# Adds for address 127.0.0.1 the 'cryptomator-vault' alias to the hosts file
+# Adds an alias for 127.0.0.1 to the hosts file
 function Add-AliasToHost {
+    param (
+        [string]$LoopbackAlias
+    )
     $sysdir = [Environment]::SystemDirectory
     $hostsFile = "$sysdir\drivers\etc\hosts"
-    $aliasLine = '127.0.0.1 cryptomator-vault'
+    $aliasLine = "127.0.0.1 $LoopbackAlias"
 
     foreach ($line in Get-Content $hostsFile) {
         if ($line -eq $aliasLine){
@@ -49,7 +55,7 @@ function Edit-ProviderOrder {
 }
 
 
-Add-AliasToHost
+Add-AliasToHost $LoopbackAlias
 Write-Output 'Ensured alias exists in hosts file'
 
 Set-WebDAVFileSizeLimit