v1.5 = Updated to support both Major Version 2 & 3

+ Updated to support both Major Version 2 & 3
This commit is contained in:
Zack T
2018-05-09 14:45:27 -07:00
parent b5dd8e3917
commit 15db377b82

View File

@@ -3,7 +3,7 @@
###################################################################################################
# Script Name: install_QGIS.sh
# By: Zack Thompson / Created: 7/26/2017
# Version: 1.4 / Updated: 3/19/2018 / By: ZT
# Version: 1.5 / Updated: 5/9/2018 / By: ZT
#
# Description: This script installs all the packages that are contained in the QGIS dmg.
#
@@ -15,9 +15,9 @@ echo "***** Install QGIS Process: START *****"
# Define Variables
# Set working directory
pkgDir=$(/usr/bin/dirname $0)
pkgDir=$(/usr/bin/dirname "${0}")
# Get the current user
currentUser=$(/usr/bin/python -c 'from SystemConfiguration import SCDynamicStoreCopyConsoleUser; import sys; username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]; username = [username,""][username in [u"loginwindow", None, u""]]; sys.stdout.write(username + "\n");')
# currentUser=$(/usr/bin/python -c 'from SystemConfiguration import SCDynamicStoreCopyConsoleUser; import sys; username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]; username = [username,""][username in [u"loginwindow", None, u""]]; sys.stdout.write(username + "\n");')
# Get the filename of the .dmg file
QGISdmg=$(/bin/ls "${pkgDir}" | /usr/bin/grep .dmg)
@@ -44,25 +44,27 @@ exitCheck() {
# Check the installation target.
if [[ $3 != "/" ]]; then
/bin/echo "ERROR: Target disk is not the startup disk."
/bin/echo "***** Install QGIS process: FAILED *****"
echo "ERROR: Target disk is not the startup disk."
echo "***** Install QGIS process: FAILED *****"
exit 1
fi
# Check if Python3 is installed
if [[ -x /usr/local/bin/python3 ]]; then
getVersion=$(/usr/local/bin/python3 --version | /usr/bin/awk -F "." '{print $2}')
if [[ $(/usr/bin/bc <<< "${getVersion} >= 6") -eq 1 ]]; then
echo "Python 3.6+ is installed!"
if [[ "${QGISdmg}" == "QGIS-3"* ]]; then
# Check if Python3 is installed
if [[ -x /usr/local/bin/python3 ]]; then
getVersion=$(/usr/local/bin/python3 --version | /usr/bin/awk -F "." '{print $2}')
if [[ $(/usr/bin/bc <<< "${getVersion} >= 6") -eq 1 ]]; then
echo "Python 3.6+ is installed!"
else
echo "ERROR: Python 3.6+ is not installed!"
echo "***** Install QGIS Process: FAILED *****"
exit 1
fi
else
echo "ERROR: Python 3.6+ is not installed!"
echo "***** Install QGIS Process: FAILED *****"
exit 1
fi
else
echo "ERROR: Python 3.6+ is not installed!"
echo "***** Install QGIS Process: FAILED *****"
exit 1
fi
# Check if QGIS is currently installed...
@@ -108,8 +110,14 @@ echo "All packages have been installed!"
/usr/bin/hdiutil eject /Volumes/"${QGISMount}"
# Disable version check (this is done because the version compared is not always the latest available for macOS).
# echo "Disabling version check on launch..."
# /usr/bin/sed -Ei '' 's/checkVersion=true/checkVersion=false/g' "/${currentUser}/Library/Application Support/QGIS/QGIS3/profiles/default/qgis.org/QGIS3.ini"
if [[ "${QGISdmg}" == "QGIS-3"* ]]; then
# Disabled this because the .ini file does not exist until the application is launched.
# echo "Disabling version check on launch..."
# /usr/bin/sed -Ei '' 's/checkVersion=true/checkVersion=false/g' "/${currentUser}/Library/Application Support/QGIS/QGIS3/profiles/default/qgis.org/QGIS3.ini"
elif [[ "${QGISdmg}" == "QGIS-2"* ]]; then
echo "Disabling version check on launch..."
/usr/bin/defaults write org.qgis.QGIS2.plist qgis.checkVersion -boolean false
fi
echo "${QGISMount} has been installed!"
echo "***** Install QGIS Process: COMPLETE *****"