mirror of
https://github.com/PurpleComputing/mdmscripts.git
synced 2026-06-11 04:30:29 +01:00
Add files via upload
This commit is contained in:
119
google-chrome.sh
119
google-chrome.sh
@@ -13,11 +13,11 @@
|
||||
#
|
||||
# HISTORY
|
||||
#
|
||||
# Version: 1.1-m
|
||||
# Version: 1.2
|
||||
#
|
||||
# - 1.0 Martyn Watts, 01.07.2021 Initial Build
|
||||
# - 1.1-m Michael Tanner, 18.08.2021 Adapted for Mosyle
|
||||
#
|
||||
# - 1.2 Martyn Watts, 24.09.2021 Added Check to see if dockutil is installed to make the script more resilient
|
||||
#
|
||||
####################################################################################################
|
||||
# Script to download and install Google Chrome.
|
||||
@@ -50,67 +50,70 @@ latestver=$(cat /tmp/pkg/Distribution | grep 'CFBundleShortVersionString' | cut
|
||||
|
||||
|
||||
# Get the version number of the currently-installed App, if any.
|
||||
if [[ -e "/Applications/${appName}.app" ]]; then
|
||||
currentinstalledver=`/usr/bin/defaults read "/Applications/${appName}.app/Contents/Info" CFBundleShortVersionString`
|
||||
echo "Current installed version is: $currentinstalledver"
|
||||
echo "Current installed version is: $currentinstalledver" >> ${logfile}
|
||||
if [[ ${latestver} = ${currentinstalledver} ]]; then
|
||||
echo "${appName} is current. Exiting"
|
||||
echo "${appName} is current. Exiting" >> ${logfile}
|
||||
exit 0
|
||||
fi
|
||||
else
|
||||
currentinstalledver="none"
|
||||
echo "${appName} is not installed"
|
||||
echo "${appName} is not installed" >> ${logfile}
|
||||
fi
|
||||
if [[ -e "/Applications/${appName}.app" ]]; then
|
||||
currentinstalledver=`/usr/bin/defaults read "/Applications/${appName}.app/Contents/Info" CFBundleShortVersionString`
|
||||
echo "Current installed version is: $currentinstalledver"
|
||||
echo "Current installed version is: $currentinstalledver" >> ${logfile}
|
||||
if [[ ${latestver} = ${currentinstalledver} ]]; then
|
||||
echo "${appName} is current. Exiting"
|
||||
echo "${appName} is current. Exiting" >> ${logfile}
|
||||
exit 0
|
||||
fi
|
||||
else
|
||||
currentinstalledver="none"
|
||||
echo "${appName} is not installed"
|
||||
echo "${appName} is not installed" >> ${logfile}
|
||||
fi
|
||||
|
||||
|
||||
# Compare the two versions, if they are different or the App is not present then download and install the new version.
|
||||
if [[ "${currentinstalledver}" != "${latestver}" ]]; then
|
||||
/bin/echo "`date`: Current ${appName} version: ${currentinstalledver}" >> ${logfile}
|
||||
/bin/echo "Current ${appName} version: ${currentinstalledver}"
|
||||
/bin/echo "`date`: Available ${appName} version: ${latestver}" >> ${logfile}
|
||||
/bin/echo "Available ${appName} version: ${latestver}"
|
||||
/bin/echo "`date`: Force quitting ${appName} if running." >> ${logfile}
|
||||
/bin/echo "Force quitting ${appName} if running."
|
||||
if [[ "${currentinstalledver}" != "${latestver}" ]]; then
|
||||
/bin/echo "`date`: Current ${appName} version: ${currentinstalledver}" >> ${logfile}
|
||||
/bin/echo "Current ${appName} version: ${currentinstalledver}"
|
||||
/bin/echo "`date`: Available ${appName} version: ${latestver}" >> ${logfile}
|
||||
/bin/echo "Available ${appName} version: ${latestver}"
|
||||
/bin/echo "`date`: Force quitting ${appName} if running." >> ${logfile}
|
||||
/bin/echo "Force quitting ${appName} if running."
|
||||
|
||||
if [[ "${forceQuit}" = "Y" ]]; then
|
||||
killall ${appName}
|
||||
fi
|
||||
if [[ "${forceQuit}" = "Y" ]]; then
|
||||
killall ${appName}
|
||||
fi
|
||||
cd /tmp
|
||||
/usr/sbin/installer -pkg ${dnldfile} -target /
|
||||
/usr/sbin/installer -pkg ${dnldfile} -target /
|
||||
|
||||
#double check to see if the new version got updated
|
||||
newlyinstalledver=`/usr/bin/defaults read "/Applications/${appName}.app/Contents/Info" CFBundleShortVersionString`
|
||||
if [[ "${latestver}" = "${newlyinstalledver}" ]]; then
|
||||
/bin/echo "`date`: SUCCESS: ${appName} has been updated to version ${newlyinstalledver}" >> ${logfile}
|
||||
/bin/echo "SUCCESS: ${appName} has been updated to version ${newlyinstalledver}"
|
||||
/bin/echo "`date`: Removing Existing Dock Icon." >> ${logfile}
|
||||
/bin/echo "Removing Existing Dock Icon."
|
||||
/usr/local/bin/dockutil --remove "${appName}" --allhomes >> ${logfile}
|
||||
/bin/sleep 5
|
||||
/bin/echo "`date`: Creating New Dock Icon." >> ${logfile}
|
||||
/bin/echo "Creating New Dock Icon."
|
||||
#/usr/local/bin/dockutil --add "/Applications/${appName}.app" --after 'Safari' --allhomes >> ${logfile}
|
||||
/bin/sleep 3
|
||||
/bin/echo "--" >> ${logfile}
|
||||
else
|
||||
/bin/echo "`date`: ERROR: ${appName} update unsuccessful, version remains at ${currentinstalledver}." >> ${logfile}
|
||||
/bin/echo "ERROR: ${appName} update unsuccessful, version remains at ${currentinstalledver}."
|
||||
/bin/echo "--" >> ${logfile}
|
||||
exit 1
|
||||
fi
|
||||
#double check to see if the new version got updated
|
||||
newlyinstalledver=`/usr/bin/defaults read "/Applications/${appName}.app/Contents/Info" CFBundleShortVersionString`
|
||||
if [[ "${latestver}" = "${newlyinstalledver}" ]]; then
|
||||
/bin/echo "`date`: SUCCESS: ${appName} has been updated to version ${newlyinstalledver}" >> ${logfile}
|
||||
/bin/echo "SUCCESS: ${appName} has been updated to version ${newlyinstalledver}"
|
||||
if [[ -e "/usr/local/bin/dockutil" ]]; then
|
||||
/bin/echo "`date`: Removing Existing Dock Icon." >> ${logfile}
|
||||
/bin/echo "Removing Existing Dock Icon."
|
||||
/usr/local/bin/dockutil --remove "${appName}" --allhomes >> ${logfile}
|
||||
/bin/sleep 5
|
||||
/bin/echo "`date`: Creating New Dock Icon." >> ${logfile}
|
||||
/bin/echo "Creating New Dock Icon."
|
||||
/usr/local/bin/dockutil --add "/Applications/${appName}.app" --after 'Safari' --allhomes >> ${logfile}
|
||||
fi
|
||||
/bin/sleep 3
|
||||
/bin/echo "--" >> ${logfile}
|
||||
else
|
||||
/bin/echo "`date`: ERROR: ${appName} update unsuccessful, version remains at ${currentinstalledver}." >> ${logfile}
|
||||
/bin/echo "ERROR: ${appName} update unsuccessful, version remains at ${currentinstalledver}."
|
||||
/bin/echo "--" >> ${logfile}
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# If App is up to date already, just log it and exit.
|
||||
else
|
||||
/bin/echo "`date`: ${appName} is already up to date, running ${currentinstalledver}." >> ${logfile}
|
||||
/bin/echo "`date`: ${appName} is already up to date, running ${currentinstalledver}."
|
||||
/bin/echo "--" >> ${logfile}
|
||||
fi
|
||||
|
||||
/bin/sleep 5
|
||||
/bin/echo "`date`: Deleting the downloaded file." >> ${logfile}
|
||||
/bin/echo "Deleting the downloaded file."
|
||||
/bin/rm /tmp/${dnldfile}
|
||||
# If App is up to date already, just log it and exit.
|
||||
else
|
||||
/bin/echo "`date`: ${appName} is already up to date, running ${currentinstalledver}." >> ${logfile}
|
||||
/bin/echo "`date`: ${appName} is already up to date, running ${currentinstalledver}."
|
||||
/bin/echo "--" >> ${logfile}
|
||||
fi
|
||||
|
||||
/bin/sleep 5
|
||||
/bin/echo "`date`: Deleting the downloaded file." >> ${logfile}
|
||||
/bin/echo "Deleting the downloaded file."
|
||||
/bin/rm /tmp/${dnldfile}
|
||||
echo "Command: DeterminateManualStep: 1" >> ${deplog}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user