Current section

Files

Jump to
gcourier priv windows aarch64 mailpit.bat
Raw

priv/windows/aarch64/mailpit.bat

@echo off
setlocal enabledelayedexpansion
REM Get the directory where this stub is located
set "STUB_DIR=%~dp0"
set "MAILPIT_BINARY=%STUB_DIR%mailpit.exe"
REM If binary exists, immediately execute it and exit
if exist "%MAILPIT_BINARY%" (
"%MAILPIT_BINARY%" %*
exit /b %ERRORLEVEL%
)
REM Binary doesn't exist, so download it
echo Mailpit binary not found. Downloading...
set "BASE_URL=https://github.com/axllent/mailpit/releases/download/v1.24.2"
set "TMP_DIR=%TEMP%\mailpit-download-%RANDOM%"
REM Determine architecture
if "%PROCESSOR_ARCHITECTURE%"=="AMD64" (
set "ARCH=amd64"
) else if "%PROCESSOR_ARCHITECTURE%"=="ARM64" (
set "ARCH=arm64"
) else (
echo Unsupported architecture: %PROCESSOR_ARCHITECTURE% >&2
exit /b 1
)
set "ARCHIVE_NAME=mailpit-windows-!ARCH!.zip"
set "DOWNLOAD_URL=%BASE_URL%/!ARCHIVE_NAME!"
mkdir "%TMP_DIR%"
REM Download using curl (available in Windows 10+)
echo Downloading !DOWNLOAD_URL!
curl -fsSL "!DOWNLOAD_URL!" -o "%TMP_DIR%\!ARCHIVE_NAME!"
REM Extract using tar (available in Windows 10+)
echo Extracting...
tar -xf "%TMP_DIR%\!ARCHIVE_NAME!" -C "%TMP_DIR%"
REM Move binary to the expected location
move "%TMP_DIR%\mailpit.exe" "%MAILPIT_BINARY%"
REM Cleanup
rmdir /s /q "%TMP_DIR%"
echo Download complete!
REM Now execute the binary
"%MAILPIT_BINARY%" %*
exit /b %ERRORLEVEL%