### Make Installer Executable and Run (Shell) Source: https://help.swif.ai/en/articles/9903836-how-to-enroll-linux-devices-in-swif This snippet demonstrates how to make the Swif agent installer executable and then run it. It requires root or sudo privileges on the Linux device. The execution starts a GUI wizard for installation. ```shell chmod +x ./SwifAgentInstaller ``` -------------------------------- ### Install Check Script Example (Shell) Source: https://help.swif.ai/en/articles/9579728-custom-software-installation This shell script checks the installed version of Python's argparse. It returns 1 if the version is less than 1.2.1, indicating the application is not installed, and 0 otherwise. This is useful for pre-installation checks. ```shell #!/bin/sh version="$(python -c 'import argparse;print argparse.__version__' 2>/dev/null)" if [ ${version:-0} < 1.2.1 ]; then exit 0 else exit 1 fi ``` -------------------------------- ### Pre-install Command Script Example (PowerShell) Source: https://help.swif.ai/en/articles/9579728-custom-software-installation This PowerShell script checks if a specific application executable exists in the Program Files directory. It returns 0 if the file is found (indicating the app is installed) and 1 otherwise. This script is intended for Windows environments. ```powershell # Pre-Install Command Script Example if (Test-Path "C:\Program Files\App\app.exe") { exit 0 } else { exit 1 } ``` -------------------------------- ### Dynamic Installer Download and Extraction (Shell) Source: https://help.swif.ai/en/articles/9579728-custom-software-installation This shell script demonstrates how to download an installer using a provided URL and then extract it. The `{{URL}}` placeholder is dynamically replaced with the actual S3 URL of the uploaded installer. This is useful for pre-install scripts. ```shell #!/bin/sh curl {{URL}} -o /tmp/installer.zip unzip /tmp/installer.zip -d /Applications ``` -------------------------------- ### Windows Install Check Script Example (PowerShell) Source: https://help.swif.ai/en/articles/9579728-custom-software-installation A PowerShell script that checks for the presence of 'app.exe' within the 'C:\Program Files\MyApp\' directory. It returns an exit code of 1 if the file exists (indicating installation) and 0 if it does not. This script is utilized by Swif for installation verification. ```powershell if (Test-Path "C:\Program Files\MyApp\app.exe") { exit 1 } else { exit 0 } ``` -------------------------------- ### Silent Swif Agent Installation with Flags Source: https://help.swif.ai/en/articles/9903836-how-to-enroll-linux-devices-in-swif This example demonstrates how to initiate a silent installation of the Swif agent using command-line flags. This is useful for automated or headless deployments where user interaction is not possible. Specific flags like --byodCode are used for providing necessary enrollment details without interactive prompts. Dependencies: Swif agent installer script. ```bash # Example of a silent installation command (flags may vary) ./install.sh --byodCode YOUR_ENROLLMENT_CODE --silent ``` -------------------------------- ### Uninstall Script Example (Bash) Source: https://help.swif.ai/en/articles/9579728-custom-software-installation A sample bash script to remove an application. It uses sudo to execute the rm -rf command for forcefully removing application files from the system. It exits with 0 to indicate successful execution. ```bash #!/bin/bash # Sample Uninstall Script /usr/bin/sudo rm -rf /Applications/MyApp.app exit 0 ``` -------------------------------- ### Install Linux Software from Tar Archive using Makefile Source: https://help.swif.ai/en/articles/9579728-custom-software-installation This method explains how to install custom software on Linux using a .tar archive. It requires a Makefile within the archive to automate the installation process after Swif extracts the files. Swif automatically installs 'make' if needed. ```makefile install: # Create the target folder if it doesn't exist mkdir -p /etc/cups/ppd/ # Copy the PPD file into the correct directory cp Epson-AM-C4000_Series_PS.ppd /etc/cups/ppd/ ``` -------------------------------- ### SentinelOne MSI Silent Install Arguments Source: https://help.swif.ai/en/articles/10630376-install-uninstall-sentinelone-agent-macos-windows Provides examples of silent installation arguments for SentinelOne MSI installers, including the use of a site token and quiet installation flags. These arguments ensure a non-interactive installation process. Check SentinelOne documentation for specific version compatibility. ```bash -t /q /norestart ``` ```bash SITE_TOKEN= /q /norestart ``` -------------------------------- ### Create Tar Archive for Linux Installation Source: https://help.swif.ai/en/articles/9579728-custom-software-installation Demonstrates the command-line steps to create a .tar archive containing software files and a Makefile for Linux installation. This archive can then be uploaded to Swif for automated deployment. ```bash cd Epson-AM-C4000_Series_PS tar -cvf Epson-AM-C4000_Series_PS.tar . ``` -------------------------------- ### macOS Install Check Script Example Source: https://help.swif.ai/en/articles/9579728-custom-software-installation This shell script checks the version of a Python package and exits with 0 if the version is less than 1.2.1, indicating it's not installed or an older version. It exits with 1 otherwise. This is used by Swif to validate if an application is installed. ```shell #!/bin/sh version="$(python -c 'import argparse;print argparse.__version__' 2>/dev/null)" if [ ${version:-0} < 1.2.1 ]; then exit 0 else exit 1 fi ``` -------------------------------- ### macOS/Linux Command Script Examples Source: https://help.swif.ai/en/articles/7993112-create-and-run-command Examples of command scripts for macOS and Linux, including how to execute commands with sudo privileges. Ensure to replace '{PASSWORD}' with the actual local user password. ```bash #!/bin/bash # Example command to update package lists sudo apt update # Example to run with sudo using password echo '{PASSWORD}' | sudo -S ls ``` -------------------------------- ### Linux Tar Archive Installation with Pre-Install Script (Bash) Source: https://help.swif.ai/en/articles/9579728-installing-custom-software-via-swif Installs custom software on Linux using a .tar archive by fetching it via a Pre-Install Script. The script uses the {{URL}} placeholder for a signed download link, then extracts and installs the archive. ```bash #!/bin/bash # 1) Download the tar file curl -L -o /tmp/mysoftware.tar "{{URL}}" # 2) Extract it tar -xvf /tmp/mysoftware.tar -C /tmp # (You can do any other custom steps here.) ``` -------------------------------- ### Download and Install Tar Archive using Bash Pre-Install Script Source: https://help.swif.ai/en/articles/9579728-custom-software-installation This bash script demonstrates how to use a pre-install script within Swif to download a .tar archive using a provided URL placeholder ({{URL}}). It then extracts the archive and allows for further custom installation steps. ```bash #!/bin/bash # 1) Download the tar file curl -L -o /tmp/mysoftware.tar "{{URL}}" # 2) Extract it tar -xvf /tmp/mysoftware.tar -C /tmp # (You can do any other custom steps here.) ``` -------------------------------- ### Configure Swif.ai Agent in NixOS Default Configuration (URL Install) Source: https://help.swif.ai/en/articles/12022726-how-to-enroll-nixos-devices-into-swif-ai-mdm This code snippet configures the Swif.ai agent within the default NixOS configuration when installing from a URL. It imports the agent tarball and sets essential service parameters like team ID, name, surname, and email. Ensure to replace placeholders with actual values. This method is suitable for standard NixOS setups. ```nix { config, pkgs, lib, ... }: let swifteamTarball = builtins.fetchTarball { url = "https://cdn.swifteam.com/st-agent-linux/{version}/nixos/swifteam.tar.gz"; sha256 = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="; }; in { imports = [ (import "${swifteamTarball}") ]; # Please fill in the required information in the configuration. services.swifteam = { enable = true; teamId = "{teamId}"; name = "{name}"; surname = "{surname}"; email = "{email}"; }; } ```