Timus Connect App for MacOS Silent Deployment Script

Note:

Bash Script - Mac
Ensure the script has execute permissions by using the following terminal command:
chmod +x /path/to/script.sh

Mac:

#!/bin/bash

# Check if the machine is a MacBook (laptop)
MODEL_IDENTIFIER=$(system_profiler SPHardwareDataType | awk '/Model Identifier/ {print $3}')
if [[ ! "$MODEL_IDENTIFIER" =~ "MacBook" ]]; then
echo "This script is intended for MacBook models only."
exit 1
else
echo "Thank you for using Timus ZTNA. Your secure remote access will be enabled shortly."
fi

# Specify the name of the app to check if it's installed
APP_NAME="Timus Connect.app"
APP_PATH="/Applications/$APP_NAME"

# Specify the URL and local directory and path for the .pkg
PKG_URL="https://repo.timuscloud.com/connect/Timus-Connect.pkg"
PKG_DIR="/tmp/Timus-Connect"
PKG_LOCAL_PATH="$PKG_DIR/Timus-Connect.pkg"

# Check if the app is already installed
if [ -d "$APP_PATH" ]; then
echo "$APP_NAME is already installed."
else
echo "$APP_NAME is not installed."

# Create the directory if it doesn't exist
[ ! -d "$PKG_DIR" ] && mkdir -p "$PKG_DIR"

# Download the .pkg file from the specified URL
echo "Downloading $PKG_NAME..."
curl -o "$PKG_LOCAL_PATH" "$PKG_URL"
if [ $? -eq 0 ]; then
echo "Download successful!"

# Install the .pkg
echo "Installing $PKG_NAME..."
installer -pkg "$PKG_LOCAL_PATH" -target /
if [ $? -eq 0 ]; then
echo "Installation successful!"

# Open the app
echo "Opening $APP_NAME..."
open "$APP_PATH"

# Optionally, you can clean up by removing the downloaded .pkg
rm "$PKG_LOCAL_PATH"
rmdir "$PKG_DIR" # This will only remove the directory if it's empty

else
echo "Error during installation."
fi

else
echo "Error downloading $PKG_NAME."
fi
fi

exit 0

To handle cases where the initial script does not work for certain Mac models, you can use the alternative script with adjustments below:

Note: When running the alternative MacOS script through an RMM or system-level deployment tool, the $HOME variable may not always be properly set. If this happens, the download path may resolve to /Downloads/TimusConnect.pkg, which is not writable on macOS and may cause the download to fail with a Failure writing output to destination error. If this issue occurs, update the destination path in the script to use a writable system location such as /tmp/TimusConnect.pkg.

Example:
Change:
DESTINATION="$HOME/Downloads/TimusConnect.pkg"
To:
DESTINATION="/tmp/TimusConnect.pkg"

MacOS:

#!/bin/bash

# Define variables
DOWNLOAD_URL="https://repo.timuscloud.com/connect/Timus-Connect.pkg"
DESTINATION="$HOME/Downloads/TimusConnect.pkg"
LOG_FILE="/tmp/timus_install.log"

# Ensure the log file is writable
if [[ ! -w $(dirname "$LOG_FILE") ]]; then
    echo "Error: Cannot write to log file at $LOG_FILE. Check permissions or use a different path."
    exit 1
fi

# Redirect script output to log file
exec > >(tee -a "$LOG_FILE") 2>&1
echo "Starting Timus Connect installation: $(date)"

# Ensure the Downloads directory exists
mkdir -p "$HOME/Downloads"

# Download the package
echo "Downloading the package from $DOWNLOAD_URL..."
curl -L -o "$DESTINATION" "$DOWNLOAD_URL"

if [[ $? -ne 0 ]]; then
    echo "Error: Failed to download the package from $DOWNLOAD_URL. Exiting."
    exit 1
fi
echo "Download completed: $DESTINATION"

# Install the package silently
echo "Installing the package..."
sudo installer -pkg "$DESTINATION" -target /

if [[ $? -ne 0 ]]; then
    echo "Error: Installation failed. Exiting."
    exit 1
fi
echo "Installation completed successfully."

# Optional cleanup
echo "Cleaning up downloaded file..."
rm -f "$DESTINATION"
echo "Cleaned up downloaded file: $DESTINATION"

echo "Timus Connect installation completed successfully: $(date)"
exit 0

 

Related to

Updated

Was this article helpful?

0 out of 1 found this helpful

Have more questions? Submit a request

Comments

1 comment

  • Comment author
    Brandon Fox

    This article should include the necessary steps to approve the other functions of the app if you're attempting to silently deploy via RMM/MDM, like authorization for login & extensions, and how to preapprove for productivity tracker. 

     

    This article is not complete without those items.

     

    Also, please include the uninstall script that I was sent privately.

    2

Please sign in to leave a comment.