From 74890ee05437f7cc5da91a82f2bbe7c31e2d229f Mon Sep 17 00:00:00 2001 From: Dmitry Ng <19asdek91@gmail.com> Date: Sat, 3 Jun 2023 14:04:23 +0300 Subject: [PATCH] feat: added two agent packages (msi and pkg) to install agent binary to windows and macOS via local package manager --- .github/workflows/build-docker-vxres.yml | 29 +++ .../build-installer-vxagent-linux.yml | 3 +- .../workflows/build-installer-vxagent-osx.yml | 41 ++++ .../build-installer-vxagent-windows.yml | 44 +++++ .github/workflows/ci.yml | 12 +- LICENSE | 2 +- build/package/agent/Dockerfile | 2 +- build/package/agent/build-install-linux.sh | 4 - build/package/agent/build-install-osx.sh | 137 ++++++++++++++ build/package/agent/build.ps1 | 111 +++++++++++ build/package/agent/darwin/Distribution | 34 ++++ .../agent/darwin/Resources/LICENSE.txt | 1 + .../agent/darwin/Resources/conclusion.html | 14 ++ .../agent/darwin/Resources/uninstall.sh | 70 +++++++ .../agent/darwin/Resources/welcome.html | 14 ++ .../package/agent/darwin/scripts/postinstall | 21 ++ build/package/agent/packages.json | 8 + build/package/agent/vxagent.wxs | 179 ++++++++++++++++++ pkg/app/api/docs/docs.go | 3 +- pkg/app/api/docs/swagger.json | 3 +- pkg/app/api/docs/swagger.yaml | 1 + pkg/app/api/server/private/binaries.go | 13 +- .../distributions-page.component.html | 14 +- web/libs/i18n-resources/en-US/shared.json | 1 + web/libs/i18n-resources/ru-RU/shared.json | 1 + .../shared/src/lib/types/operation-systems.ts | 3 +- 26 files changed, 750 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/build-installer-vxagent-osx.yml create mode 100644 .github/workflows/build-installer-vxagent-windows.yml create mode 100644 build/package/agent/build-install-osx.sh create mode 100644 build/package/agent/build.ps1 create mode 100644 build/package/agent/darwin/Distribution create mode 100644 build/package/agent/darwin/Resources/LICENSE.txt create mode 100644 build/package/agent/darwin/Resources/conclusion.html create mode 100644 build/package/agent/darwin/Resources/uninstall.sh create mode 100644 build/package/agent/darwin/Resources/welcome.html create mode 100644 build/package/agent/darwin/scripts/postinstall create mode 100644 build/package/agent/packages.json create mode 100644 build/package/agent/vxagent.wxs diff --git a/.github/workflows/build-docker-vxres.yml b/.github/workflows/build-docker-vxres.yml index 1e8f47fe..a496d83e 100644 --- a/.github/workflows/build-docker-vxres.yml +++ b/.github/workflows/build-docker-vxres.yml @@ -23,6 +23,22 @@ jobs: - uses: actions/download-artifact@v3 with: name: agent_windows + - uses: actions/download-artifact@v3 + with: + name: agent_deb + path: agent_deb + - uses: actions/download-artifact@v3 + with: + name: agent_rpm + path: agent_rpm + - uses: actions/download-artifact@v3 + with: + name: agent_pkg + path: agent_pkg + - uses: actions/download-artifact@v3 + with: + name: agent_msi + path: agent_msi - uses: actions/download-artifact@v3 with: name: decode_environment @@ -30,9 +46,22 @@ jobs: run: | mv build/package/agent/Dockerfile_cross build/package/agent/Dockerfile mkdir build/package/agent/_tmp + # restore agent binaries cp -r agent/_tmp/* build/package/agent/_tmp + # restore agent deb and rpm packages + cp agent_rpm/vxagent-*_i386.rpm build/package/agent/_tmp/linux/386/vxagent.rpm + cp agent_rpm/vxagent-*_amd64.rpm build/package/agent/_tmp/linux/amd64/vxagent.rpm + cp agent_deb/vxagent-*_i386.deb build/package/agent/_tmp/linux/386/vxagent.deb + cp agent_deb/vxagent-*_amd64.deb build/package/agent/_tmp/linux/amd64/vxagent.deb + # restore agent pkg package + cp agent_pkg/vxagent-*_amd64.pkg build/package/agent/_tmp/darwin/amd64/vxagent.pkg + # restore agent msi packages + cp agent_msi/vxagent-*_x86.msi build/package/agent/_tmp/windows/386/vxagent.msi + cp agent_msi/vxagent-*_x64.msi build/package/agent/_tmp/windows/amd64/vxagent.msi + # set executable flag for linux and macOS binaries chmod +x build/package/agent/_tmp/linux/*/vxagent chmod +x build/package/agent/_tmp/darwin/*/vxagent + # enumerate restored files ls -R build/package/agent/_tmp - name: Docker build vxres uses: ./.github/actions/docker_build diff --git a/.github/workflows/build-installer-vxagent-linux.yml b/.github/workflows/build-installer-vxagent-linux.yml index 4f31831c..32c8b75c 100644 --- a/.github/workflows/build-installer-vxagent-linux.yml +++ b/.github/workflows/build-installer-vxagent-linux.yml @@ -25,11 +25,12 @@ jobs: mkdir build/package/agent/_tmp cp -r agent/_tmp/* build/package/agent/_tmp ls -R build/package/agent/_tmp - - name: Build installer + - name: Build Linux installer run: | cd build/package/agent chmod +x build-install-linux.sh ./build-install-linux.sh + - name: Upload result for deb installer uses: actions/upload-artifact@v3 with: diff --git a/.github/workflows/build-installer-vxagent-osx.yml b/.github/workflows/build-installer-vxagent-osx.yml new file mode 100644 index 00000000..214a6b0a --- /dev/null +++ b/.github/workflows/build-installer-vxagent-osx.yml @@ -0,0 +1,41 @@ +name: VXAgent installer build + +on: workflow_call + +jobs: + build_installer_osx: + name: Installer build + environment: + name: production + runs-on: macos-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - uses: actions/download-artifact@v3 + with: + name: agent_osx + - uses: actions/download-artifact@v3 + with: + name: decode_environment + - name: prepare files + run: | + mkdir build/package/agent/_tmp + cp -r agent/_tmp/* build/package/agent/_tmp + ls -R build/package/agent/_tmp + shell: bash + - name: Build macOS installer + run: | + cd build/package/agent + chmod +x build-install-osx.sh + VERSION=$(cat _tmp/version) ./build-install-osx.sh + cp install_osx/vxagent-*_amd64.pkg _tmp/darwin/amd64/vxagent.pkg + + - name: Upload result for pkg installer + uses: actions/upload-artifact@v3 + with: + name: agent_pkg + path: | + build/package/agent/install_osx/*.pkg diff --git a/.github/workflows/build-installer-vxagent-windows.yml b/.github/workflows/build-installer-vxagent-windows.yml new file mode 100644 index 00000000..cb336d18 --- /dev/null +++ b/.github/workflows/build-installer-vxagent-windows.yml @@ -0,0 +1,44 @@ +name: VXAgent installer build + +on: workflow_call + +jobs: + build_installer_windows: + name: Installer build + environment: + name: production + runs-on: windows-2019 + + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - uses: actions/download-artifact@v3 + with: + name: agent_windows + - uses: actions/download-artifact@v3 + with: + name: decode_environment + - name: prepare files + run: | + mkdir build/package/agent/_tmp + cp -r agent/_tmp/* build/package/agent/_tmp + ls -R build/package/agent/_tmp + shell: bash + - name: Set path for heat.exe and light.exe + run: echo "$WIX\\bin" >>$GITHUB_PATH + shell: bash + - name: Build Windows installer + run: | + cd build/package/agent + pwsh -ExecutionPolicy Bypass -File build.ps1 packages.json vxagent + mkdir install_windows + cp dist/*.msi install_windows/ + + - name: Upload result for msi installer + uses: actions/upload-artifact@v3 + with: + name: agent_msi + path: | + build/package/agent/install_windows/*.msi diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 853b2abf..253aed55 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -64,7 +64,7 @@ jobs: build_docker_vxres: uses: vxcontrol/soldr/.github/workflows/build-docker-vxres.yml@master if: github.ref_name == 'master' || startsWith(github.ref, 'refs/tags') - needs: [ build_agent_linux, build_agent_windows, build_agent_osx ] + needs: [ build_installer_vxagent_linux, build_installer_vxagent_windows, build_installer_vxagent_osx ] secrets: inherit build_docker_vxserver: uses: vxcontrol/soldr/.github/workflows/build-docker-vxserver.yml@master @@ -82,3 +82,13 @@ jobs: if: github.ref_name == 'master' || startsWith(github.ref, 'refs/tags') needs: build_agent_linux secrets: inherit + build_installer_vxagent_windows: + uses: vxcontrol/soldr/.github/workflows/build-installer-vxagent-windows.yml@master + if: github.ref_name == 'master' || startsWith(github.ref, 'refs/tags') + needs: build_agent_windows + secrets: inherit + build_installer_vxagent_osx: + uses: vxcontrol/soldr/.github/workflows/build-installer-vxagent-osx.yml@master + if: github.ref_name == 'master' || startsWith(github.ref, 'refs/tags') + needs: build_agent_osx + secrets: inherit diff --git a/LICENSE b/LICENSE index 593b9015..b0557187 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2022 VXControl SOLDR +Copyright (c) 2023 VXControl SOLDR Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/build/package/agent/Dockerfile b/build/package/agent/Dockerfile index 72b7fe9c..3eb2318d 100755 --- a/build/package/agent/Dockerfile +++ b/build/package/agent/Dockerfile @@ -10,7 +10,7 @@ RUN mkdir -p /opt/vxagent/bin && \ COPY build/package/agent/preparing.sh /opt/vxagent/bin/ COPY build/package/agent/_tmp/version /opt/vxagent/bin/ -COPY build/package/agent/_tmp/linux/amd64/vxagent /opt/vxagent/bin/ +COPY build/package/agent/_tmp/linux/amd64/vxbundle /opt/vxagent/bin/vxagent COPY build/package/agent/_tmp/deps/libraries_amd64.tar.gz /opt/vxagent/deps/ RUN mkdir -p /usr/lib/vxagent && \ diff --git a/build/package/agent/build-install-linux.sh b/build/package/agent/build-install-linux.sh index 7e9587ed..d777df2b 100644 --- a/build/package/agent/build-install-linux.sh +++ b/build/package/agent/build-install-linux.sh @@ -35,7 +35,6 @@ md5deep -r vxagent/opt/vxcontrol/vxagent > vxagent/DEBIAN/md5sums chmod -R 755 vxagent/DEBIAN fakeroot dpkg-deb -Zxz --build vxagent vxagent-${VERSION}_${arch}.deb || exit 1 -cp vxagent-${VERSION}_${arch}.deb _tmp/linux/386/vxagent.deb echo "Done create deb $arch" @@ -66,7 +65,6 @@ md5deep -r vxagent/opt/vxcontrol/vxagent > vxagent/DEBIAN/md5sums chmod -R 755 vxagent/DEBIAN fakeroot dpkg-deb -Zxz --build vxagent vxagent-${VERSION}_${arch}.deb || exit 1 -cp vxagent-${VERSION}_${arch}.deb _tmp/linux/amd64/vxagent.deb echo "Done create deb $arch" @@ -83,7 +81,6 @@ cp vxagent.service ~/rpmbuild/SOURCES/vxagent/unit/ rpmbuild -bb ./rpm_$arch.spec --target i386 cp ~/rpmbuild/RPMS/i386/* install_linux/vxagent-${VERSION}_i386.rpm -cp install_linux/vxagent-${VERSION}_i386.rpm _tmp/linux/386/vxagent.rpm arch="amd64" rm -rf ~/rpmbuild/SOURCES/* || true @@ -95,4 +92,3 @@ cp vxagent.service ~/rpmbuild/SOURCES/vxagent/unit/ eval "echo \"$(cat RPM/rpm.spec)\"" > rpm_$arch.spec rpmbuild -bb ./rpm_$arch.spec --target amd64 cp ~/rpmbuild/RPMS/amd64/* install_linux/vxagent-${VERSION}_amd64.rpm -cp install_linux/vxagent-${VERSION}_amd64.rpm _tmp/linux/amd64/vxagent.rpm diff --git a/build/package/agent/build-install-osx.sh b/build/package/agent/build-install-osx.sh new file mode 100644 index 00000000..86f0fd60 --- /dev/null +++ b/build/package/agent/build-install-osx.sh @@ -0,0 +1,137 @@ +#!/bin/bash +set -e + +TARGET_DIRECTORY="target" +PRODUCT="vxagent" +OUTPUT_PATH="install_osx" +export VERSION=${VERSION/v/} +export VERSION=${VERSION%-*} + + +log_info() { + echo "${LOG_PREFIX}[INFO]" $1 +} + +log_warn() { + echo "${LOG_PREFIX}[WARN]" $1 +} + +log_error() { + echo "${LOG_PREFIX}[ERROR]" $1 +} + +deleteInstallationDirectory() { + log_info "Cleaning $TARGET_DIRECTORY directory." + rm -rf $TARGET_DIRECTORY + + if [[ $? != 0 ]]; then + log_error "Failed to clean $TARGET_DIRECTORY directory" $? + exit 1 + fi +} + +createInstallationDirectory() { + if [ -d ${TARGET_DIRECTORY} ]; then + deleteInstallationDirectory + fi + mkdir -p $TARGET_DIRECTORY + + if [[ $? != 0 ]]; then + log_error "Failed to create $TARGET_DIRECTORY directory" $? + exit 1 + fi +} + +deleteOutputPath() { + log_info "Cleaning ${OUTPUT_PATH} directory." + rm -rf ${OUTPUT_PATH} + + if [[ $? != 0 ]]; then + log_error "Failed to clean ${OUTPUT_PATH} directory" $? + exit 1 + fi +} + +createOutputPath() { + if [ -d ${OUTPUT_PATH} ]; then + deleteOutputPath + fi + mkdir -p ${OUTPUT_PATH} + + if [[ $? != 0 ]]; then + log_error "Failed to create $TARGET_DIRECTORY directory" $? + exit 1 + fi + +} + +copyDarwinDirectory() { + createInstallationDirectory + createOutputPath + cp -r darwin ${TARGET_DIRECTORY}/ + chmod -R 755 ${TARGET_DIRECTORY}/darwin +} + +copyBuildDirectory() { + sed -i '' -e 's/__VERSION__/'${VERSION}'/g;s/__PRODUCT__/'${PRODUCT}'/g' ${TARGET_DIRECTORY}/darwin/scripts/postinstall + sed -i '' -e 's/__VERSION__/'${VERSION}'/g;s/__PRODUCT__/'${PRODUCT}'/g' ${TARGET_DIRECTORY}/darwin/Distribution + sed -i '' -e 's/__VERSION__/'${VERSION}'/g;s/__PRODUCT__/'${PRODUCT}'/g' ${TARGET_DIRECTORY}/darwin/Resources/*.html + + rm -rf ${TARGET_DIRECTORY}/darwinpkg + mkdir -p ${TARGET_DIRECTORY}/darwinpkg + + #Copy product to /Library/PRODUCT + mkdir -p ${TARGET_DIRECTORY}/darwinpkg/Library/${PRODUCT} + log_info "Try signing executable file" + cp -a _tmp/darwin/amd64/vxagent ${TARGET_DIRECTORY}/darwinpkg/Library/${PRODUCT} + chmod -R 755 ${TARGET_DIRECTORY}/darwinpkg/Library/${PRODUCT} + + rm -rf ${TARGET_DIRECTORY}/package + mkdir -p ${TARGET_DIRECTORY}/package + chmod -R 755 ${TARGET_DIRECTORY}/package + + rm -rf ${TARGET_DIRECTORY}/pkg + mkdir -p ${TARGET_DIRECTORY}/pkg + chmod -R 755 ${TARGET_DIRECTORY}/pkg +} + +function buildPackage() { + log_info "Application installer package building started.(1/2)" + pkgbuild --identifier org.${PRODUCT}.${VERSION} \ + --version ${VERSION} \ + --scripts ${TARGET_DIRECTORY}/darwin/scripts \ + --root ${TARGET_DIRECTORY}/darwinpkg \ + ${TARGET_DIRECTORY}/package/${PRODUCT}.pkg >/dev/null 2>&1 +} + +function buildProduct() { + log_info "Application installer product building started.(2/2)" + productbuild --distribution ${TARGET_DIRECTORY}/darwin/Distribution \ + --resources ${TARGET_DIRECTORY}/darwin/Resources \ + --package-path ${TARGET_DIRECTORY}/package \ + ${TARGET_DIRECTORY}/pkg/$1 >/dev/null 2>&1 +} + +function createInstaller() { + log_info "Application installer generation process started.(2 Steps)" + buildPackage + buildProduct ${PRODUCT}-${VERSION}_amd64.pkg + mv ${TARGET_DIRECTORY}/pkg/${PRODUCT}-${VERSION}_amd64.pkg ${OUTPUT_PATH}/${PRODUCT}-${VERSION}_amd64.pkg + log_info "Application installer generation steps finished." +} + +function createUninstaller() { + cp darwin/Resources/uninstall.sh ${TARGET_DIRECTORY}/darwinpkg/Library/${PRODUCT} + sed -i '' -e "s/__VERSION__/${VERSION}/g;s/__PRODUCT__/${PRODUCT}/g" "${TARGET_DIRECTORY}/darwinpkg/Library/${PRODUCT}/uninstall.sh" +} + + +log_info "Installer generating process started." + +copyDarwinDirectory +copyBuildDirectory +createUninstaller +createInstaller + +log_info "Installer generating process finished" +exit 0 diff --git a/build/package/agent/build.ps1 b/build/package/agent/build.ps1 new file mode 100644 index 00000000..65f732f6 --- /dev/null +++ b/build/package/agent/build.ps1 @@ -0,0 +1,111 @@ +param( + [parameter(mandatory = $true)] + [String] + $ConfigFile = "packages.json", + + [parameter(mandatory = $true)] + [String] + $PackageName = "vxagent" +) + +function New-AgentMSI +{ + param( + [parameter(mandatory = $true)] + [String] + $WIXFile, + + [parameter(mandatory = $true)] + [String] + $PathToAgentExe, + + [parameter(mandatory = $true)] + [String] + $Arch, + + [parameter(mandatory = $true)] + [String] + $PackageVersion, + + [String] + $Name, + + [PSCustomObject] + $Parameters, + + [String] + $OutDir + ) + + $candleArgs = @( + "-sw1150", # suppress warning about the ServiceConfig field in the vxagent.wsx file + "-arch", "$Arch", + "-ext", "WixUtilExtension", + "-dAgentSourceExecutable=$PathToAgentExe", + "-dProductVersion=$PackageVersion" + ) + + $FileName = "{0}-{1}_{2}" -f $PackageName, $PackageVersion, $Arch + $FileName = Join-Path $OutDir $FileName + $candleArgs += "-o", "$FileName.wsxobj" + $candleArgs += "$WIXFile" + + foreach ($Parameter in $Parameters.PSObject.Properties) + { + $candleArgs += "-d$($Parameter.Name)=$($Parameter.Value)" + } + + $OutputFileName = "$FileName.msi" + $lightArgs = @( + "-sw1076", + "-ext", "WixUtilExtension", + "-o", $OutputFileName, + "$FileName.wsxobj" + ) + + Write-Host "Compiling..." + "candle.exe $candleArgs" + & candle.exe $candleArgs + if ($LASTEXITCODE -ne 0) { throw } + + Write-Host "Linking..." + "light.exe $lightArgs" + & light.exe $lightArgs + if ($LASTEXITCODE -ne 0) { throw } + + Write-Host "MSI File: $OutputFileName" +} + +#------------------------------------------------------------------------------- + +$version = [IO.File]::ReadAllText("_tmp/version") +$PackageVersion = (($version -Split "v")[1] -Split "-")[0] +$Config = Get-Content $ConfigFile -Encoding UTF8 | ConvertFrom-Json + +if ([String]::IsNullOrEmpty($env:WIX)) +{ + Write-Warning "WIX env var is not set" +} +else +{ + Write-Host "WIX: $env:WIX" +} + +#------------------------------------------------------------------------------- + +Write-Host "=========== Building VXAgent MSI ===========" +foreach ($AgentArch in $Config.AgentArch.PSObject.Properties) +{ + $MSIConfig = + @{ + Arch = $AgentArch.Name + PathToAgentExe = $AgentArch.Value + WIXFile = $Config.WIXFile + OutDir = $Config.OutDir + PackageVersion = $PackageVersion + } + + Write-Host "=========== Build for $($MSIConfig.Arch)" + New-AgentMSI @MSIConfig + Write-Host "===============================================================================" +} diff --git a/build/package/agent/darwin/Distribution b/build/package/agent/darwin/Distribution new file mode 100644 index 00000000..1b137202 --- /dev/null +++ b/build/package/agent/darwin/Distribution @@ -0,0 +1,34 @@ + + + __PRODUCT__ + + + + + + + + + + + + + + __PRODUCT__.pkg + diff --git a/build/package/agent/darwin/Resources/LICENSE.txt b/build/package/agent/darwin/Resources/LICENSE.txt new file mode 100644 index 00000000..4bab70ba --- /dev/null +++ b/build/package/agent/darwin/Resources/LICENSE.txt @@ -0,0 +1 @@ +VXControl SOLDR All right reserved 2023 \ No newline at end of file diff --git a/build/package/agent/darwin/Resources/conclusion.html b/build/package/agent/darwin/Resources/conclusion.html new file mode 100644 index 00000000..0a21cbdd --- /dev/null +++ b/build/package/agent/darwin/Resources/conclusion.html @@ -0,0 +1,14 @@ + + + + + + +
+

Thank you for installing the VXControl SOLDR Agent.

+
+

+

Copyright © 2023 VXControl. All rights reserved.

+
+ + diff --git a/build/package/agent/darwin/Resources/uninstall.sh b/build/package/agent/darwin/Resources/uninstall.sh new file mode 100644 index 00000000..bfcd022c --- /dev/null +++ b/build/package/agent/darwin/Resources/uninstall.sh @@ -0,0 +1,70 @@ +#!/bin/bash + +#Generate application uninstallers for macOS. + +#Parameters +DATE=`date +%Y-%m-%d` +TIME=`date +%H:%M:%S` +LOG_PREFIX="[$DATE $TIME]" + +#Functions +log_info() { + echo "${LOG_PREFIX}[INFO]" $1 +} + +log_warn() { + echo "${LOG_PREFIX}[WARN]" $1 +} + +log_error() { + echo "${LOG_PREFIX}[ERROR]" $1 +} + +#Check running user +if (( $EUID != 0 )); then + echo "Please run as root." + exit +fi + +CURRENT_VERSION=$(/Library/__PRODUCT__/__PRODUCT__ -version) + +echo "Welcome to Application Uninstaller" +echo "The following packages will be REMOVED:" +echo " __PRODUCT__-${CURRENT_VERSION}" +while true; do + read -p "Do you wish to continue [Y/n]?" answer + [[ $answer == "y" || $answer == "Y" || $answer == "" ]] && break + [[ $answer == "n" || $answer == "N" ]] && exit 0 + echo "Please answer with 'y' or 'n'" +done + + +#Need to replace these with install preparation script +VERSION=__VERSION__ +PRODUCT=__PRODUCT__ + +echo "Application uninstalling process started" + +/Library/${PRODUCT}/${PRODUCT} -command stop || true +/Library/${PRODUCT}/${PRODUCT} -command uninstall || true +#forget from pkgutil +pkgutil --forget "org.$PRODUCT.$VERSION" > /dev/null 2>&1 +if [ $? -eq 0 ] +then + echo "[1/2] [DONE] Successfully deleted application informations" +else + echo "[1/2] [ERROR] Could not delete application informations" >&2 +fi + +#remove application source distribution +rm /Applications/${PRODUCT} || true +[ -e "/Library/${PRODUCT}/${PRODUCT}" ] && rm -rf "/Library/${PRODUCT}" +if [ $? -eq 0 ] +then + echo "[2/2] [DONE] Successfully deleted application" +else + echo "[2/2] [ERROR] Could not delete application" >&2 +fi + +echo "Application uninstall process finished" +exit 0 diff --git a/build/package/agent/darwin/Resources/welcome.html b/build/package/agent/darwin/Resources/welcome.html new file mode 100644 index 00000000..3595e93c --- /dev/null +++ b/build/package/agent/darwin/Resources/welcome.html @@ -0,0 +1,14 @@ + + + + + + +
+
+

This will install VXControl SOLDR Agent __VERSION__ on your computer. You will be guided through the steps necessary to install this software.

+
+

Click Continue to continue the setup.

+
+ + diff --git a/build/package/agent/darwin/scripts/postinstall b/build/package/agent/darwin/scripts/postinstall new file mode 100644 index 00000000..2f937e7e --- /dev/null +++ b/build/package/agent/darwin/scripts/postinstall @@ -0,0 +1,21 @@ +#!/bin/bash + +set -e +set -x + +chmod +x /Library/vxagent/vxagent && chown root:admin /Library/vxagent/vxagent +chmod +x /Library/vxagent/uninstall.sh && chown root:admin /Library/vxagent/uninstall.sh + +ln -s /Library/vxagent /Applications/vxagent || true + +VXSERVER_CONNECT=$(launchctl getenv VXSERVER_CONNECT) + +if [ -n "$VXSERVER_CONNECT" ]; then + /Library/vxagent/vxagent -connect $VXSERVER_CONNECT -command install +else + /Library/vxagent/vxagent -command install +fi + +/Library/vxagent/vxagent -command start + +launchctl unsetenv VXSERVER_CONNECT \ No newline at end of file diff --git a/build/package/agent/packages.json b/build/package/agent/packages.json new file mode 100644 index 00000000..17a51264 --- /dev/null +++ b/build/package/agent/packages.json @@ -0,0 +1,8 @@ +{ + "WIXFile": "vxagent.wxs", + "OutDir": "dist", + "AgentArch": { + "x86": "..\\_tmp\\windows\\386\\vxagent.exe", + "x64": "..\\_tmp\\windows\\amd64\\vxagent.exe" + } +} diff --git a/build/package/agent/vxagent.wxs b/build/package/agent/vxagent.wxs new file mode 100644 index 00000000..19444407 --- /dev/null +++ b/build/package/agent/vxagent.wxs @@ -0,0 +1,179 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Privileged + + + + + + + + + + + + + + + + + + + + + + + + (REMOVE="ALL") AND (NOT UPGRADINGPRODUCTCODE) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pkg/app/api/docs/docs.go b/pkg/app/api/docs/docs.go index c53f8d70..b04fd74b 100644 --- a/pkg/app/api/docs/docs.go +++ b/pkg/app/api/docs/docs.go @@ -1137,7 +1137,8 @@ const docTemplate = `{ "bin", "msi", "deb", - "rpm" + "rpm", + "pkg" ], "type": "string", "default": "bin", diff --git a/pkg/app/api/docs/swagger.json b/pkg/app/api/docs/swagger.json index 2ee58c47..26fa6d5a 100644 --- a/pkg/app/api/docs/swagger.json +++ b/pkg/app/api/docs/swagger.json @@ -1129,7 +1129,8 @@ "bin", "msi", "deb", - "rpm" + "rpm", + "pkg" ], "type": "string", "default": "bin", diff --git a/pkg/app/api/docs/swagger.yaml b/pkg/app/api/docs/swagger.yaml index f7d0d66f..89d79a47 100644 --- a/pkg/app/api/docs/swagger.yaml +++ b/pkg/app/api/docs/swagger.yaml @@ -2791,6 +2791,7 @@ paths: - msi - deb - rpm + - pkg in: path name: package required: true diff --git a/pkg/app/api/server/private/binaries.go b/pkg/app/api/server/private/binaries.go index 7442bd51..956748a4 100644 --- a/pkg/app/api/server/private/binaries.go +++ b/pkg/app/api/server/private/binaries.go @@ -161,7 +161,7 @@ func (s *BinariesService) GetAgentBinaryFile(c *gin.Context) { // @Param os path string true "agent info OS" default(linux) Enums(windows, linux, darwin) // @Param arch path string true "agent info arch" default(amd64) Enums(386, amd64) // @Param version path string true "agent version string according semantic version format" default(latest) -// @Param package path string true "agent package type" default(bin) Enums(bin, msi, deb, rpm) +// @Param package path string true "agent package type" default(bin) Enums(bin, msi, deb, rpm, pkg) // @Success 200 {file} file "agent package or binary as a file" // @Failure 400 {object} response.errorResp "invalid agent info" // @Failure 403 {object} response.errorResp "getting agent package or binary file not permitted" @@ -197,6 +197,13 @@ func (s *BinariesService) getAgentBinaryFile(c *gin.Context, packageType string) response.Error(c, response.ErrAgentBinaryFileInvalidPackageType, unsupportedOS) return } + case "pkg": + if agentOS == "darwin" { + extension = fmt.Sprintf(".%s", packageType) + } else { + response.Error(c, response.ErrAgentBinaryFileInvalidPackageType, unsupportedOS) + return + } case "deb", "rpm": if agentOS == "linux" { extension = fmt.Sprintf(".%s", packageType) @@ -213,7 +220,7 @@ func (s *BinariesService) getAgentBinaryFile(c *gin.Context, packageType string) response.Error(c, response.ErrAgentBinaryFileInvalidPackageType, unsupportedPackageType) return } - agentName = fmt.Sprintf("%s%s", agentName, extension) + agentNameExt := fmt.Sprintf("%s%s", agentName, extension) uaf.ObjectDisplayName = fmt.Sprintf("%s_%s_%s_%s", agentName, agentOS, agentArch, packageType) if err := validate.Var(agentOS, "oneof=windows linux darwin,required"); err != nil { @@ -251,7 +258,7 @@ func (s *BinariesService) getAgentBinaryFile(c *gin.Context, packageType string) } uaf.ObjectID = binary.Hash - path := filepath.Join("vxagent", binary.Version, agentOS, agentArch, agentName) + path := filepath.Join("vxagent", binary.Version, agentOS, agentArch, agentNameExt) if chksums, ok = binary.Info.Chksums[path]; !ok { logger.FromContext(c).Errorf("error getting agent binary file check sums: '%s' not found", path) response.Error(c, response.ErrAgentBinaryFileNotFound, nil) diff --git a/web/libs/features/distributions/src/lib/routes/distributions-page/distributions-page.component.html b/web/libs/features/distributions/src/lib/routes/distributions-page/distributions-page.component.html index 22a85f0a..036a392f 100644 --- a/web/libs/features/distributions/src/lib/routes/distributions-page/distributions-page.component.html +++ b/web/libs/features/distributions/src/lib/routes/distributions-page/distributions-page.component.html @@ -127,9 +127,21 @@ + + + + diff --git a/web/libs/i18n-resources/en-US/shared.json b/web/libs/i18n-resources/en-US/shared.json index a3b7788b..62557e24 100644 --- a/web/libs/i18n-resources/en-US/shared.json +++ b/web/libs/i18n-resources/en-US/shared.json @@ -237,6 +237,7 @@ "Shared.Os.Text.Package.Deb": "DEB", "Shared.Os.Text.Package.Rpm": "RPM", "Shared.Os.Text.Package.Msi": "MSI", + "Shared.Os.Text.Package.Pkg": "PKG", "Shared.PasswordForm.Hint.Digit": "Number", "Shared.PasswordForm.Hint.LatinAndSpecialSymbols": "Only Latin letters, numbers, special characters and a space character", diff --git a/web/libs/i18n-resources/ru-RU/shared.json b/web/libs/i18n-resources/ru-RU/shared.json index 0e699870..fbf6a481 100644 --- a/web/libs/i18n-resources/ru-RU/shared.json +++ b/web/libs/i18n-resources/ru-RU/shared.json @@ -237,6 +237,7 @@ "Shared.Os.Text.Package.Deb": "DEB", "Shared.Os.Text.Package.Rpm": "RPM", "Shared.Os.Text.Package.Msi": "MSI", + "Shared.Os.Text.Package.Pkg": "PKG", "Shared.PasswordForm.Hint.Digit": "Цифра", "Shared.PasswordForm.Hint.LatinAndSpecialSymbols": "Только латинские буквы, цифры, спецсимволы и пробел", diff --git a/web/libs/shared/src/lib/types/operation-systems.ts b/web/libs/shared/src/lib/types/operation-systems.ts index 36af2110..e40f1b23 100644 --- a/web/libs/shared/src/lib/types/operation-systems.ts +++ b/web/libs/shared/src/lib/types/operation-systems.ts @@ -13,7 +13,8 @@ export enum Package { Bin = 'bin', Deb = 'deb', Rpm = 'rpm', - Msi = 'msi' + Msi = 'msi', + Pkg = 'pkg' } export type OperationSystemsList = Record;