# Maily installer for Windows (x64), in PowerShell: # # irm https://maily.thanaelfontaine.eu/install.ps1 | iex # # Downloads the latest release from GitHub (https://github.com/ThanaelFontaine/Maily/releases), # checks it against its published SHA-256, installs it in %LOCALAPPDATA%\Programs\Maily and adds # Maily to the Start menu. Running it again updates Maily. Your accounts and mail live in the data # folder and are kept. No administrator rights needed. # # Options (environment variables): $env:MAILY_VERSION = "0.9.0" installs that version, # $env:MAILY_INSTALL_DIR = "C:\path" installs somewhere else. & { $ErrorActionPreference = 'Stop' $ProgressPreference = 'SilentlyContinue' # the progress bar slows Invoke-WebRequest down a lot [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 $repo = 'ThanaelFontaine/Maily' $site = 'https://maily.thanaelfontaine.eu' if (-not [Environment]::Is64BitOperatingSystem) { throw "Maily: the ready-made app needs 64-bit Windows. Run Maily from source: https://github.com/$repo#option-b-run-from-source" } # The version: the one asked for, or the latest release. $version = $env:MAILY_VERSION if (-not $version) { $release = Invoke-RestMethod -UseBasicParsing -Uri "https://api.github.com/repos/$repo/releases/latest" -Headers @{ 'User-Agent' = 'Maily-installer' } $version = $release.tag_name } $version = $version.TrimStart('v') if ($version -notmatch '^\d+(\.\d+)*$') { throw "Maily: could not find the latest version (got: $version)." } $file = "Maily-$version-windows-x64.zip" $url = "https://github.com/$repo/releases/download/v$version/$file" $tmp = Join-Path ([IO.Path]::GetTempPath()) ("maily-" + [Guid]::NewGuid().ToString('N')) New-Item -ItemType Directory -Path $tmp | Out-Null try { Write-Host "Downloading Maily $version for Windows..." Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile (Join-Path $tmp $file) Invoke-WebRequest -UseBasicParsing -Uri "$url.sha256" -OutFile (Join-Path $tmp "$file.sha256") # The .sha256 file reads " ". $expected = ((Get-Content -Raw (Join-Path $tmp "$file.sha256")).Trim() -split '\s+')[0] $actual = (Get-FileHash -Algorithm SHA256 -Path (Join-Path $tmp $file)).Hash if (-not $expected -or $expected -ne $actual) { # -ne ignores case throw "Maily: the download does not match its SHA-256 checksum. Nothing was installed." } Write-Host "Checksum verified." if (Get-Process -Name Maily -ErrorAction SilentlyContinue) { throw "Maily: Maily is open. Close it, then run this command again." } $dest = $env:MAILY_INSTALL_DIR if (-not $dest) { $dest = Join-Path $env:LOCALAPPDATA 'Programs\Maily' } Expand-Archive -Path (Join-Path $tmp $file) -DestinationPath (Join-Path $tmp 'x') -Force $new = Join-Path $tmp 'x\Maily' if (-not (Test-Path (Join-Path $new 'Maily.exe'))) { throw "Maily: the archive does not hold Maily\Maily.exe." } New-Item -ItemType Directory -Force -Path (Split-Path $dest) | Out-Null if (Test-Path $dest) { Remove-Item -Recurse -Force $dest } Move-Item -Path $new -Destination $dest $exe = Join-Path $dest 'Maily.exe' # Start menu shortcut, for the current user. $programs = [Environment]::GetFolderPath('Programs') $shell = New-Object -ComObject WScript.Shell $link = $shell.CreateShortcut((Join-Path $programs 'Maily.lnk')) $link.TargetPath = $exe $link.WorkingDirectory = $dest $link.Description = 'All your mailboxes, every AI, one connection' $link.Save() Write-Host "" Write-Host "Maily $version is installed in $dest." Write-Host "Open it from the Start menu (Maily), or run: & '$exe'" Write-Host "If the window stays blank, install the Microsoft Edge WebView2 Runtime: https://developer.microsoft.com/microsoft-edge/webview2/consumer/" Write-Host "" Write-Host "To update Maily later, run the same command again. Maily also tells you when a new version is out." Write-Host "Next: connect your mailboxes and your AIs, $site/#start" } finally { Remove-Item -Recurse -Force $tmp -ErrorAction SilentlyContinue } }