Deploying Messenger to Mac
Messenger is available as a dmg for Mac for easy deployment via shell script or for mass deployment via your favorite RMM, MDM, or other deployment solution.
1. Finished setting up messenger.
2. Understand the difference between Partner-level and Customer-level deployments.
About Messenger for Mac
Messenger lives in the tray and by default will auto start with your Mac. To open the app, find the icon in your tray and open it. It will inherit the tray icon that you define in your Messenger settings.
Deploying via Shell
Retrieving your App ID
You will need an App ID to deploy Messenger for your customers - this tells messenger to inherit your branding.
You can retrieve your partner-level App ID from the Thread Admin Panel -> Messenger -> Installation.
Recommended Shell Script
Save as a .sh script.
#!/bin/bash
# Exit the script on any command failure
set -e
set -o pipefail
# Log file
LOG_PATH="/tmp/messenger_install.log"
# Fetch the current console user correctly
CURRENT_USER=$(scutil <<< "show State:/Users/ConsoleUser" | awk '/Name :/ && ! /loginwindow/ { print $3 }')
# macOS username
if [ -n "$SUDO_USER" ]; then
USERNAME="$CURRENT_USER"
else
USERNAME="$CURRENT_USER"
fi
MESSENGER_CONFIG="/Users/$USERNAME/Library/Application Support/Messenger"
# Function to log messages
log() {
echo "$(date '+%Y-%m-%d %H:%M:%S') - $1" | tee -a "$LOG_PATH"
}
log "username: $USERNAME"
# Variables
DOWNLOAD_URL="https://assets.getthread.com/messenger/downloads/desktop/messenger.dmg"
DMG_PATH="/tmp/messenger.dmg"
MOUNT_PATH="/tmp/messenger_mount"
APP_ID="YOUR_APP_ID_HERE"
log "Starting installation of Messenger app..."
# Uninstall existing Messenger apps
rm -rf /Applications/Messenger.app && rm -rf /Applications/Chatgenie\ Messenger.app
# Download the DMG file
log "Downloading DMG from $DOWNLOAD_URL..."
curl -o "$DMG_PATH" "$DOWNLOAD_URL"
log "DMG downloaded to $DMG_PATH."
# Function to unmount the DMG
function unmount_dmg {
log "Unmounting DMG from $MOUNT_PATH..."
hdiutil detach "$MOUNT_PATH" || true
log "DMG unmounted."
}
# Mount the DMG
log "Mounting DMG..."
hdiutil attach "$DMG_PATH" -mountpoint "$MOUNT_PATH"
log "DMG mounted at $MOUNT_PATH."
# Trap any error and ensure that the DMG gets unmounted even if there's an error
trap unmount_dmg EXIT
# Install the app
log "Installing Messenger app to /Applications..."
cp -R "$MOUNT_PATH"/*.app /Applications/
log "Installation complete."
# Unmount the DMG
unmount_dmg
# Remove the downloaded DMG to clean up
log "Removing downloaded DMG..."
rm "$DMG_PATH"
log "DMG removed."
# Close any running instances of the app
log "Closing any running instances of the Messenger app..."
pkill -f "Messenger.app/Contents/MacOS/Messenger" || true
log "Instances closed."
# Allow a brief moment for configuration to complete
sleep 2
# Run the nohup command to configure the app
# nohup MAY NOT work in some RMM tools (Addigy), in this case just remove the nohup part
log "Running the nohup command"
nohup /Applications/Messenger.app/Contents/MacOS/Messenger APP_ID="$APP_ID" FLOW=customer &
sleep 2
# Launching the app, creates the config.json file, see MESSENGER_CONFIG
log "Launching the Messenger app..."
open -a Messenger
log "Messenger app launched."
sleep 5
# Close any running instances of the app
log "Closing any running instances of the Messenger app..."
pkill -f "Messenger.app/Contents/MacOS/Messenger" || true
log "Instances closed."
# Modify the value of APP_ID in config.json, see MESSENGER_CONFIG
if [ -d "$MESSENGER_CONFIG" ]; then
log "Messenger config folder exists for user $USERNAME."
echo '{ "APP_ID": "'"$APP_ID"'" }' > "$MESSENGER_CONFIG/config.json"
log "Configured Messenger app ID in $MESSENGER_CONFIG/config.json."
else
log "Messenger config folder not found for user $USERNAME."
fi
sleep 5
# Configuration is complete, app is ready to use, launch it
log "Launching the Messenger app..."
open -a Messenger
log "Messenger app installation and configuration complete! Script v9"
Executing the Shell Script
To execute the above script on a Mac, first download your script as a .sh file (see above). Then open terminal and run the following commands:
cd ~/Downloads
chmod +x messenger_mac.sh
./messenger_mac.sh
Running the app from commandline (nohup)
nohup /Applications/Messenger.app/Contents/MacOS/Messenger APP_ID=YOUR_APP_ID_HERE FLOW=customer
Uninstalling the app
#!/bin/bash
# Check for root privileges
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root (use sudo)"
exit 1
fi
# Specify the full path to the application you want to uninstall
APP_MESSENGER="/Applications/Messenger.app"
APP_CHATGENIE_MESSENGER="/Applications/Chatgenie Messenger.app"
# Check if the MESSENGER application exists
if [ -e "$APP_MESSENGER" ]; then
echo "Uninstalling $APP_MESSENGER..."
# Remove the application
rm -rf "$APP_MESSENGER"
echo "$APP_MESSENGER has been uninstalled."
else
echo "$APP_MESSENGER is not installed."
fi
# Check if the CHATGENIE MESSENGER application exists
if [ -e "$APP_CHATGENIE_MESSENGER" ]; then
echo "Uninstalling $APP_CHATGENIE_MESSENGER..."
# Remove the application
rm -rf "$APP_CHATGENIE_MESSENGER"
echo "$APP_CHATGENIE_MESSENGER has been uninstalled."
else
echo "$APP_CHATGENIE_MESSENGER is not installed."
fi
exit 0