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:
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
1 comment
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.
Please sign in to leave a comment.