mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-05-14 00:31:27 +00:00
Merge pull request #4228 from jose-cardoso-a22506616/issue-3993
Closes #3993
This commit is contained in:
committed by
GitHub
parent
2fe7fe886c
commit
472b10a8a4
5
dist/win/contrib/patchWebDAV.bat
vendored
5
dist/win/contrib/patchWebDAV.bat
vendored
@@ -4,15 +4,18 @@
|
||||
:: This file must be located in the INSTALLDIR
|
||||
|
||||
set "LOOPBACK_ALIAS=%1"
|
||||
set "ACTION=%2"
|
||||
if "%ACTION%"=="" set "ACTION=install"
|
||||
|
||||
:: Log for debugging
|
||||
echo LOOPBACK_ALIAS=%LOOPBACK_ALIAS%
|
||||
echo ACTION=%ACTION%
|
||||
|
||||
:: Change to INSTALLDIR
|
||||
cd %~dp0
|
||||
:: Execute the PowerShell script
|
||||
powershell -NoLogo -NoProfile -NonInteractive -ExecutionPolicy RemoteSigned -File .\patchWebDAV.ps1^
|
||||
-LoopbackAlias %LOOPBACK_ALIAS%
|
||||
-LoopbackAlias %LOOPBACK_ALIAS% -Action %ACTION%
|
||||
|
||||
:: Return the exit code from PowerShell
|
||||
exit /b %ERRORLEVEL%
|
||||
47
dist/win/contrib/patchWebDAV.ps1
vendored
47
dist/win/contrib/patchWebDAV.ps1
vendored
@@ -1,15 +1,17 @@
|
||||
#Requires -RunAsAdministrator
|
||||
Param(
|
||||
[Parameter(Mandatory, HelpMessage="Please provide an alias for 127.0.0.1")][string] $LoopbackAlias
|
||||
[Parameter(Mandatory, HelpMessage="Please provide an alias for 127.0.0.1")][string] $LoopbackAlias,
|
||||
[string] $Action = "install"
|
||||
)
|
||||
|
||||
New-Variable -Name "sysdir" -Value ([Environment]::SystemDirectory) -Option Constant -Scope Global
|
||||
New-Variable -Name "hostsFile" -Value "$sysdir\drivers\etc\hosts" -Option Constant -Scope Global
|
||||
|
||||
# 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 $LoopbackAlias"
|
||||
|
||||
foreach ($line in Get-Content $hostsFile) {
|
||||
@@ -18,9 +20,26 @@ function Add-AliasToHost {
|
||||
}
|
||||
}
|
||||
|
||||
Add-Content -Path $hostsFile -Encoding ascii -Value "`r`n$aliasLine"
|
||||
$content = Get-Content $hostsFile
|
||||
$content += "`r`n$aliasLine"
|
||||
|
||||
$content | Set-Content "$hostsFile.tmp" -Encoding ascii
|
||||
Move-Item "$hostsFile.tmp" $hostsFile -Force
|
||||
}
|
||||
|
||||
# Removes an alias for 127.0.0.1 from the hosts file
|
||||
function Remove-AliasFromHost {
|
||||
param (
|
||||
[string]$LoopbackAlias
|
||||
)
|
||||
$aliasLine = "127.0.0.1 $LoopbackAlias"
|
||||
|
||||
$content = Get-Content $hostsFile
|
||||
$newContent = $content | Where-Object { $_ -ne $aliasLine }
|
||||
|
||||
$newContent | Set-Content "$hostsFile.tmp" -Encoding ascii
|
||||
Move-Item "$hostsFile.tmp" $hostsFile -Force
|
||||
}
|
||||
|
||||
# Sets in the registry the webclient file size limit to the maximum value
|
||||
function Set-WebDAVFileSizeLimit {
|
||||
@@ -54,14 +73,20 @@ function Edit-ProviderOrder {
|
||||
New-ItemProperty -Path $RegistryPath -Name $Name -Value $UpdatedOrder -PropertyType String -Force | Out-Null
|
||||
}
|
||||
|
||||
if ($Action -eq "install") {
|
||||
Add-AliasToHost $LoopbackAlias
|
||||
Write-Output 'Ensured alias exists in hosts file'
|
||||
|
||||
Add-AliasToHost $LoopbackAlias
|
||||
Write-Output 'Ensured alias exists in hosts file'
|
||||
Set-WebDAVFileSizeLimit
|
||||
Write-Output 'Set WebDAV file size limit'
|
||||
|
||||
Set-WebDAVFileSizeLimit
|
||||
Write-Output 'Set WebDAV file size limit'
|
||||
|
||||
Edit-ProviderOrder
|
||||
Write-Output 'Ensured correct provider order'
|
||||
Edit-ProviderOrder
|
||||
Write-Output 'Ensured correct provider order'
|
||||
} elseif ($Action -eq "uninstall") {
|
||||
Remove-AliasFromHost $LoopbackAlias
|
||||
Write-Output 'Ensured alias removed from hosts file'
|
||||
} else {
|
||||
Write-Error "Invalid action: $Action. Only 'install' or 'uninstall' are valid."
|
||||
}
|
||||
|
||||
exit 0
|
||||
|
||||
11
dist/win/resources/main.wxs
vendored
11
dist/win/resources/main.wxs
vendored
@@ -158,9 +158,13 @@
|
||||
<ns0:CustomAction Id="DisableUserConfig" BinaryRef="Wix4UtilCA_$(sys.BUILDARCHSHORT)" DllEntry="WixQuietExec" Execute="deferred" Return="ignore" Impersonate="no"/>
|
||||
|
||||
<!-- WebDAV patches -->
|
||||
<ns0:SetProperty Id="PatchWebDAV" Value=""[INSTALLDIR]patchWebDAV.bat" "$(var.LoopbackAlias)"" Sequence="execute" Before="PatchWebDAV" />
|
||||
<ns0:SetProperty Id="PatchWebDAV" Value=""[INSTALLDIR]patchWebDAV.bat" "$(var.LoopbackAlias)" install" Sequence="execute" Before="PatchWebDAV" />
|
||||
<ns0:CustomAction Id="PatchWebDAV" BinaryRef="Wix4UtilCA_$(sys.BUILDARCHSHORT)" DllEntry="WixQuietExec" Execute="deferred" Return="ignore" Impersonate="no"/>
|
||||
|
||||
<!-- WebDAV patches (Uninstall) -->
|
||||
<ns0:SetProperty Id="PatchWebDAVUninstall" Value=""[INSTALLDIR]patchWebDAV.bat" "$(var.LoopbackAlias)" uninstall" Sequence="execute" Before="PatchWebDAVUninstall" />
|
||||
<ns0:CustomAction Id="PatchWebDAVUninstall" BinaryRef="Wix4UtilCA_$(sys.BUILDARCHSHORT)" DllEntry="WixQuietExec" Execute="deferred" Return="ignore" Impersonate="no"/>
|
||||
|
||||
<!-- Update check configuration -->
|
||||
<ns0:SetProperty Id="PatchUpdateCheck" Value=""[INSTALLDIR]patchUpdateCheck.bat" "[DISABLEUPDATECHECK]"" Sequence="execute" Before="PatchUpdateCheck" />
|
||||
<ns0:CustomAction Id="PatchUpdateCheck" BinaryRef="Wix4UtilCA_$(sys.BUILDARCHSHORT)" DllEntry="WixQuietExec64" Execute="deferred" Return="ignore" Impersonate="no"/>
|
||||
@@ -214,9 +218,8 @@
|
||||
|
||||
<ns0:RemoveExistingProducts After="InstallValidate"/> <!-- Moved from CostInitialize, due to Wix4CloseApplications_* -->
|
||||
<ns0:Custom Action="DisableUserConfig" After="InstallFiles" Condition="NOT (Installed AND (NOT REINSTALL) AND (NOT UPGRADINGPRODUCTCODE) AND REMOVE)"/>
|
||||
<!-- Skip action on uninstall -->
|
||||
<!-- TODO: don't skip action, but remove cryptomator alias from hosts file -->
|
||||
<ns0:Custom Action="PatchWebDAV" After="DisableUserConfig" Condition="NOT (Installed AND (NOT REINSTALL) AND (NOT UPGRADINGPRODUCTCODE) AND REMOVE)"/>
|
||||
<ns0:Custom Action="PatchWebDAVUninstall" Before="RemoveFiles" Condition="Installed AND (NOT REINSTALL) AND (NOT UPGRADINGPRODUCTCODE) AND REMOVE" />
|
||||
<!-- Configure update check setting if property is provided -->
|
||||
<ns0:Custom Action="PatchUpdateCheck" After="PatchWebDAV" Condition="DISABLEUPDATECHECK AND NOT (Installed AND (NOT REINSTALL) AND (NOT UPGRADINGPRODUCTCODE) AND REMOVE)"/>
|
||||
</ns0:InstallExecuteSequence>
|
||||
@@ -228,4 +231,4 @@
|
||||
<ns0:WixVariable Id="WixUIBannerBmp" Value="$(env.JP_WIXWIZARD_RESOURCES)\banner.bmp" />
|
||||
<ns0:WixVariable Id="WixUIDialogBmp" Value="$(env.JP_WIXWIZARD_RESOURCES)\background.bmp" />
|
||||
</ns0:Package>
|
||||
</ns0:Wix>
|
||||
</ns0:Wix>
|
||||
Reference in New Issue
Block a user