Skip to content

Commit

Permalink
fix: corrupted mac installation
Browse files Browse the repository at this point in the history
  • Loading branch information
aassafjc committed Oct 19, 2023
1 parent 366c18f commit 54f34ae
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,8 @@ do
rm -rf /Users/$user/Applications/JumpCloud\ Password\ Manager.app
fi
# Copy the contents of the DMG file to /Users/$user/Applications/
# Preserves all file attributes and ACLs
cp -pPR "$DMGAppPath" /Users/$user/Applications/
# Move the contents of the DMG file to /Users/$user/Applications/
mv -f "$DMGAppPath" /Users/$user/Applications/
err=$?
if [ ${err} -ne 0 ]; then
Expand Down
2 changes: 1 addition & 1 deletion PowerShell/JumpCloud Commands Gallery/commands.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
{
"name": "Mac - Install JumpCloud Password Manager App | v1.2 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 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\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 mv -f \"$DMGAppPath\" /Users/$user/Applications/\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."
},
Expand Down

0 comments on commit 54f34ae

Please sign in to comment.