Add cryptomator-vault alias to etc/hosts during (re)install (#1914)

Co-authored-by: Armin Schrenk <armin.schrenk@skymatic.de>
This commit is contained in:
Sebastian Stenzel
2021-11-29 16:37:23 +01:00
committed by GitHub
parent 9b8661fe3c
commit 2808d777e0
5 changed files with 24 additions and 2 deletions

2
dist/win/build.bat vendored
View File

@@ -1,2 +1,2 @@
@echo off
powershell -NoExit -ExecutionPolicy Unrestricted -Command .\build.ps1
powershell -NoLogo -NoExit -ExecutionPolicy Unrestricted -Command .\build.ps1

1
dist/win/build.ps1 vendored
View File

@@ -68,7 +68,6 @@ Copy-Item "$buildDir\..\..\target\cryptomator-*.jar" -Destination "$buildDir\..\
Copy-Item "contrib\*" -Destination "Cryptomator"
attrib -r "Cryptomator\Cryptomator.exe"
# create .msi bundle
$Env:JP_WIXWIZARD_RESOURCES = "$buildDir\resources"
& "$Env:JAVA_HOME\bin\jpackage" `

3
dist/win/contrib/patchHosts.bat vendored Normal file
View File

@@ -0,0 +1,3 @@
@echo off
cd %~dp0
powershell -NoLogo -NonInteractive -ExecutionPolicy Unrestricted -Command .\patchHosts.ps1

16
dist/win/contrib/patchHosts.ps1 vendored Normal file
View File

@@ -0,0 +1,16 @@
#Requires -RunAsAdministrator
$sysdir = [Environment]::SystemDirectory
$hostsFile = "$sysdir\drivers\etc\hosts"
$aliasLine = '127.0.0.1 cryptomator-vault'
foreach ($line in Get-Content $hostsFile) {
if ($line -eq $aliasLine){
Write-Output 'No changes necessary'
exit 0
}
}
Add-Content -Path $hostsFile -Encoding ascii -Value "`r`n$aliasLine"
Write-Output 'Added alias to hosts file'
exit 0

View File

@@ -124,6 +124,8 @@
<CustomAction Id="JpSetARPURLUPDATEINFO" Property="ARPURLUPDATEINFO" Value="$(var.JpUpdateURL)" />
<?endif?>
<CustomAction Id="PatchHostsFile" Impersonate="no" ExeCommand="[INSTALLDIR]patchHosts.bat" Directory="INSTALLDIR" Execute="deferred" Return="asyncWait" />
<?ifdef JpIcon ?>
<Property Id="ARPPRODUCTICON" Value="JpARPPRODUCTICON"/>
<Icon Id="JpARPPRODUCTICON" SourceFile="$(var.JpIcon)"/>
@@ -153,6 +155,8 @@
<Custom Action="JpDisallowDowngrade" After="FindRelatedProducts">JP_DOWNGRADABLE_FOUND</Custom>
<?endif?>
<RemoveExistingProducts Before="CostInitialize"/>
<Custom Action="PatchHostsFile" After="InstallFiles">NOT Installed OR REINSTALL</Custom>
</InstallExecuteSequence>
<WixVariable Id="WixUIBannerBmp" Value="$(env.JP_WIXWIZARD_RESOURCES)\banner.bmp" />