From 9c0d3a67147835a3579db83278a12a7d12de6c4e Mon Sep 17 00:00:00 2001 From: Omar Al Obaji Date: Thu, 5 Sep 2024 15:32:46 +0300 Subject: [PATCH 1/2] Added device architecture detection, redirection to ARM download --- ...Mac - Install JumpCloud Password Manager App.md | 14 +++++++++++--- .../JumpCloud Commands Gallery/commands.json | 4 ++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/PowerShell/JumpCloud Commands Gallery/Mac Commands/Mac - Install JumpCloud Password Manager App.md b/PowerShell/JumpCloud Commands Gallery/Mac Commands/Mac - Install JumpCloud Password Manager App.md index 800268b6b..d86fc75d1 100644 --- a/PowerShell/JumpCloud Commands Gallery/Mac Commands/Mac - Install JumpCloud Password Manager App.md +++ b/PowerShell/JumpCloud Commands Gallery/Mac Commands/Mac - Install JumpCloud Password Manager App.md @@ -1,6 +1,6 @@ #### Name -Mac - Install JumpCloud Password Manager App | v1.4 JCCG +Mac - Install JumpCloud Password Manager App | v1.5 JCCG #### commandType @@ -11,10 +11,18 @@ mac ``` #!/bin/bash -# This script will install password manager in Users/$user/Applications for all user accounts - +# This script will install password manager in Users/$user/Applications for all user accounts based on their architecture (x64 or arm64) DownloadUrl="https://cdn.pwm.jumpcloud.com/DA/release/JumpCloud-Password-Manager-latest.dmg" +# Detect device architecture +DeviceArchitecture=$(uname -m) + + +if [ "$DeviceArchitecture" = "arm64" ]; then + DownloadUrl="https://cdn.pwm.jumpcloud.com/DA/release/arm64/JumpCloud-Password-Manager-latest.dmg" +fi + + regex='^https.*.dmg$' if [[ $DownloadUrl =~ $regex ]]; then echo "URL points to direct DMG download" diff --git a/PowerShell/JumpCloud Commands Gallery/commands.json b/PowerShell/JumpCloud Commands Gallery/commands.json index 560ea955d..aea4e1ff7 100644 --- a/PowerShell/JumpCloud Commands Gallery/commands.json +++ b/PowerShell/JumpCloud Commands Gallery/commands.json @@ -133,9 +133,9 @@ "description": "This command will download and install the CrowdStrike Falcon Agent to the device if it isn't already installed. The command will leverage CrowdStrike's API to find and download the latest version of the Falcon Agent onto the local machine.\n\nIn order to use this command, follow the instructions from the [Installing the CrowdStrike Falcon Agent KB](https://support.jumpcloud.com/s/article/Installing-the-Crowdstrike-Falcon-Agent)\n\n[Richard Purves' blog post on Downloading Crowdstrike](https://richard-purves.com/2022/05/03/downloading-crowdstrike-via-api-for-fun-and-profit/) inspired this command template.\n\nSpecifically for this command:\n\n1. Create a CrowdStrike API Client with the \"SENSOR DOWNLOAD\" Read scope and make note of the ClientID and ClientSecret. Refer to CrowdStrike's article [Getting Access to the CrowdStrike API](https://www.crowdstrike.com/blog/tech-center/get-access-falcon-apis/) for further information\n2. Set the 3 variables (CSBaseAddress, CSClientID, CSClientSecret) to their respective values for your CrowdStrike API Client\n 1. If you have Require Token enabled for your CrowdStrike org, set the CSInstallToken variable with your installation token\n3. Extend the command timeout to a value that makes sense in your environment. The suggested command timeout for an environment with average network speeds on devices with average computing power is 10 minutes. Note that the command may timeout with a 124 error code in the command result window if not extended, but the script will continue to run." }, { - "name": "Mac - Install JumpCloud Password Manager App | v1.4 JCCG", + "name": "Mac - Install JumpCloud Password Manager App | v1.5 JCCG", "type": "mac", - "command": "#!/bin/bash\n\n# This script will install password manager in Users/$user/Applications for all user accounts\n\nDownloadUrl=\"https://cdn.pwm.jumpcloud.com/DA/release/JumpCloud-Password-Manager-latest.dmg\"\n\nregex='^https.*.dmg$'\nif [[ $DownloadUrl =~ $regex ]]; then\n echo \"URL points to direct DMG download\"\n validLink=\"True\"\nelse\n echo \"Searching headers for download links\"\n urlHead=$(curl -s --head $DownloadUrl)\n\n locationSearch=$(echo \"$urlHead\" | grep https:)\n\n if [ -n \"$locationSearch\" ]; then\n\n locationRaw=$(echo \"$locationSearch\" | cut -d' ' -f2)\n\n locationFormatted=\"$(echo \"${locationRaw}\" | tr -d '[:space:]')\"\n\n regex='^https.*'\n if [[ $locationFormatted =~ $regex ]]; then\n echo \"Download link found\"\n DownloadUrl=$(echo \"$locationFormatted\")\n else\n echo \"No https location download link found in headers\"\n exit 1\n fi\n\n else\n\n echo \"No location download link found in headers\"\n exit 1\n fi\n\nfi\n\n\n\n#Create Temp Folder\nDATE=$(date '+%Y-%m-%d-%H-%M-%S')\n\nTempFolder=\"Download-$DATE\"\n\nmkdir /tmp/$TempFolder\n\n# Navigate to Temp Folder\ncd /tmp/$TempFolder\n\n# Download File into Temp Folder\ncurl -s -O \"$DownloadUrl\"\n\n# Capture name of Download File\nDownloadFile=\"$(ls)\"\n\necho \"Downloaded $DownloadFile to /tmp/$TempFolder\"\n\n# Verifies DMG File\nregex='\\.dmg$'\nif [[ $DownloadFile =~ $regex ]]; then\n DMGFile=\"$(echo \"$DownloadFile\")\"\n echo \"DMG File Found: $DMGFile\"\nelse\n echo \"File: $DownloadFile is not a DMG\"\n rm -r /tmp/$TempFolder\n echo \"Deleted /tmp/$TempFolder\"\n exit 1\nfi\n\n# Mount DMG File -nobrowse prevents the volume from popping up in Finder\n\nhdiutilAttach=$(hdiutil attach /tmp/$TempFolder/$DMGFile -nobrowse)\n\necho \"Used hdiutil to mount $DMGFile \"\n\nerr=$?\nif [ ${err} -ne 0 ]; then\n echo \"Could not mount $DMGFile Error: ${err}\"\n rm -r /tmp/$TempFolder\n echo \"Deleted /tmp/$TempFolder\"\n exit 1\nfi\n\nregex='\\/Volumes\\/.*'\nif [[ $hdiutilAttach =~ $regex ]]; then\n DMGVolume=\"${BASH_REMATCH[@]}\"\n echo \"Located DMG Volume: $DMGVolume\"\nelse\n echo \"DMG Volume not found\"\n rm -r /tmp/$TempFolder\n echo \"Deleted /tmp/$TempFolder\"\n exit 1\nfi\n\n# Identify the mount point for the DMG file\nDMGMountPoint=\"$(hdiutil info | grep \"$DMGVolume\" | awk '{ print $1 }')\"\n\necho \"Located DMG Mount Point: $DMGMountPoint\"\n\n# Capture name of App file\n\ncd \"$DMGVolume\"\n\nAppName=\"$(ls | Grep .app)\"\n\ncd ~\n\necho \"Located App: $AppName\"\n\n\nDMGAppPath=$(find \"$DMGVolume\" -name \"*.app\" -depth 1)\n\nuserInstall=false\n\nfor user in $(dscl . list /Users | grep -vE 'root|daemon|nobody|^_')\ndo\n if [[ -d /Users/$user ]]; then\n # Create ~/Applications folder\n if [[ ! -d /Users/$user/Applications ]]; then\n mkdir /Users/$user/Applications\n fi\n if [[ -d /Users/$user/Applications/JumpCloud\\ Password\\ Manager.app ]]; then\n # remove if exists\n rm -rf /Users/$user/Applications/JumpCloud\\ Password\\ Manager.app\n fi\n\n # Copy the contents of the DMG file to /Users/$user/Applications/\n # Preserves all file attributes and ACLs\n cp -pPR \"$DMGAppPath\" /Users/$user/Applications/\n\n # Change ownership of the file to the user of this loop iteration\n chown -v $user /Users/$user/Applications/JumpCloud\\ Password\\ Manager.app\n\n if [[ -d /Users/$user/Desktop/JumpCloud\\ Password\\ Manager.app ]]; then\n # remove alias on desktop if exists\n rm -rf /Users/$user/Desktop/JumpCloud\\ Password\\ Manager.app\n fi\n\n err=$?\n if [ ${err} -ne 0 ]; then\n echo \"Could not copy $DMGAppPath Error: ${err}\"\n hdiutil detach $DMGMountPoint\n echo \"Used hdiutil to detach $DMGFile from $DMGMountPoint\"\n rm -r /tmp/$TempFolder\n echo \"Deleted /tmp/$TempFolder\"\n exit 1\n fi\n\n userInstall=true\n echo \"Copied $DMGAppPath to /Users/$user/Applications\"\n\n # Create an alias on desktop\n ln -s /Users/$user/Applications/JumpCloud\\ Password\\ Manager.app /Users/$user/Desktop/JumpCloud\\ Password\\ Manager.app\n fi\ndone\n\n\n# Check if password manager is installed in /Applications; remove if we installed in user directory\nif [ -d /Applications/JumpCloud\\ Password\\ Manager.app ] && [ $userInstall = true ]; then\n # remove if exists\n rm -rf /Applications/JumpCloud\\ Password\\ Manager.app\nfi\n\n# Unmount the DMG file\nhdiutil detach $DMGMountPoint\n\necho \"Used hdiutil to detach $DMGFile from $DMGMountPoint\"\n\nerr=$?\nif [ ${err} -ne 0 ]; then\n abort \"Could not detach DMG: $DMGMountPoint Error: ${err}\"\nfi\n\n# Remove Temp Folder and download\nrm -r /tmp/$TempFolder\n\necho \"Deleted /tmp/$TempFolder\"\n\nexit", + "command": "#!/bin/bash\n\n# This script will install password manager in Users/$user/Applications for all user accounts based on their architecture (x64 or arm64)\nDownloadUrl=\"https://cdn.pwm.jumpcloud.com/DA/release/JumpCloud-Password-Manager-latest.dmg\"\n\n# Detect device architecture\nDeviceArchitecture=$(uname -m)\n\nif [ \"$DeviceArchitecture\" = \"arm64\" ]; then\n DownloadUrl=\"https://cdn.pwm.jumpcloud.com/DA/release/arm64/JumpCloud-Password-Manager-latest.dmg\"\nfi\n\n\nregex='^https.*.dmg$'\nif [[ $DownloadUrl =~ $regex ]]; then\n echo \"URL points to direct DMG download\"\n validLink=\"True\"\nelse\n echo \"Searching headers for download links\"\n urlHead=$(curl -s --head $DownloadUrl)\n\n locationSearch=$(echo \"$urlHead\" | grep https:)\n\n if [ -n \"$locationSearch\" ]; then\n\n locationRaw=$(echo \"$locationSearch\" | cut -d' ' -f2)\n\n locationFormatted=\"$(echo \"${locationRaw}\" | tr -d '[:space:]')\"\n\n regex='^https.*'\n if [[ $locationFormatted =~ $regex ]]; then\n echo \"Download link found\"\n DownloadUrl=$(echo \"$locationFormatted\")\n else\n echo \"No https location download link found in headers\"\n exit 1\n fi\n\n else\n\n echo \"No location download link found in headers\"\n exit 1\n fi\n\nfi\n\n\n\n#Create Temp Folder\nDATE=$(date '+%Y-%m-%d-%H-%M-%S')\n\nTempFolder=\"Download-$DATE\"\n\nmkdir /tmp/$TempFolder\n\n# Navigate to Temp Folder\ncd /tmp/$TempFolder\n\n# Download File into Temp Folder\ncurl -s -O \"$DownloadUrl\"\n\n# Capture name of Download File\nDownloadFile=\"$(ls)\"\n\necho \"Downloaded $DownloadFile to /tmp/$TempFolder\"\n\n# Verifies DMG File\nregex='\\.dmg$'\nif [[ $DownloadFile =~ $regex ]]; then\n DMGFile=\"$(echo \"$DownloadFile\")\"\n echo \"DMG File Found: $DMGFile\"\nelse\n echo \"File: $DownloadFile is not a DMG\"\n rm -r /tmp/$TempFolder\n echo \"Deleted /tmp/$TempFolder\"\n exit 1\nfi\n\n# Mount DMG File -nobrowse prevents the volume from popping up in Finder\n\nhdiutilAttach=$(hdiutil attach /tmp/$TempFolder/$DMGFile -nobrowse)\n\necho \"Used hdiutil to mount $DMGFile \"\n\nerr=$?\nif [ ${err} -ne 0 ]; then\n echo \"Could not mount $DMGFile Error: ${err}\"\n rm -r /tmp/$TempFolder\n echo \"Deleted /tmp/$TempFolder\"\n exit 1\nfi\n\nregex='\\/Volumes\\/.*'\nif [[ $hdiutilAttach =~ $regex ]]; then\n DMGVolume=\"${BASH_REMATCH[@]}\"\n echo \"Located DMG Volume: $DMGVolume\"\nelse\n echo \"DMG Volume not found\"\n rm -r /tmp/$TempFolder\n echo \"Deleted /tmp/$TempFolder\"\n exit 1\nfi\n\n# Identify the mount point for the DMG file\nDMGMountPoint=\"$(hdiutil info | grep \"$DMGVolume\" | awk '{ print $1 }')\"\n\necho \"Located DMG Mount Point: $DMGMountPoint\"\n\n# Capture name of App file\n\ncd \"$DMGVolume\"\n\nAppName=\"$(ls | Grep .app)\"\n\ncd ~\n\necho \"Located App: $AppName\"\n\n\nDMGAppPath=$(find \"$DMGVolume\" -name \"*.app\" -depth 1)\n\nuserInstall=false\n\nfor user in $(dscl . list /Users | grep -vE 'root|daemon|nobody|^_')\ndo\n if [[ -d /Users/$user ]]; then\n # Create ~/Applications folder\n if [[ ! -d /Users/$user/Applications ]]; then\n mkdir /Users/$user/Applications\n fi\n if [[ -d /Users/$user/Applications/JumpCloud\\ Password\\ Manager.app ]]; then\n # remove if exists\n rm -rf /Users/$user/Applications/JumpCloud\\ Password\\ Manager.app\n fi\n\n # Copy the contents of the DMG file to /Users/$user/Applications/\n # Preserves all file attributes and ACLs\n cp -pPR \"$DMGAppPath\" /Users/$user/Applications/\n\n # Change ownership of the file to the user of this loop iteration\n chown -v $user /Users/$user/Applications/JumpCloud\\ Password\\ Manager.app\n\n if [[ -d /Users/$user/Desktop/JumpCloud\\ Password\\ Manager.app ]]; then\n # remove alias on desktop if exists\n rm -rf /Users/$user/Desktop/JumpCloud\\ Password\\ Manager.app\n fi\n\n err=$?\n if [ ${err} -ne 0 ]; then\n echo \"Could not copy $DMGAppPath Error: ${err}\"\n hdiutil detach $DMGMountPoint\n echo \"Used hdiutil to detach $DMGFile from $DMGMountPoint\"\n rm -r /tmp/$TempFolder\n echo \"Deleted /tmp/$TempFolder\"\n exit 1\n fi\n\n userInstall=true\n echo \"Copied $DMGAppPath to /Users/$user/Applications\"\n\n # Create an alias on desktop\n ln -s /Users/$user/Applications/JumpCloud\\ Password\\ Manager.app /Users/$user/Desktop/JumpCloud\\ Password\\ Manager.app\n fi\ndone\n\n\n# Check if password manager is installed in /Applications; remove if we installed in user directory\nif [ -d /Applications/JumpCloud\\ Password\\ Manager.app ] && [ $userInstall = true ]; then\n # remove if exists\n rm -rf /Applications/JumpCloud\\ Password\\ Manager.app\nfi\n\n# Unmount the DMG file\nhdiutil detach $DMGMountPoint\n\necho \"Used hdiutil to detach $DMGFile from $DMGMountPoint\"\n\nerr=$?\nif [ ${err} -ne 0 ]; then\n abort \"Could not detach DMG: $DMGMountPoint Error: ${err}\"\nfi\n\n# Remove Temp Folder and download\nrm -r /tmp/$TempFolder\n\necho \"Deleted /tmp/$TempFolder\"\n\nexit", "link": "https://github.com/TheJumpCloud/support/blob/master/PowerShell/JumpCloud%20Commands%20Gallery/Mac%20Commands/Mac%20-%20Install%20JumpCloud%20Password%20Manager%20App.md", "description": "This command will download and install the JumpCloud Password Manager to the device if it isn't already installed. On slower networks, timeouts with exit code 127 can occur. Manually setting the default timeout limit to 600 seconds may be advisable." }, From 71e4382c67f5ca55093888fb7a67ee5c71f41c35 Mon Sep 17 00:00:00 2001 From: Omar Al Obaji Date: Thu, 5 Sep 2024 15:51:07 +0300 Subject: [PATCH 2/2] ran commands.json cmd --- PowerShell/JumpCloud Commands Gallery/commands.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PowerShell/JumpCloud Commands Gallery/commands.json b/PowerShell/JumpCloud Commands Gallery/commands.json index aea4e1ff7..7ded687ef 100644 --- a/PowerShell/JumpCloud Commands Gallery/commands.json +++ b/PowerShell/JumpCloud Commands Gallery/commands.json @@ -135,7 +135,7 @@ { "name": "Mac - Install JumpCloud Password Manager App | v1.5 JCCG", "type": "mac", - "command": "#!/bin/bash\n\n# This script will install password manager in Users/$user/Applications for all user accounts based on their architecture (x64 or arm64)\nDownloadUrl=\"https://cdn.pwm.jumpcloud.com/DA/release/JumpCloud-Password-Manager-latest.dmg\"\n\n# Detect device architecture\nDeviceArchitecture=$(uname -m)\n\nif [ \"$DeviceArchitecture\" = \"arm64\" ]; then\n DownloadUrl=\"https://cdn.pwm.jumpcloud.com/DA/release/arm64/JumpCloud-Password-Manager-latest.dmg\"\nfi\n\n\nregex='^https.*.dmg$'\nif [[ $DownloadUrl =~ $regex ]]; then\n echo \"URL points to direct DMG download\"\n validLink=\"True\"\nelse\n echo \"Searching headers for download links\"\n urlHead=$(curl -s --head $DownloadUrl)\n\n locationSearch=$(echo \"$urlHead\" | grep https:)\n\n if [ -n \"$locationSearch\" ]; then\n\n locationRaw=$(echo \"$locationSearch\" | cut -d' ' -f2)\n\n locationFormatted=\"$(echo \"${locationRaw}\" | tr -d '[:space:]')\"\n\n regex='^https.*'\n if [[ $locationFormatted =~ $regex ]]; then\n echo \"Download link found\"\n DownloadUrl=$(echo \"$locationFormatted\")\n else\n echo \"No https location download link found in headers\"\n exit 1\n fi\n\n else\n\n echo \"No location download link found in headers\"\n exit 1\n fi\n\nfi\n\n\n\n#Create Temp Folder\nDATE=$(date '+%Y-%m-%d-%H-%M-%S')\n\nTempFolder=\"Download-$DATE\"\n\nmkdir /tmp/$TempFolder\n\n# Navigate to Temp Folder\ncd /tmp/$TempFolder\n\n# Download File into Temp Folder\ncurl -s -O \"$DownloadUrl\"\n\n# Capture name of Download File\nDownloadFile=\"$(ls)\"\n\necho \"Downloaded $DownloadFile to /tmp/$TempFolder\"\n\n# Verifies DMG File\nregex='\\.dmg$'\nif [[ $DownloadFile =~ $regex ]]; then\n DMGFile=\"$(echo \"$DownloadFile\")\"\n echo \"DMG File Found: $DMGFile\"\nelse\n echo \"File: $DownloadFile is not a DMG\"\n rm -r /tmp/$TempFolder\n echo \"Deleted /tmp/$TempFolder\"\n exit 1\nfi\n\n# Mount DMG File -nobrowse prevents the volume from popping up in Finder\n\nhdiutilAttach=$(hdiutil attach /tmp/$TempFolder/$DMGFile -nobrowse)\n\necho \"Used hdiutil to mount $DMGFile \"\n\nerr=$?\nif [ ${err} -ne 0 ]; then\n echo \"Could not mount $DMGFile Error: ${err}\"\n rm -r /tmp/$TempFolder\n echo \"Deleted /tmp/$TempFolder\"\n exit 1\nfi\n\nregex='\\/Volumes\\/.*'\nif [[ $hdiutilAttach =~ $regex ]]; then\n DMGVolume=\"${BASH_REMATCH[@]}\"\n echo \"Located DMG Volume: $DMGVolume\"\nelse\n echo \"DMG Volume not found\"\n rm -r /tmp/$TempFolder\n echo \"Deleted /tmp/$TempFolder\"\n exit 1\nfi\n\n# Identify the mount point for the DMG file\nDMGMountPoint=\"$(hdiutil info | grep \"$DMGVolume\" | awk '{ print $1 }')\"\n\necho \"Located DMG Mount Point: $DMGMountPoint\"\n\n# Capture name of App file\n\ncd \"$DMGVolume\"\n\nAppName=\"$(ls | Grep .app)\"\n\ncd ~\n\necho \"Located App: $AppName\"\n\n\nDMGAppPath=$(find \"$DMGVolume\" -name \"*.app\" -depth 1)\n\nuserInstall=false\n\nfor user in $(dscl . list /Users | grep -vE 'root|daemon|nobody|^_')\ndo\n if [[ -d /Users/$user ]]; then\n # Create ~/Applications folder\n if [[ ! -d /Users/$user/Applications ]]; then\n mkdir /Users/$user/Applications\n fi\n if [[ -d /Users/$user/Applications/JumpCloud\\ Password\\ Manager.app ]]; then\n # remove if exists\n rm -rf /Users/$user/Applications/JumpCloud\\ Password\\ Manager.app\n fi\n\n # Copy the contents of the DMG file to /Users/$user/Applications/\n # Preserves all file attributes and ACLs\n cp -pPR \"$DMGAppPath\" /Users/$user/Applications/\n\n # Change ownership of the file to the user of this loop iteration\n chown -v $user /Users/$user/Applications/JumpCloud\\ Password\\ Manager.app\n\n if [[ -d /Users/$user/Desktop/JumpCloud\\ Password\\ Manager.app ]]; then\n # remove alias on desktop if exists\n rm -rf /Users/$user/Desktop/JumpCloud\\ Password\\ Manager.app\n fi\n\n err=$?\n if [ ${err} -ne 0 ]; then\n echo \"Could not copy $DMGAppPath Error: ${err}\"\n hdiutil detach $DMGMountPoint\n echo \"Used hdiutil to detach $DMGFile from $DMGMountPoint\"\n rm -r /tmp/$TempFolder\n echo \"Deleted /tmp/$TempFolder\"\n exit 1\n fi\n\n userInstall=true\n echo \"Copied $DMGAppPath to /Users/$user/Applications\"\n\n # Create an alias on desktop\n ln -s /Users/$user/Applications/JumpCloud\\ Password\\ Manager.app /Users/$user/Desktop/JumpCloud\\ Password\\ Manager.app\n fi\ndone\n\n\n# Check if password manager is installed in /Applications; remove if we installed in user directory\nif [ -d /Applications/JumpCloud\\ Password\\ Manager.app ] && [ $userInstall = true ]; then\n # remove if exists\n rm -rf /Applications/JumpCloud\\ Password\\ Manager.app\nfi\n\n# Unmount the DMG file\nhdiutil detach $DMGMountPoint\n\necho \"Used hdiutil to detach $DMGFile from $DMGMountPoint\"\n\nerr=$?\nif [ ${err} -ne 0 ]; then\n abort \"Could not detach DMG: $DMGMountPoint Error: ${err}\"\nfi\n\n# Remove Temp Folder and download\nrm -r /tmp/$TempFolder\n\necho \"Deleted /tmp/$TempFolder\"\n\nexit", + "command": "#!/bin/bash\n\n# This script will install password manager in Users/$user/Applications for all user accounts based on their architecture (x64 or arm64)\nDownloadUrl=\"https://cdn.pwm.jumpcloud.com/DA/release/JumpCloud-Password-Manager-latest.dmg\"\n\n# Detect device architecture\nDeviceArchitecture=$(uname -m)\n\n\nif [ \"$DeviceArchitecture\" = \"arm64\" ]; then\n DownloadUrl=\"https://cdn.pwm.jumpcloud.com/DA/release/arm64/JumpCloud-Password-Manager-latest.dmg\"\nfi\n\n\nregex='^https.*.dmg$'\nif [[ $DownloadUrl =~ $regex ]]; then\n echo \"URL points to direct DMG download\"\n validLink=\"True\"\nelse\n echo \"Searching headers for download links\"\n urlHead=$(curl -s --head $DownloadUrl)\n\n locationSearch=$(echo \"$urlHead\" | grep https:)\n\n if [ -n \"$locationSearch\" ]; then\n\n locationRaw=$(echo \"$locationSearch\" | cut -d' ' -f2)\n\n locationFormatted=\"$(echo \"${locationRaw}\" | tr -d '[:space:]')\"\n\n regex='^https.*'\n if [[ $locationFormatted =~ $regex ]]; then\n echo \"Download link found\"\n DownloadUrl=$(echo \"$locationFormatted\")\n else\n echo \"No https location download link found in headers\"\n exit 1\n fi\n\n else\n\n echo \"No location download link found in headers\"\n exit 1\n fi\n\nfi\n\n\n\n#Create Temp Folder\nDATE=$(date '+%Y-%m-%d-%H-%M-%S')\n\nTempFolder=\"Download-$DATE\"\n\nmkdir /tmp/$TempFolder\n\n# Navigate to Temp Folder\ncd /tmp/$TempFolder\n\n# Download File into Temp Folder\ncurl -s -O \"$DownloadUrl\"\n\n# Capture name of Download File\nDownloadFile=\"$(ls)\"\n\necho \"Downloaded $DownloadFile to /tmp/$TempFolder\"\n\n# Verifies DMG File\nregex='\\.dmg$'\nif [[ $DownloadFile =~ $regex ]]; then\n DMGFile=\"$(echo \"$DownloadFile\")\"\n echo \"DMG File Found: $DMGFile\"\nelse\n echo \"File: $DownloadFile is not a DMG\"\n rm -r /tmp/$TempFolder\n echo \"Deleted /tmp/$TempFolder\"\n exit 1\nfi\n\n# Mount DMG File -nobrowse prevents the volume from popping up in Finder\n\nhdiutilAttach=$(hdiutil attach /tmp/$TempFolder/$DMGFile -nobrowse)\n\necho \"Used hdiutil to mount $DMGFile \"\n\nerr=$?\nif [ ${err} -ne 0 ]; then\n echo \"Could not mount $DMGFile Error: ${err}\"\n rm -r /tmp/$TempFolder\n echo \"Deleted /tmp/$TempFolder\"\n exit 1\nfi\n\nregex='\\/Volumes\\/.*'\nif [[ $hdiutilAttach =~ $regex ]]; then\n DMGVolume=\"${BASH_REMATCH[@]}\"\n echo \"Located DMG Volume: $DMGVolume\"\nelse\n echo \"DMG Volume not found\"\n rm -r /tmp/$TempFolder\n echo \"Deleted /tmp/$TempFolder\"\n exit 1\nfi\n\n# Identify the mount point for the DMG file\nDMGMountPoint=\"$(hdiutil info | grep \"$DMGVolume\" | awk '{ print $1 }')\"\n\necho \"Located DMG Mount Point: $DMGMountPoint\"\n\n# Capture name of App file\n\ncd \"$DMGVolume\"\n\nAppName=\"$(ls | Grep .app)\"\n\ncd ~\n\necho \"Located App: $AppName\"\n\n\nDMGAppPath=$(find \"$DMGVolume\" -name \"*.app\" -depth 1)\n\nuserInstall=false\n\nfor user in $(dscl . list /Users | grep -vE 'root|daemon|nobody|^_')\ndo\n if [[ -d /Users/$user ]]; then\n # Create ~/Applications folder\n if [[ ! -d /Users/$user/Applications ]]; then\n mkdir /Users/$user/Applications\n fi\n if [[ -d /Users/$user/Applications/JumpCloud\\ Password\\ Manager.app ]]; then\n # remove if exists\n rm -rf /Users/$user/Applications/JumpCloud\\ Password\\ Manager.app\n fi\n\n # Copy the contents of the DMG file to /Users/$user/Applications/\n # Preserves all file attributes and ACLs\n cp -pPR \"$DMGAppPath\" /Users/$user/Applications/\n\n # Change ownership of the file to the user of this loop iteration\n chown -v $user /Users/$user/Applications/JumpCloud\\ Password\\ Manager.app\n\n if [[ -d /Users/$user/Desktop/JumpCloud\\ Password\\ Manager.app ]]; then\n # remove alias on desktop if exists\n rm -rf /Users/$user/Desktop/JumpCloud\\ Password\\ Manager.app\n fi\n\n err=$?\n if [ ${err} -ne 0 ]; then\n echo \"Could not copy $DMGAppPath Error: ${err}\"\n hdiutil detach $DMGMountPoint\n echo \"Used hdiutil to detach $DMGFile from $DMGMountPoint\"\n rm -r /tmp/$TempFolder\n echo \"Deleted /tmp/$TempFolder\"\n exit 1\n fi\n\n userInstall=true\n echo \"Copied $DMGAppPath to /Users/$user/Applications\"\n\n # Create an alias on desktop\n ln -s /Users/$user/Applications/JumpCloud\\ Password\\ Manager.app /Users/$user/Desktop/JumpCloud\\ Password\\ Manager.app\n fi\ndone\n\n\n# Check if password manager is installed in /Applications; remove if we installed in user directory\nif [ -d /Applications/JumpCloud\\ Password\\ Manager.app ] && [ $userInstall = true ]; then\n # remove if exists\n rm -rf /Applications/JumpCloud\\ Password\\ Manager.app\nfi\n\n# Unmount the DMG file\nhdiutil detach $DMGMountPoint\n\necho \"Used hdiutil to detach $DMGFile from $DMGMountPoint\"\n\nerr=$?\nif [ ${err} -ne 0 ]; then\n abort \"Could not detach DMG: $DMGMountPoint Error: ${err}\"\nfi\n\n# Remove Temp Folder and download\nrm -r /tmp/$TempFolder\n\necho \"Deleted /tmp/$TempFolder\"\n\nexit", "link": "https://github.com/TheJumpCloud/support/blob/master/PowerShell/JumpCloud%20Commands%20Gallery/Mac%20Commands/Mac%20-%20Install%20JumpCloud%20Password%20Manager%20App.md", "description": "This command will download and install the JumpCloud Password Manager to the device if it isn't already installed. On slower networks, timeouts with exit code 127 can occur. Manually setting the default timeout limit to 600 seconds may be advisable." },