#!/bin/sh # This script will install Liquit Universal Agent on macOS. # Authors Matthew Gonzalez en Sven van Katwijk # Version 1.0 # Date created 24-01-2023 # Copyright 2023 Liquit Software B.V. # This code is made available as is, without any warranty of any kind. The entire risk of the use or the results of the use of this code remains with the user. # Dynamic variables agent_download_url="https://example.liquit.com/api/agent/installers/F84543F0-F440-4200-9A2B-E13FC30C71BB" config_download_url="https://liquit.example.blob.core.windows.net/liquit/Agent.json" certificate_download_url="https://liquit.example.blob.core.windows.net/liquit/AgentRegistration.cer" working_dir="/Library/Application Support/com.liquit.Bootstrapper" # Define log file name log_file="$working_dir/Bootstrapper.log" # Define package and configuration file name pkg_path="$working_dir/Liquit-Universal-Agent-Mac.pkg" config_path="$working_dir/Agent.json" cert_path="$working_dir/MacRegistar.cer" # Create log file if it doesn't exist touch "$log_file" function log() { echo "$(date +'%Y-%m-%d %H:%M:%S') "$1 | tee -a "$log_file" } # Log file location echo "Using logfile "$log_file log "Starting installation" # Check if running as root. if [ "$(id -u)" != "0" ]; then echo "This script must be run as root!" exit 1 fi # Check if Liquit is already installed if [ -d "/Applications/Liquit.app" ]; then log "Liquit is already installed " exit 0 fi # Creates download path mkdir -p "$working_dir" cd "$working_dir" log "Working directory created " # Download Liquit Universal Agent & JSON file curl -L -o "$pkg_path" "$agent_download_url" if [ $? -ne 0 ]; then log "Failed to download Liquit Universal Agent" exit 1 fi log "Liquit Universal Agent downloaded " # Download JSON file curl -L -o "$config_path" "$config_download_url" if [ $? -ne 0 ]; then log exit 1 fi log "JSON file downloaded" # Download registration certificate if [[ ! -z "$certificate_download_url" ]]; then curl -L -o "$cert_path" "$certificate_download_url" if [ $? -ne 0 ]; then log "Failed to download registration certificate" exit 1 fi log "Registration certificate downloaded" fi # Install Liquit Universal Agent log "Installing Liquit Universal Agent" installer -pkg "$pkg_path" -target / -dumplog # Check if installation was successful if [ $? -ne 0 ]; then log "Failed to install Liquit Universal Agent" exit 1 fi # Check if Liquit is installed log "Liquit Universal Agent installed" # Make sure all files are released before deleting them. sleep 5 # Remove downloaded files rm "$pkg_path" rm "$config_path" rm "$cert_path" log "Downloaded files removed" log "Installation completed" exit 0