Posted on 09-27-2017 10:50 AM
Is someone willing to help me out? I've been using a similar script for google drive for sometime now. But with the release of backup and sync I can't seem to make this work.
#!/bin/sh -x
logfile="/Library/Logs/jss.log"
user=`ls -l /dev/console | cut -d " " -f 4`
PRODUCT="Backup and Sync from Google"
# installation
/bin/echo "`date`: Installing Backup and Sync for $user..." >> ${logfile}
dmgfile="image.dmg"
volname="Install Backup andy Sync for Google"
url="https://dl.google.com/drive/InstallBackupAndSync.dmg"
/bin/echo "`date`: Downloading $PRODUCT." >> ${logfile}
/usr/bin/curl -k -o /tmp/image.dmg $url
/bin/echo "`date`: Mounting installer disk image." >> ${logfile}
/usr/bin/hdiutil attach /tmp/image.dmg -nobrowse -quiet
/bin/echo "`date`: Installing..." >> ${logfile}
cp -R /Volumes/Install Backup and Sync from Google/Backup and Sync from Google.app /Applications/
/bin/sleep 3
/bin/echo "`date`: Unmounting installer disk image." >> ${logfile}
/usr/bin/hdiutil detach $(/bin/df | /usr/bin/grep ${volname} | awk '{print $1}') -quiet
/bin/sleep 3
open -a /Applications/Google Backup and Sync from Google.app/
From the failure log it appears that it's downloading and mounting but the installation is failing because it can't find the file needed:
Installing...'<br/> cp -R '/Volumes/Install Backup and Sync from Google/Backup and Sync from Google.app' /Applications/<br/>cp: /Volumes/Install Backup and Sync from Google/Backup and Sync from Google.app: No such file or directory<br/> /bin/sleep 3<br/>+ date<br/> /bin/echo 'Wed Sep 27 10:41:24 PDT 2017: Unmounting installer disk image.'<br/>+ /bin/df<br/> /usr/bin/grep Install Backup andy Sync for Google<br/> awk '{print $1}'<br/>grep: Backup: No such file or directory<br/>grep: andy: No such file or directory<br/>grep: Sync: No such file or directory<br/>grep: for: No such file or directory<br/>grep: Google: No such file or directory<br/> /usr/bin/hdiutil detach -quiet<br/> /bin/sleep 3<br/> open -a '/Applications/Google Backup and Sync from Google.app/'<br/>FSPathMakeRef(/Applications/Google Backup and Sync from Google.app) failed with error -43.<br/>
Any help would be appreciated.
Solved! Go to Solution.
Posted on 09-27-2017 11:37 AM
Try this:
#!/bin/bash
bundle="Backup and Sync.app"
tmp="/private/tmp/GoogleBackupAndSync"
echo "$(date): Create temporary directory"
mkdir -p "${tmp}"
echo "$(date): Download 'https://dl.google.com/drive/InstallBackupAndSync.dmg'"
curl -s -o "${tmp}"/"InstallBackupAndSync.dmg" "https://dl.google.com/drive/InstallBackupAndSync.dmg"
echo "$(date): Check downloaded DMG"
volume=$(hdiutil attach -noautoopen -noverify -nobrowse "${tmp}/InstallBackupAndSync.dmg" | egrep "Volumes" | grep -o "/Volumes/.*")
if [ "$(find "${volume}" -name "${bundle}" -execdir echo '{}' ';' -print | sed -n 1p)" == "${bundle}" ]; then
bundlepath=$(find "${volume}" -name "${bundle}" -print | sed -n 1p)
bundlename=$(find "${volume}" -name "${bundle}" -execdir echo '{}' ';' -print | sed -n 1p)
echo "$(date): '${bundle}' was found in '${bundlepath}'"
if [ ! -s "${bundlepath}" ]; then
echo "$(date): No bundle found"
rm -rf "${tmp}"
hdiutil detach $(/bin/df | /usr/bin/grep "${volume}" | awk '{print $1}') -quiet -force
exit 1
else
if [ -s "/Applications/${bundle}" ]; then
echo "$(date): Delete installed '${bundle}'"
rm -rf "/Applications/${bundle}"
fi
echo "$(date): Move '${bundlepath}' to '/Applications'"
rsync -ar "${bundlepath}" "/Applications/"
fi
echo "$(date): Unmount '${volume}'"
hdiutil detach $(/bin/df | /usr/bin/grep "${volume}" | awk '{print $1}') -quiet -force
echo "$(date): Purge temporary directory"
rm -rf "${tmp}"
else
rm -rf "${tmp}"
exit 1
fi
exit 0
Posted on 09-27-2017 11:37 AM
Try this:
#!/bin/bash
bundle="Backup and Sync.app"
tmp="/private/tmp/GoogleBackupAndSync"
echo "$(date): Create temporary directory"
mkdir -p "${tmp}"
echo "$(date): Download 'https://dl.google.com/drive/InstallBackupAndSync.dmg'"
curl -s -o "${tmp}"/"InstallBackupAndSync.dmg" "https://dl.google.com/drive/InstallBackupAndSync.dmg"
echo "$(date): Check downloaded DMG"
volume=$(hdiutil attach -noautoopen -noverify -nobrowse "${tmp}/InstallBackupAndSync.dmg" | egrep "Volumes" | grep -o "/Volumes/.*")
if [ "$(find "${volume}" -name "${bundle}" -execdir echo '{}' ';' -print | sed -n 1p)" == "${bundle}" ]; then
bundlepath=$(find "${volume}" -name "${bundle}" -print | sed -n 1p)
bundlename=$(find "${volume}" -name "${bundle}" -execdir echo '{}' ';' -print | sed -n 1p)
echo "$(date): '${bundle}' was found in '${bundlepath}'"
if [ ! -s "${bundlepath}" ]; then
echo "$(date): No bundle found"
rm -rf "${tmp}"
hdiutil detach $(/bin/df | /usr/bin/grep "${volume}" | awk '{print $1}') -quiet -force
exit 1
else
if [ -s "/Applications/${bundle}" ]; then
echo "$(date): Delete installed '${bundle}'"
rm -rf "/Applications/${bundle}"
fi
echo "$(date): Move '${bundlepath}' to '/Applications'"
rsync -ar "${bundlepath}" "/Applications/"
fi
echo "$(date): Unmount '${volume}'"
hdiutil detach $(/bin/df | /usr/bin/grep "${volume}" | awk '{print $1}') -quiet -force
echo "$(date): Purge temporary directory"
rm -rf "${tmp}"
else
rm -rf "${tmp}"
exit 1
fi
exit 0
Posted on 09-27-2017 11:50 AM
Tried running your script from JSS and it just stalls out.
Posted on 09-27-2017 12:18 PM
@LovelessinSEA It works for me. Can you send me the log?
Posted on 09-27-2017 01:25 PM
@anverhousseini What log are you looking for? The install doesn't get past this point, it just sits here for as long as i would let it. Since the policy is pending it never gives a failure log in JSS.
Posted on 09-27-2017 03:02 PM
@LovelessinSEA I can't help you if I don't see the logs. Can you run the script outside of JSS?
Posted on 09-27-2017 05:07 PM
@anverhousseini apologies for not responding earlier, your script is perfect, I had some bogus code left over from testing that was causing an issue. Thanks for your help! only thing i would mention is it would be nice to open the application after the install. so i added
open -a /Applications/Backup and Sync.app
to the script.
Thanks again!!
Posted on 11-01-2017 11:26 AM
@LovelessinSEA Do you know of a way to modify this script. To point to a local shared drive on the network to pull from instead of downloading backup & sync to each device I push the script to?
Posted on 11-27-2017 12:07 PM
I'd love to find a way to further automate this using our single sign on so it can auto login to backup and sync.
Gabe Shackney
Princeton Public Schools
Posted on 02-28-2019 10:43 AM
Just tested this script against 10.14.3 on a new MacBook Air and it still works as advertised. Thanks!
Posted on 10-17-2019 07:41 AM
Does this script manage any updates to Backup & Sync? A laptop displayed the message to install the upgraded version of Backup & Sync, so wondering the best method to manage this.
Posted on 10-18-2019 09:05 AM
Does this still work since the app name is now Backup and Sync from Google.app ?
Posted on 07-21-2021 10:40 AM
Does anyone have the updated script for "Drive for Desktop"?