From a9c878e1b765e8509de37c8931056e9bab7dd67d Mon Sep 17 00:00:00 2001 From: Zack T Date: Mon, 26 Mar 2018 22:29:24 -0700 Subject: [PATCH 1/7] v0.1 = Initial Version + Most of the basic logic is laid out and complete --- System Configs/create_Shortcut.sh | 98 +++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 System Configs/create_Shortcut.sh diff --git a/System Configs/create_Shortcut.sh b/System Configs/create_Shortcut.sh new file mode 100644 index 0000000..b0eac7e --- /dev/null +++ b/System Configs/create_Shortcut.sh @@ -0,0 +1,98 @@ +#!/bin/bash + +################################################################################################### +# Script Name: jamf_CreateShortcut.sh +# By: Zack Thompson / Created: 3/26/2018 +# Version: 0.1 / Updated: 3/26/2018 / By: ZT +# +# Description: This script will create a website shortcut in a specified location with a specified icon. +# +################################################################################################### + +echo "***** Create Shortcut process: START *****" + +################################################## +# Define Variables + fileName="${1}" + URL="${2}" + icon="${3}" + location="${4}" + +# 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");') + +defaultLocation="/Users/${currentUser}/Library/Shortcuts/" + +################################################## +# Setup Functions + +getHelp() { +echo " +usage: jamf_CreateShortcut.sh + +Info: This script will create a website shortcut in a specified location with a specified icon. + +Parameters: + filename Thise files' \"Display Name\". + + URL The website the shortcut is for. + + icon The image that will be used for the icon. + + location Where the shortcut will be saved. +" +} + +################################################## +# Bits staged... + +# Check to make sure all parameters were provided. +# if [[ -z "${4}" && -z "${5}" && -z "${6}" && -z "${7}"]]; then +# echo "ERROR: Missing required parameters!" +# # Function getHelp +# getHelp +# echo "***** Create Shortcut process: FAILED *****" +# exit 1 +# fi + +echo "Provided configuration:" +echo "Filename: ${fileName}" +echo "URL: ${URL}" +echo "Icon: ${icon}" +echo "Location: ${location}" + + +# Create the staging directory if it doesn't existing. +if [[ ! -d "${defaultLocation}" ]]; then + /bin/mkdir "${defaultLocation}" +fi + +# Create the file +echo "Creating the requested shortcut..." +/usr/bin/printf '%s\n' "[InternetShortcut]" "URL=${URL}" "" > "${defaultLocation}/${fileName}.url" + +# If the icon provided is on a web server, download it. +if [[ "${icon}" == "http"* ]]; then + echo "Downloading icon..." + /usr/bin/curl --silent --show-error --fail "${icon}" --output /tmp/icon.png + # curlAPI=(--silent --show-error --fail --user --write-out "statusCode:%{http_code}") + icon="/tmp/icon.png" +fi + +# Set the icon +echo "Adding the requested icon..." +/usr/bin/python -c "import Cocoa; import sys; Cocoa.NSWorkspace.sharedWorkspace().setIcon_forFile_options_(Cocoa.NSImage.alloc().initWithContentsOfFile_(sys.argv[1].decode('utf-8')), sys.argv[2].decode('utf-8'), 0) or sys.exit(\"Unable to set file icon\")" "${icon}" "${defaultLocation}/${fileName}.url" + +# Check where to place the file. +if [[ "${location}" == "Dock" ]]; then + # Add to dock + echo "Adding to the dock..." + /usr/bin/defaults write com.apple.dock persistent-apps -array-add "tile-datafile-data_CFURLStringfile://${defaultLocation}/${fileName}.url_CFURLStringType15file-label${fileName}.urlfile-type32tile-typefile-tile" + /usr/bin/killall Dock +else + echo "Moving file in place..." + /bin/mv "${defaultLocation}" "${location}" +fi + +echo "***** Create Shortcut process: COMPLETE *****" +exit 0 \ No newline at end of file From 496586b14283e5379541e3aeb30e74c02d9294ab Mon Sep 17 00:00:00 2001 From: Zack T Date: Mon, 26 Mar 2018 23:02:53 -0700 Subject: [PATCH 2/7] v1.3 = Added check if application exists + Added check if application exists; if so remove it. --- Software/Mathematica/install_Mathematica.sh | 22 +++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/Software/Mathematica/install_Mathematica.sh b/Software/Mathematica/install_Mathematica.sh index 311a2da..fe04546 100755 --- a/Software/Mathematica/install_Mathematica.sh +++ b/Software/Mathematica/install_Mathematica.sh @@ -3,28 +3,34 @@ ################################################################################################### # Script Name: install_Mathematica.sh # By: Zack Thompson / Created: 1/10/2018 -# Version: 1.2 / Updated: 1/31/2018 / By: ZT +# Version: 1.3 / Updated: 3/23/2018 / By: ZT # # Description: This script silently installs Mathematica. # ################################################################################################### -/bin/echo "***** Install Mathematica process: START *****" +echo "***** Install Mathematica process: START *****" ################################################## # Define Variables # Set working directory - pkgDir=$(/usr/bin/dirname $0) + pkgDir=$(/usr/bin/dirname "${0}") ################################################## # Bits staged... -# Install Mathematica -/bin/echo "Installing Mathematica..." - /bin/mv "${pkgDir}/Mathematica.app" /Applications -/bin/echo "Install complete!" +# Check if Mathematic is already installed. +if [[ -e "/Applications/Mathematica.app" ]]; then + echo "Mathematica is currently installed, removing..." + /bin/rm -rf "/Applications/Mathematica.app" +fi -/bin/echo "***** Install Mathematica process: COMPLETE *****" +# Install Mathematica +echo "Installing Mathematica..." + /bin/mv "${pkgDir}/Mathematica.app" /Applications +echo "Install complete!" + +echo "***** Install Mathematica process: COMPLETE *****" exit 0 \ No newline at end of file From be100dfb6a566e086d6e771b27c514d148afb611 Mon Sep 17 00:00:00 2001 From: Zack T Date: Tue, 27 Mar 2018 15:46:19 -0700 Subject: [PATCH 3/7] v0.2 = Resolved issues related to adding a shortcut to the dock + Resolved issues related to adding a shortcut to the dock + Minor formatting and cleanup --- System Configs/create_Shortcut.sh | 66 +++++++++++++++++++++---------- 1 file changed, 45 insertions(+), 21 deletions(-) diff --git a/System Configs/create_Shortcut.sh b/System Configs/create_Shortcut.sh index b0eac7e..00e89d5 100644 --- a/System Configs/create_Shortcut.sh +++ b/System Configs/create_Shortcut.sh @@ -1,9 +1,9 @@ #!/bin/bash ################################################################################################### -# Script Name: jamf_CreateShortcut.sh +# Script Name: create_Shortcut.sh # By: Zack Thompson / Created: 3/26/2018 -# Version: 0.1 / Updated: 3/26/2018 / By: ZT +# Version: 0.2 / Updated: 3/27/2018 / By: ZT # # Description: This script will create a website shortcut in a specified location with a specified icon. # @@ -13,15 +13,15 @@ echo "***** Create Shortcut process: START *****" ################################################## # Define Variables +# If using Jamf, change these values to: 4, 5, 6, 7 fileName="${1}" URL="${2}" icon="${3}" location="${4}" # 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");') - -defaultLocation="/Users/${currentUser}/Library/Shortcuts/" + 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");') + defaultLocation="/Users/${currentUser}/Library/Shortcuts" ################################################## # Setup Functions @@ -33,7 +33,7 @@ usage: jamf_CreateShortcut.sh Info: This script will create a website shortcut in a specified location with a specified icon. Parameters: - filename Thise files' \"Display Name\". + filename The files' \"Display Name\". URL The website the shortcut is for. @@ -47,13 +47,13 @@ Parameters: # Bits staged... # Check to make sure all parameters were provided. -# if [[ -z "${4}" && -z "${5}" && -z "${6}" && -z "${7}"]]; then -# echo "ERROR: Missing required parameters!" -# # Function getHelp -# getHelp -# echo "***** Create Shortcut process: FAILED *****" -# exit 1 -# fi +if [ -z "${fileName}" -a -z "${URL}" -a -z "${icon}" -a -z "${location}" ]; then + echo "ERROR: Missing required parameters!" + # Function getHelp + getHelp + echo "***** Create Shortcut process: FAILED *****" + exit 1 +fi echo "Provided configuration:" echo "Filename: ${fileName}" @@ -61,13 +61,12 @@ echo "URL: ${URL}" echo "Icon: ${icon}" echo "Location: ${location}" - # Create the staging directory if it doesn't existing. if [[ ! -d "${defaultLocation}" ]]; then /bin/mkdir "${defaultLocation}" fi -# Create the file +# Create the shortcut file. echo "Creating the requested shortcut..." /usr/bin/printf '%s\n' "[InternetShortcut]" "URL=${URL}" "" > "${defaultLocation}/${fileName}.url" @@ -79,19 +78,44 @@ if [[ "${icon}" == "http"* ]]; then icon="/tmp/icon.png" fi -# Set the icon +# Set the icon on the shortcut file. echo "Adding the requested icon..." /usr/bin/python -c "import Cocoa; import sys; Cocoa.NSWorkspace.sharedWorkspace().setIcon_forFile_options_(Cocoa.NSImage.alloc().initWithContentsOfFile_(sys.argv[1].decode('utf-8')), sys.argv[2].decode('utf-8'), 0) or sys.exit(\"Unable to set file icon\")" "${icon}" "${defaultLocation}/${fileName}.url" # Check where to place the file. if [[ "${location}" == "Dock" ]]; then - # Add to dock - echo "Adding to the dock..." - /usr/bin/defaults write com.apple.dock persistent-apps -array-add "tile-datafile-data_CFURLStringfile://${defaultLocation}/${fileName}.url_CFURLStringType15file-label${fileName}.urlfile-type32tile-typefile-tile" - /usr/bin/killall Dock + + # Setting a variable that holds whether the Dock item already exists or not (if it does, we don't want to unnecessarily edit and kill the Dock). + alreadyExists=0 + + # Get the number of items in the persistent-others node; then subtract one for Array value notation. + indexItem=$(/usr/libexec/PlistBuddy -x -c "Print :persistent-others" "/Users/${currentUser}/Library/Preferences/com.apple.dock.plist" | /usr/bin/xmllint --format - | /usr/bin/xpath 'count(//plist/array/dict)' 2>/dev/null) + indexItem=$((indexItem-1)) + + # Loop through all the items in the persistent-others node and compare to the new item being added. + for ((i=1; i<=$indexItem; ++i)); do + indexLabel=$(/usr/libexec/PlistBuddy -c "Print :persistent-others:${i}:tile-data:file-label" "/Users/${currentUser}/Library/Preferences/com.apple.dock.plist") + indexData=$(/usr/libexec/PlistBuddy -c "Print :persistent-others:${i}:tile-data:file-data:_CFURLString" "/Users/${currentUser}/Library/Preferences/com.apple.dock.plist") + + # Check if the current indexItem values equal the new items' values. + if [[ "${indexLabel}" == "${fileName}" && "${indexData}" == "file://${defaultLocation}/${fileName}.url" ]]; then + alreadyExists=1 + echo "Already exists!" + fi + done + + # If the new item does not already exist, add it to the Dock. + if [[ $alreadyExists == 0 ]]; then + echo "Adding to the dock..." + fileNameLocation=$(echo "${fileName}" | /usr/bin/sed 's/ /%20/g') + /usr/bin/sudo -s -u "${currentUser}" /usr/bin/defaults write "/Users/${currentUser}/Library/Preferences/com.apple.dock" persistent-others -array-add "tile-datafile-data_CFURLStringfile://${defaultLocation}/${fileNameLocation}.url_CFURLStringType15file-label${fileName}file-type32tile-typefile-tile" + /usr/bin/killall Dock + fi + else + # Move file to the specified location if not adding to the Dock. echo "Moving file in place..." - /bin/mv "${defaultLocation}" "${location}" + /bin/mv "${defaultLocation}/${fileName}.url" "${location}" fi echo "***** Create Shortcut process: COMPLETE *****" From 31658ac7e9fbfda2f408a6835a73b852eb3c0a1c Mon Sep 17 00:00:00 2001 From: Zack T Date: Sat, 31 Mar 2018 00:01:04 -0700 Subject: [PATCH 4/7] v1.0 = Production Version + Production Version --- Software/license_AutoCAD.sh | 105 ++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 Software/license_AutoCAD.sh diff --git a/Software/license_AutoCAD.sh b/Software/license_AutoCAD.sh new file mode 100644 index 0000000..93c2c01 --- /dev/null +++ b/Software/license_AutoCAD.sh @@ -0,0 +1,105 @@ +#!/bin/bash + +################################################################################################### +# Script Name: license_AutoCAD.sh +# By: Zack Thompson / Created: 3/29/2018 +# Version: 1.0 / Updated: 3/30/2018 / By: ZT +# +# Description: This script applies the license for AutoCAD applications. +# +################################################################################################### + +echo "***** License AutoCAD process: START *****" + +################################################## +# Define Variables + +licenseDirectory="/Library/Application Support/Autodesk/CLM/LGS" + +################################################## +# Turn on case-insensitive pattern matching +shopt -s nocasematch + +# Determine License Type +case "${4}" in + "T&R" | "Teaching and Research" | "Academic" ) + licenseType="Academic" + ;; + "Admin" | "Administrative" ) + licenseType="Administrative" + ;; + * ) + echo "ERROR: Invalid License Type provided" + echo "***** License AutoCAD process: FAILED *****" + exit 1 + ;; +esac + +echo "Licensing Type: ${licenseType}" + +# Determine License Mechanism +case "${5}" in + "LM" | "License Manager" | "Network" ) + licenseMechanism="NETWORK" + ;; + # "Stand Alone" | "Local" ) + # licenseMechanism="Local" + # ;; + * ) + echo "ERROR: Invalid License Mechanism provided" + echo "***** License AutoCAD process: FAILED *****" + exit 2 + ;; +esac + +# Turn off case-insensitive pattern matching +shopt -u nocasematch + +echo "Licensing Mechanism: ${licenseMechanism}" + +################################################## +# Bits staged, license software... + +# Find all install AutoCAD versions. +appPaths=$(/usr/bin/find -E /Applications -iregex ".*[/]AutoCAD 201[0-9]{1}[.]app" -type d -prune) + +# Verify that a AutoCAD Application was found. +if [[ -z "${appPaths}" ]]; then + echo "ERROR: AutoCAD was not found!" + echo "***** License AutoCAD process: FAILED *****" + exit 3 +else + installedVersions=$(ls "${licenseDirectory}") + + if [[ $licenseType == "Academic" && $licenseMechanism == "NETWORK" ]]; then +licenseContents="SERVER licser1.company.com 000000000000 12345 +SERVER licser2.company.com 000000000000 12345 +SERVER licser3.company.com 000000000000 12345 +USE_SERVER" + + # elif [[ $licenseType == "Academic" && $licenseMechanism == "Local" ]]; then + # licenseContents="" + + elif [[ $licenseType == "Administrative" && $licenseMechanism == "NETWORK" ]]; then +licenseContents="SERVER licser4.company.com 000000000000 67890 +SERVER licser5.company.com 000000000000 67890 +SERVER licser6.company.com 000000000000 67890 +USE_SERVER" + + # elif [[ $licenseType == "Administrative" && $licenseMechanism == "Local" ]]; then + # licenseContents="" + fi + + echo "Configuring the License Manager Server..." + + while IFS="\n" read -r version; do + echo "Product Version: ${version}" + /usr/bin/printf "${licenseContents}" > "${licenseDirectory}/${version}/LicPath.lic" + /usr/bin/printf "_${licenseMechanism}" > "${licenseDirectory}/${version}/LGS.data" + done < <(/usr/bin/printf '%s\n' $installedVersions) + +fi + +echo "AutoCAD has been activated!" +echo "***** License AutoCAD process: COMPLETE *****" +exit 0 \ No newline at end of file From 01c3e37837564e6478f5da0675b1d25a0c954e78 Mon Sep 17 00:00:00 2001 From: Zack T Date: Tue, 3 Apr 2018 11:06:58 -0700 Subject: [PATCH 5/7] v1.0 = Production Version + Production Version --- Software/AutoCAD/build_AutoCAD.sh | 82 +++++++++++++++++++ Software/{ => AutoCAD}/license_AutoCAD.sh | 0 Software/AutoCAD/update_AutoCAD.sh | 97 +++++++++++++++++++++++ 3 files changed, 179 insertions(+) create mode 100644 Software/AutoCAD/build_AutoCAD.sh rename Software/{ => AutoCAD}/license_AutoCAD.sh (100%) create mode 100644 Software/AutoCAD/update_AutoCAD.sh diff --git a/Software/AutoCAD/build_AutoCAD.sh b/Software/AutoCAD/build_AutoCAD.sh new file mode 100644 index 0000000..afb3bef --- /dev/null +++ b/Software/AutoCAD/build_AutoCAD.sh @@ -0,0 +1,82 @@ +#!/bin/bash + +################################################################################################### +# Script Name: build_AutoCAD.sh +# By: Zack Thompson / Created: 4/2/2018 +# Version: 1.0 / Updated: 4/2/2018 / By: ZT +# +# Description: This script uses munkipkg to build an AutoCAD package. +# +################################################################################################### + +echo "***** Build AutoCAD process: START *****" + +################################################## +# Define Variables + +softwareTitle="AutoCAD" + +# Switches + switch1="${1}" # Build Type + switch2="${2}" # Version + switch3="${3}" # Version Value + +# Set working directory + scriptDirectory=$(/usr/bin/dirname "$(/usr/bin/stat -f "$0")") + +################################################## +# Setup Functions + +function getHelp { +echo " +usage: build_AutoCAD.sh [-update] [-version] -help + +Info: Uses munkipkg to build a package for use in Jamf. + +Actions: + -update Builds a package to update a new version + Example: build_AutoCAD.sh -update -version 2017.0 + + -help Displays this help text. + Example: build_AutoCAD.sh -help +" +} + +function munkiBuild { + /usr/libexec/PlistBuddy -c "set identifier com.github.mlbz521.pkg.${softwareTitle}" "${scriptDirectory}"/build-info.plist + /usr/libexec/PlistBuddy -c "set name ${softwareTitle} Unlicensed-\${version}.pkg" "${scriptDirectory}"/build-info.plist + /usr/libexec/PlistBuddy -c "set version $switch3" "${scriptDirectory}"/build-info.plist + + munkipkg "${scriptDirectory}" > /dev/null + + # Function cleanUp + cleanUp +} + +function cleanUp { + /bin/rm "${scriptDirectory}"/scripts/postinstall + /bin/mv "${scriptDirectory}"/scripts/* "${scriptDirectory}"/build/$switch3/ +} + +################################################## +# Find out what we want to do... + +echo "Build Type: $switch1" +echo "Version: $switch3" + +case $switch1 in + -update ) + /bin/cp "${scriptDirectory}"/update_AutoCAD.sh "${scriptDirectory}"/scripts/postinstall + /bin/mv "${scriptDirectory}"/build/$switch3/* "${scriptDirectory}"/scripts/ + + # Function munkiBuild + munkiBuild + ;; + -help | * ) + # Function getHelp + getHelp + ;; +esac + +echo "***** Build AutoCAD process: COMPLETE *****" +exit 0 \ No newline at end of file diff --git a/Software/license_AutoCAD.sh b/Software/AutoCAD/license_AutoCAD.sh similarity index 100% rename from Software/license_AutoCAD.sh rename to Software/AutoCAD/license_AutoCAD.sh diff --git a/Software/AutoCAD/update_AutoCAD.sh b/Software/AutoCAD/update_AutoCAD.sh new file mode 100644 index 0000000..3a6440d --- /dev/null +++ b/Software/AutoCAD/update_AutoCAD.sh @@ -0,0 +1,97 @@ +#!/bin/bash + +################################################################################################### +# Script Name: update_AutoCAD.sh +# By: Zack Thompson / Created: 4/2/2018 +# Version: 1.0 / Updated: 4/2/2018 / By: ZT +# +# Description: This script will update an AutoCAD install. +# +################################################################################################### + +echo "***** Update AutoCAD process: START *****" + +################################################## +# Define Variables + +# Set working directory + pkgDir=$(/usr/bin/dirname "${0}") +# Get Configuration details... + targetAppName=$(/usr/bin/defaults read "${pkgDir}/VerTarget.plist" TargetAppName) + newVersion=$(/usr/bin/defaults read "${pkgDir}/VerTarget.plist" UpdateVersion) + versionsToPatch=$(/bin/cat "${pkgDir}/VerTarget.plist" | /usr/bin/xmllint --format - | /usr/bin/xpath '/plist/dict/array/string' 2>/dev/null | LANG=C /usr/bin/sed -e 's/<[^/>]*>//g' | LANG=C /usr/bin/sed -e 's/<[^>]*>/\'$'\n/g') + compatible=1 +# Find the AutoCAD version being updated... + echo "Searching for ${targetAppName}..." + appPath=$(/usr/bin/find -E /Applications -iregex ".*[/]${targetAppName}[.]app" -type d -prune) + +if [[ -z "${appPath}" ]]; then + echo "A version of AutoCAD was not found in the expected location!" + echo "***** Update AutoCAD process: FAILED *****" + exit 1 +else + # Get the App Bundle name... + appName=$(echo "${appPath}" | /usr/bin/awk -F "/" '{print $NF}') + # Get only the install path... + installPath=$(echo "${appPath}" | /usr/bin/awk -F "/${appName}" '{print $1}') + # Get the Current Version CFBundleVersion... + oldBundleVersion=$(/usr/bin/defaults read "${appPath}/Contents/Info.plist" CFBundleVersion) +fi + +################################################## +# Bits staged... + +# Check if patch version is the current version. +if [[ "${newVersion}" == "${oldBundleVersion}" ]]; then + echo "AutoCAD is already up to date!" + echo "***** Update AutoCAD process: FAILED *****" + exit 2 +fi + +echo "App Path: ${appPath}" +echo "Current Version: ${oldBundleVersion}" +echo "Patch Version: ${newVersion}" + +# Verify that this patch is compatible with this version. +while IFS=\n read -r versionPatch; do + if [[ "${versionPatch}" == "${oldBundleVersion}" ]]; then + echo "${newVersion} is a valid patch for: ${oldBundleVersion}" + compatible=0 + fi +done < <(/usr/bin/printf '%s\n' "${versionsToPatch}") + +# If compatible, install, if not error out. +if [[ $compatible -eq true ]]; then + echo "Installing patch..." + exitStatus=$("${pkgDir}/BinaryDelta" apply "${installPath}" "${pkgDir}/product.delta") + exitCode=$? +else + echo "ERROR: This patch is not compatible with the installed version!" + echo "***** Update AutoCAD process: FAILED *****" + exit 3 +fi + +# Check the exit code. +if [[ $exitCode != 0 ]]; then + echo "ERROR: Update failed!" + echo "Exit Code: ${exitCode}" + echo "Exit status was: ${exitStatus}" + echo "***** Update AutoCAD process: FAILED *****" + exit 4 +else + # Get the new CFBundleVersion... + newBundleVersion=$(/usr/bin/defaults read "${appPath}/Contents/Info.plist" CFBundleVersion) + + # Confirm that the CFBundleVersion is the expected value. + if [[ "${newVersion}" == "${newBundleVersion}" ]]; then + echo "Update complete!" + else + echo "ERROR: Update failed!" + echo "AutoCAD was not properly updated!" + echo "***** Update AutoCAD process: FAILED *****" + exit 5 + fi +fi + +echo "***** Update AutoCAD process: COMPLETE *****" +exit 0 \ No newline at end of file From 1bda43f7e71c9748c9c6f0fc3cec7f322c163e1f Mon Sep 17 00:00:00 2001 From: Zack T Date: Tue, 3 Apr 2018 11:14:52 -0700 Subject: [PATCH 6/7] Code Improvements + Code Improvements --- Software/Maple/build_Maple.sh | 10 ++--- Software/Maple/install_Maple.sh | 24 ++++++------ Software/Maple/license_Maple.sh | 34 ++++++++--------- Software/Maple/update_Maple.sh | 28 +++++++------- Software/Mathematica/build_Mathematica.sh | 12 +++--- Software/Mathematica/license_Mathematica.sh | 18 ++++----- Software/Matlab/build_Matlab.sh | 12 +++--- Software/Matlab/install_MatLab.sh | 28 ++++++++------ Software/Matlab/license_Matlab.sh | 24 ++++++------ Software/README.md | 3 ++ Software/SPSS Statistics/build_SPSS.sh | 14 +++---- Software/SPSS Statistics/install_SPSS.sh | 24 ++++++------ Software/SPSS Statistics/license_SPSS.sh | 42 ++++++++++----------- Software/SPSS Statistics/uninstall_SPSS.sh | 18 ++++----- Software/SPSS Statistics/update_SPSS.sh | 28 +++++++------- Software/install_QGIS.sh | 8 ++-- Software/license_Fetch.sh | 20 +++++----- Software/license_JMP.sh | 22 +++++------ Software/license_Minitab.sh | 16 ++++---- Software/license_Parallels.sh | 28 +++++++------- Software/license_VMwareFusion.sh | 20 +++++----- Software/uninstall_AcrobatDC2015.sh | 10 ++--- Software/uninstall_AcrobatPro2017.sh | 10 ++--- 23 files changed, 231 insertions(+), 222 deletions(-) diff --git a/Software/Maple/build_Maple.sh b/Software/Maple/build_Maple.sh index 1e224cb..84868d9 100644 --- a/Software/Maple/build_Maple.sh +++ b/Software/Maple/build_Maple.sh @@ -3,13 +3,13 @@ ################################################################################################### # Script Name: build_Maple.sh # By: Zack Thompson / Created: 1/8/2018 -# Version: 1.1.1 / Updated: 1/25/2018 / By: ZT +# Version: 1.1.2 / Updated: 3/30/2018 / By: ZT # # Description: This script uses munkipkg to build an Maple package. # ################################################################################################### -/bin/echo "***** Build Maple process: START *****" +echo "***** Build Maple process: START *****" ################################################## # Define Variables @@ -65,8 +65,8 @@ function cleanUp { ################################################## # Find out what we want to do... -/bin/echo "Build Type: $switch1" -/bin/echo "Version: $switch3" +echo "Build Type: $switch1" +echo "Version: $switch3" case $switch1 in -install ) @@ -96,5 +96,5 @@ case $switch1 in ;; esac -/bin/echo "***** Build Maple process: COMPLETE *****" +echo "***** Build Maple process: COMPLETE *****" exit 0 \ No newline at end of file diff --git a/Software/Maple/install_Maple.sh b/Software/Maple/install_Maple.sh index 8f417e3..49b3cfa 100755 --- a/Software/Maple/install_Maple.sh +++ b/Software/Maple/install_Maple.sh @@ -3,19 +3,19 @@ ################################################################################################### # Script Name: install_Maple.sh # By: Zack Thompson / Created: 3/2/2017 -# Version: 1.5 / Updated: 1/31/2018 / By: ZT +# Version: 1.5.1 / Updated: 3/30/2018 / By: ZT # # Description: This script silently installs Maple. # ################################################################################################### -/bin/echo "***** Install Maple process: START *****" +echo "***** Install Maple process: START *****" ################################################## # Define Variables # Set working directory - pkgDir=$(/usr/bin/dirname $0) + pkgDir=$(/usr/bin/dirname "${0}") # Java JDK Directory jdkDir="/Library/Java/JavaVirtualMachines" # Version that's being updated (this will be set by the build_Maple.sh script) @@ -25,26 +25,26 @@ # Bits staged... if [[ ! -d $(/usr/bin/find $jdkDir -iname 1.6*.jdk) ]]; then - /bin/echo "Java JDK 1.6 is required for full Maple functionality: Installing..." + echo "Java JDK 1.6 is required for full Maple functionality: Installing..." # Apple update 'Java for OS X 2015-001' is required for Maples as well, installing that here. /usr/sbin/installer -dumplog -verbose -pkg "${pkgDir}/JavaForOSX.pkg" -target / - /bin/echo 'Java JDK installed!' + echo 'Java JDK installed!' fi # Install Maple -/bin/echo "Installing Maple..." +echo "Installing Maple..." exitStatus=$("${pkgDir}/Maple${version}MacInstaller.app/Contents/MacOS/installbuilder.sh" --mode unattended) exitCode=$? if [[ $exitCode != 0 ]]; then - /bin/echo "ERROR: Install failed!" - /bin/echo "Exit Code: ${exitCode}" - /bin/echo "Exit status was: ${exitStatus}" - /bin/echo "***** Install Maple process: FAILED *****" + echo "ERROR: Install failed!" + echo "Exit Code: ${exitCode}" + echo "Exit status was: ${exitStatus}" + echo "***** Install Maple process: FAILED *****" exit 1 fi -/bin/echo "Install complete!" -/bin/echo "***** Install Maple process: COMPLETE *****" +echo "Install complete!" +echo "***** Install Maple process: COMPLETE *****" exit 0 \ No newline at end of file diff --git a/Software/Maple/license_Maple.sh b/Software/Maple/license_Maple.sh index 6ddce62..494f635 100755 --- a/Software/Maple/license_Maple.sh +++ b/Software/Maple/license_Maple.sh @@ -3,13 +3,13 @@ ################################################################################################### # Script Name: license_Maple.sh # By: Zack Thompson / Created: 1/8/2018 -# Version: 1.5.1 / Updated: 2/7/2018 / By: ZT +# Version: 1.5.2 / Updated: 3/30/2018 / By: ZT # # Description: This script applies the license for Maple applications. # ################################################################################################### -/usr/bin/logger -s "***** License Maple process: START *****" +echo "***** License Maple process: START *****" ################################################## # Turn on case-insensitive pattern matching @@ -24,8 +24,8 @@ shopt -s nocasematch licenseMechanism="Local" ;; * ) - /usr/bin/logger -s "ERROR: Invalid License Mechanism provided" - /usr/bin/logger -s "***** License Maple process: FAILED *****" + echo "ERROR: Invalid License Mechanism provided" + echo "***** License Maple process: FAILED *****" exit 1 ;; esac @@ -33,7 +33,7 @@ shopt -s nocasematch # Turn off case-insensitive pattern matching shopt -u nocasematch - /usr/bin/logger -s "Licensing Mechanism: ${licenseMechanism}" + echo "Licensing Mechanism: ${licenseMechanism}" ################################################## # Bits staged, license software... @@ -43,8 +43,8 @@ appPaths=$(/usr/bin/find -E /Applications -iregex ".*Maple [0-9]{4}[.]app" -maxd # Verify that a Maple version was found. if [[ -z "${appPaths}" ]]; then - /usr/bin/logger -s "A version of Maple was not found in the expected location!" - /usr/bin/logger -s "***** License Maple process: FAILED *****" + echo "A version of Maple was not found in the expected location!" + echo "***** License Maple process: FAILED *****" exit 2 else # If the machine has multiple Maple Applications, loop through them... @@ -52,7 +52,7 @@ else # Get the Maple version majorVersion=$(/usr/bin/defaults read "${appPath}/Contents/Info.plist" CFBundleShortVersionString | /usr/bin/awk -F "." '{print $1}') - /usr/bin/logger -s "Applying License for Major Version: ${majorVersion}" + echo "Applying License for Major Version: ${majorVersion}" # Location of the License File licenseFile="/Library/Frameworks/Maple.framework/Versions/${majorVersion}/license/license.dat" @@ -60,7 +60,7 @@ else if [[ -d "${appPath}" ]]; then if [[ $licenseMechanism == "Network" ]]; then - /usr/bin/logger -s "Configuring the License Manager Server..." + echo "Configuring the License Manager Server..." /bin/cat > "${licenseFile}" < -help Info: Uses munkipkg to build a package for use in Jamf. @@ -61,8 +61,8 @@ function cleanUp { ################################################## # Find out what we want to do... -/bin/echo "Build Type: $switch1" -/bin/echo "Version: $switch3" +echo "Build Type: $switch1" +echo "Version: $switch3" case $switch1 in -install ) @@ -78,5 +78,5 @@ case $switch1 in ;; esac -/bin/echo "***** Build Mathematica process: COMPLETE *****" +echo "***** Build Mathematica process: COMPLETE *****" exit 0 \ No newline at end of file diff --git a/Software/Mathematica/license_Mathematica.sh b/Software/Mathematica/license_Mathematica.sh index 807a1b6..787cdb7 100755 --- a/Software/Mathematica/license_Mathematica.sh +++ b/Software/Mathematica/license_Mathematica.sh @@ -3,13 +3,13 @@ ################################################################################################### # Script Name: license_Mathematica.sh # By: Zack Thompson / Created: 1/10/2018 -# Version: 1.1 / Updated: 1/29/2018 / By: ZT +# Version: 1.1.1 / Updated: 4/2/2018 / By: ZT # # Description: This script applies the license for Mathematica applications. # ################################################################################################### -/usr/bin/logger -s "***** License Mathematica process: START *****" +echo "***** License Mathematica process: START *****" ################################################## # Define Variables @@ -21,11 +21,11 @@ licenseFile="${licenseDirectory}/mathpass" # Create the license file. if [[ ! -d "${licenseDirectory}" ]]; then - /usr/bin/logger -s "Creating License Directory..." + echo "Creating License Directory..." /bin/mkdir -p "${licenseDirectory}" fi -/usr/bin/logger -s "Creating license file..." +echo "Creating license file..." /bin/cat > "${licenseFile}" < -help Info: Uses munkipkg to build a package for use in Jamf. @@ -61,8 +61,8 @@ function cleanUp { ################################################## # Find out what we want to do... -/bin/echo "Build Type: $switch1" -/bin/echo "Version: $switch3" +echo "Build Type: $switch1" +echo "Version: $switch3" case $switch1 in -install ) @@ -81,5 +81,5 @@ case $switch1 in ;; esac -/bin/echo "***** Build Matlab process: COMPLETE *****" +echo "***** Build Matlab process: COMPLETE *****" exit 0 \ No newline at end of file diff --git a/Software/Matlab/install_MatLab.sh b/Software/Matlab/install_MatLab.sh index 29e0f77..458ad8c 100644 --- a/Software/Matlab/install_MatLab.sh +++ b/Software/Matlab/install_MatLab.sh @@ -3,19 +3,19 @@ ################################################################################################### # Script Name: install_MatLab.sh # By: Zack Thompson / Created: 3/6/2017 -# Version: 1.5 / Updated: 1/31/2018 / By: ZT +# Version: 1.6 / Updated: 3/29/2018 / By: ZT # # Description: This script installs MatLab. # ################################################################################################### -/bin/echo "***** Install Matlab process: START *****" +echo "***** Install Matlab process: START *****" ################################################## # Define Variables # Set working directory - pkgDir=$(/usr/bin/dirname $0) + pkgDir=$(/usr/bin/dirname "${0}") # Version that's being updated (this will be set by the build_Matlab.sh script) version= @@ -23,31 +23,37 @@ # Bits staged... # Install MatLab with option file. -/bin/echo "Installing Matlab..." +echo "Installing Matlab..." if [[ $version == "2017a" ]]; then # Inject dummy location to the installer.input file -- hacky, but works LANG=C /usr/bin/sed -Ei '' 's,(#)?licensePath=.*,'"licensePath=${pkgDir}/installer_input.txt"',' "${pkgDir}/installer_input.txt" # -mode silent did not work in the option file for me. exitStatus=$("${pkgDir}/install" -mode silent -inputFile "${pkgDir}/installer_input.txt") -else +elif [[ $version == "2017b" ]]; then # I'm assuming all future version will be packaged in this manner...(/hoping)..? + exitStatus=$("${pkgDir}/InstallForMacOSX.app/Contents/MacOS/InstallForMacOSX" -inputFile "${pkgDir}/installer_input.txt") +else + # 2018a did not work like 2017b unfortunately, where I didn't have to specify the licensePath... + # Inject dummy location to the installer.input file -- hacky, but works + LANG=C /usr/bin/sed -Ei '' 's,(#)?licensePath=.*,'"licensePath=${pkgDir}/installer_input.txt"',' "${pkgDir}/installer_input.txt" + exitStatus=$("${pkgDir}/InstallForMacOSX.app/Contents/MacOS/InstallForMacOSX" -inputFile "${pkgDir}/installer_input.txt") fi exitCode=$? if [[ $exitCode != 0 ]]; then - /bin/echo "Exit Code: ${exitCode}" + echo "Exit Code: ${exitCode}" fi if [[ $exitStatus == *"End - Unsuccessful"* ]]; then - /bin/echo "ERROR: Install failed!" - /bin/echo "ERROR Content: ${exitStatus}" - /bin/echo "***** Install Matlab process: FAILED *****" + echo "ERROR: Install failed!" + echo "ERROR Content: ${exitStatus}" + echo "***** Install Matlab process: FAILED *****" exit 1 fi -/bin/echo "Install complete!" -/bin/echo "***** Install Matlab process: COMPLETE *****" +echo "Install complete!" +echo "***** Install Matlab process: COMPLETE *****" exit 0 \ No newline at end of file diff --git a/Software/Matlab/license_Matlab.sh b/Software/Matlab/license_Matlab.sh index b609bdf..0cf7cea 100755 --- a/Software/Matlab/license_Matlab.sh +++ b/Software/Matlab/license_Matlab.sh @@ -3,13 +3,13 @@ ################################################################################################### # Script Name: license_Matlab.sh # By: Zack Thompson / Created: 1/10/2018 -# Version: 1.1 / Updated: 1/30/2018 / By: ZT +# Version: 1.1.1 / Updated: 4/2/2018 / By: ZT # # Description: This script applies the license for Matlab applications. # ################################################################################################### -/usr/bin/logger -s "***** License Matlab process: START *****" +echo "***** License Matlab process: START *****" ################################################## # Define Variables @@ -19,8 +19,8 @@ appPaths=$(/usr/bin/find /Applications -iname "Matlab*.app" -maxdepth 1 -type d) # Verify that a Matlab version was found. if [[ -z "${appPaths}" ]]; then - /usr/bin/logger -s "A version of Matlab was not found in the expected location!" - /usr/bin/logger -s "***** License Matlab process: FAILED *****" + echo "A version of Matlab was not found in the expected location!" + echo "***** License Matlab process: FAILED *****" exit 1 else # If the machine has multiple Matlab Applications, loop through them... @@ -28,7 +28,7 @@ else # Get the Matlab version appVersion=$(/bin/cat "${appPath}/VersionInfo.xml" | /usr/bin/grep release | /usr/bin/awk -F "<(/)?release>" '{print $2}') - /usr/bin/logger -s "Applying License for Version: ${appVersion}" + echo "Applying License for Version: ${appVersion}" # Build the license file location licenseFile="${appPath}/licenses/network.lic" @@ -36,7 +36,7 @@ else ################################################## # Create the license file. - /usr/bin/logger -s "Creating license file..." + echo "Creating license file..." /bin/cat > "${licenseFile}" < -help Info: Uses munkipkg to build a package for use in Jamf. @@ -68,8 +68,8 @@ function cleanUp { ################################################## # Find out what we want to do... -/bin/echo "Build Type: $switch1" -/bin/echo "Version: $switch3" +echo "Build Type: $switch1" +echo "Version: $switch3" case $switch1 in -install ) @@ -102,5 +102,5 @@ case $switch1 in ;; esac -/bin/echo "***** Build SPSS process: COMPLETE *****" +echo "***** Build SPSS process: COMPLETE *****" exit 0 \ No newline at end of file diff --git a/Software/SPSS Statistics/install_SPSS.sh b/Software/SPSS Statistics/install_SPSS.sh index 6c3878b..48ea845 100644 --- a/Software/SPSS Statistics/install_SPSS.sh +++ b/Software/SPSS Statistics/install_SPSS.sh @@ -3,31 +3,31 @@ ################################################################################################### # Script Name: install_SPSS.sh # By: Zack Thompson / Created: 11/1/2017 -# Version: 1.3 / Updated: 1/25/2018 / By: ZT +# Version: 1.3.1 / Updated: 4/2/2018 / By: ZT # # Description: This script silently installs SPSS. # ################################################################################################### -/bin/echo "***** Install SPSS process: START *****" +echo "***** Install SPSS process: START *****" ################################################## # Define Variables # Set working directory - pkgDir=$(/usr/bin/dirname $0) + pkgDir=$(/usr/bin/dirname "${0}") # Java JDK Directory jdkDir="/Library/Java/JavaVirtualMachines" # Version that's being updated (this will be set by the build_SPSS.sh script) version= - majorVersion=$(/bin/echo $version | /usr/bin/awk -F "." '{print $1}') + majorVersion=$(echo $version | /usr/bin/awk -F "." '{print $1}') ################################################## # Bits staged... if [[ -d $(/usr/bin/find "/Library/Java/JavaVirtualMachines" -iname "*.jdk" -type d) ]]; then # Install prerequisite: Java JDK - /bin/echo "Installing prerequisite Java JDK from Jamf..." + echo "Installing prerequisite Java JDK from Jamf..." /usr/local/bin/jamf policy -id 721 -forceNoRecon fi @@ -35,19 +35,19 @@ fi /bin/chmod +x "${pkgDir}/SPSS_Statistics_Installer.bin" # Silent install using information in the installer.properties file -/bin/echo "Installing SPSS..." +echo "Installing SPSS..." exitStatus=$("${pkgDir}/SPSS_Statistics_Installer.bin" -f "${pkgDir}/installer.properties") exitCode=$? if [[ ! -d "/Applications/SPSS Statistics ${majorVersion}/SPSSStatistics.app" ]]; then - /bin/echo "ERROR: Install failed!" - /bin/echo "Exit Code: ${exitCode}" - /bin/echo "ERROR Content: ${exitStatus}" - /bin/echo "***** Install SPSS process: FAILED *****" + echo "ERROR: Install failed!" + echo "Exit Code: ${exitCode}" + echo "ERROR Content: ${exitStatus}" + echo "***** Install SPSS process: FAILED *****" exit 1 fi -/bin/echo "Install complete!" -/bin/echo "***** Install SPSS process: COMPLETE *****" +echo "Install complete!" +echo "***** Install SPSS process: COMPLETE *****" exit 0 \ No newline at end of file diff --git a/Software/SPSS Statistics/license_SPSS.sh b/Software/SPSS Statistics/license_SPSS.sh index c5fe47b..f42b38e 100644 --- a/Software/SPSS Statistics/license_SPSS.sh +++ b/Software/SPSS Statistics/license_SPSS.sh @@ -3,13 +3,13 @@ ################################################################################################### # Script Name: license_SPSS.sh # By: Zack Thompson / Created: 1/3/2018 -# Version: 1.5 / Updated: 1/30/2018 / By: ZT +# Version: 1.5.1 / Updated: 4/2/2018 / By: ZT # # Description: This script applies the license for SPSS applications. # ################################################################################################### -/usr/bin/logger -s "***** License SPSS process: START *****" +echo "***** License SPSS process: START *****" ################################################## # Turn on case-insensitive pattern matching @@ -24,13 +24,13 @@ case "${4}" in licenseType="Administrative" ;; * ) - /usr/bin/logger -s "ERROR: Invalid License Type provided" - /usr/bin/logger -s "***** License SPSS process: FAILED *****" + echo "ERROR: Invalid License Type provided" + echo "***** License SPSS process: FAILED *****" exit 1 ;; esac -/usr/bin/logger -s "Licensing Type: ${licenseType}" +echo "Licensing Type: ${licenseType}" # Determine License Mechanism case "${5}" in @@ -41,8 +41,8 @@ case "${5}" in licenseMechanism="Local" ;; * ) - /usr/bin/logger -s "ERROR: Invalid License Mechanism provided" - /usr/bin/logger -s "***** License SPSS process: FAILED *****" + echo "ERROR: Invalid License Mechanism provided" + echo "***** License SPSS process: FAILED *****" exit 2 ;; esac @@ -50,7 +50,7 @@ esac # Turn off case-insensitive pattern matching shopt -u nocasematch -/usr/bin/logger -s "Licensing Mechanism: ${licenseMechanism}" +echo "Licensing Mechanism: ${licenseMechanism}" ################################################## # Define Functions @@ -99,8 +99,8 @@ appPaths=$(/usr/bin/find -E /Applications -iregex ".*[/](SPSS) ?(Statistics) ?([ # Verify that a Maple version was found. if [[ -z "${appPaths}" ]]; then - /usr/bin/logger -s "A version of SPSS was not found in the expected location!" - /usr/bin/logger -s "***** License SPSS process: FAILED *****" + echo "A version of SPSS was not found in the expected location!" + echo "***** License SPSS process: FAILED *****" exit 3 else # If the machine has multiple SPSS Applications, loop through them... @@ -115,7 +115,7 @@ else if [[ $licenseMechanism == "Network" ]]; then - /usr/bin/logger -s "Configuring the License Manager Server..." + echo "Configuring the License Manager Server..." # Function LicenseInfo LicenseInfo @@ -125,7 +125,7 @@ else /usr/bin/sed -i '' 's/CommuterMaxLife=.*/'"CommuterMaxLife=${commuterDays}"'/' "${networkLicense}" if [[ -e "${localLicense}" ]]; then - /usr/bin/logger -s "Local License file exists; deleting..." + echo "Local License file exists; deleting..." /bin/rm -rf "${localLicense}" fi @@ -133,7 +133,7 @@ else # Get the SPSS version versionSPSS=$(/usr/bin/defaults read "${appPath}/Contents/Info.plist" CFBundleShortVersionString | /usr/bin/awk -F "." '{print $1}') - /usr/bin/logger -s "Apply License Code for version: ${versionSPSS}" + echo "Apply License Code for version: ${versionSPSS}" # Function LicenseInfo LicenseInfo @@ -142,24 +142,24 @@ else exitStatus=$(cd "${licensePath}" && "${licensePath}"/licenseactivator "${licenseCode}") if [[ $exitStatus == *"Authorization succeeded"* ]]; then - /usr/bin/logger -s "License Code applied successfully!" + echo "License Code applied successfully!" if [[ -e "${networkLicense}" ]]; then - /usr/bin/logger -s "Removing Network License Manager info..." + echo "Removing Network License Manager info..." # Remove the License Manager Server Name. /usr/bin/sed -i '' 's/DaemonHost=.*/DaemonHost=/' "${networkLicense}" fi else - /usr/bin/logger -s "ERROR: Failed to apply License Code" - /usr/bin/logger -s "ERROR Contents: ${exitStatus}" - /usr/bin/logger -s "***** License SPSS process: FAILED *****" + echo "ERROR: Failed to apply License Code" + echo "ERROR Contents: ${exitStatus}" + echo "***** License SPSS process: FAILED *****" exit 4 fi fi - done < <(/bin/echo "${appPaths}") + done < <(echo "${appPaths}") fi -/usr/bin/logger -s "SPSS has been activated!" -/usr/bin/logger -s "***** License SPSS process: COMPLETE *****" +echo "SPSS has been activated!" +echo "***** License SPSS process: COMPLETE *****" exit 0 \ No newline at end of file diff --git a/Software/SPSS Statistics/uninstall_SPSS.sh b/Software/SPSS Statistics/uninstall_SPSS.sh index 433027b..bd36d27 100644 --- a/Software/SPSS Statistics/uninstall_SPSS.sh +++ b/Software/SPSS Statistics/uninstall_SPSS.sh @@ -3,33 +3,33 @@ ################################################################################################### # Script Name: uninstall_SPSS.sh # By: Zack Thompson / Created: 11/1/2017 -# Version: 1.2 / Updated: 1/25/2018 / By: ZT +# Version: 1.2.1 / Updated: 4/2/2018 / By: ZT # # Description: Remove previous version(s) of SPSS from /Applications # ################################################################################################### -/bin/echo "***** Uninstall SPSS process: START *****" +echo "***** Uninstall SPSS process: START *****" -/bin/echo "Searching for existing SPSS instances..." +echo "Searching for existing SPSS instances..." appPaths=$(/usr/bin/find -E /Applications -iregex ".*[/](SPSS) ?(Statistics) ?([0-9]{2})?[.]app" -type d -prune) # Verify that a SPSS version was found. if [[ -z "${appPaths}" ]]; then - /bin/echo "Did not find an instance SPSS!" + echo "Did not find an instance SPSS!" else # If the machine has multiple SPSS Applications, loop through them... while IFS="\n" read -r appPath; do # Get the App Bundle name - appName=$(/bin/echo $appPath | /usr/bin/awk -F "/" '{print $NF}') + appName=$(echo $appPath | /usr/bin/awk -F "/" '{print $NF}') # Get only the install path - installPath=$(/bin/echo $appPath | /usr/bin/awk -F "/$appName" '{print $1}') + installPath=$(echo $appPath | /usr/bin/awk -F "/$appName" '{print $1}') # Delete the old version - /bin/echo "Uninstalling: ${appPath}" + echo "Uninstalling: ${appPath}" /bin/rm -rf "${installPath}" - done < <(/bin/echo "${appPaths}") + done < <(echo "${appPaths}") fi -/bin/echo "***** Uninstall SPSS process: COMPLETE *****" +echo "***** Uninstall SPSS process: COMPLETE *****" exit 0 diff --git a/Software/SPSS Statistics/update_SPSS.sh b/Software/SPSS Statistics/update_SPSS.sh index 3b3ea1a..43840f3 100644 --- a/Software/SPSS Statistics/update_SPSS.sh +++ b/Software/SPSS Statistics/update_SPSS.sh @@ -3,13 +3,13 @@ ################################################################################################### # Script Name: update_SPSS.sh # By: Zack Thompson / Created: 11/22//2017 -# Version: 1.5 / Updated: 1/29/2018 / By: ZT +# Version: 1.5.1 / Updated: 4/2/2018 / By: ZT # # Description: This script grabs the current location of the SPSSStatistics.app and injects it into the installer.properties file and then will upgrade an SPSS Installation. # ################################################################################################### -/bin/echo "***** Upgrade SPSS process: START *****" +echo "***** Upgrade SPSS process: START *****" ################################################## # Define Variables @@ -18,13 +18,13 @@ pkgDir=$(/usr/bin/dirname $0) # Version that's being updated (this will be set by the build_SPSS.sh script) version= - majorVersion=$(/bin/echo $version | /usr/bin/awk -F "." '{print $1}') + majorVersion=$(echo $version | /usr/bin/awk -F "." '{print $1}') # Get the location of SPSSStatistics.app appPath=$(/usr/bin/find -E /Applications -iregex ".*[${majorVersion}].*[/](SPSS) ?(Statistics) ?(${majorVersion})?[.]app" -type d -prune) # Get the App Bundle name - appName=$(/bin/echo $appPath | /usr/bin/awk -F "/" '{print $NF}') + appName=$(echo "${appPath}" | /usr/bin/awk -F "/" '{print $NF}') # Get only the install path - installPath=$(/bin/echo $appPath | /usr/bin/awk -F "/$appName" '{print $1}') + installPath=$(echo "${appPath}" | /usr/bin/awk -F "/${appName}" '{print $1}') # Get the current SPSS version currentVersion=$(/usr/bin/defaults read "${appPath}/Contents/Info.plist" CFBundleShortVersionString) @@ -37,7 +37,7 @@ if [[ -z "${appPath}" ]]; then exit 1 fi -/bin/echo "Upgrading SPSS Version: ${currentVersion} at path: ${appPath}" +echo "Upgrading SPSS Version: ${currentVersion} at path: ${appPath}" # Inject the location to the installer.properties file LANG=C /usr/bin/sed -Ei '' 's,(#)?USER_INSTALL_DIR=.*,'"USER_INSTALL_DIR=${installPath}"',' "${pkgDir}/installer.properties" @@ -46,24 +46,24 @@ fi /bin/chmod +x "${pkgDir}/SPSS_Statistics_Installer_Mac_Patch.bin" # Silent upgrade using information in the installer.properties file -/bin/echo "Upgrading SPSS..." +echo "Upgrading SPSS..." exitStatus=$("${pkgDir}/SPSS_Statistics_Installer_Mac_Patch.bin" -f "${pkgDir}/installer.properties") exitCode=$? # Check for the expected exit code. if [[ "${exitCode}" != "208" ]]; then - /bin/echo "ERROR: Upgrade failed!" - /bin/echo "Exit Code: ${exitCode}" - /bin/echo "Exit Status: ${exitStatus}" - /bin/echo "***** Upgrade SPSS process: FAILED *****" + echo "ERROR: Upgrade failed!" + echo "Exit Code: ${exitCode}" + echo "Exit Status: ${exitStatus}" + echo "***** Upgrade SPSS process: FAILED *****" exit 2 elif [[ $(/usr/bin/defaults read "${appPath}/Contents/Info.plist" CFBundleShortVersionString) != "${version}" ]]; then - /bin/echo "Injecting the proper version string into SPSS's Info.plist" + echo "Injecting the proper version string into SPSS's Info.plist" # Inject the proper version into the Info.plist file -- this may not be required for every version; specifically for v24.0.0.2, it was needed /usr/bin/sed -Ei '' 's/'"${majorVersion}.0.0.[0-9]"'/'"${version}"'/g' "${appPath}/Contents/Info.plist" fi -/bin/echo "Upgrade complete!" -/bin/echo "***** Upgrade SPSS process: COMPLETE *****" +echo "Upgrade complete!" +echo "***** Upgrade SPSS process: COMPLETE *****" exit 0 diff --git a/Software/install_QGIS.sh b/Software/install_QGIS.sh index fb5a3fc..48485e2 100644 --- a/Software/install_QGIS.sh +++ b/Software/install_QGIS.sh @@ -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.4.1 / Updated: 3/30/2018 / By: ZT # # Description: This script installs all the packages that are contained in the QGIS dmg. # @@ -15,7 +15,7 @@ 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");') # Get the filename of the .dmg file @@ -44,8 +44,8 @@ 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 diff --git a/Software/license_Fetch.sh b/Software/license_Fetch.sh index 7adcf2b..176c73d 100644 --- a/Software/license_Fetch.sh +++ b/Software/license_Fetch.sh @@ -3,13 +3,13 @@ ################################################################################################### # Script Name: license_Fetch.sh # By: Zack Thompson / Created: 6/28/2017 -# Version: 1.1 / Updated: 2/16/2018 / By: ZT +# Version: 1.1.1 / Updated: 3/30/2018 / By: ZT # -# Description: This script will license Fetch with ASU's License. +# Description: This script will license Fetch. # ################################################################################################### -/bin/echo "***** license Fetch Process: START *****" +echo "***** license Fetch Process: START *****" ################################################## # Define Variables @@ -22,20 +22,20 @@ serialNumber="FETCH12345-6789-0123-4567-8910-1112" # Bits staged... if [[ ! -x $FetchApp ]]; then - /bin/echo "Error: Fetch is not properly installed." - /bin/echo "***** license Fetch Process: FAILED *****" + echo "Error: Fetch is not properly installed." + echo "***** license Fetch Process: FAILED *****" exit 1 else - /bin/echo "Applying the Fetch license..." + echo "Applying the Fetch license..." /usr/bin/defaults write $plist SerialNumber "$serialNumber" /usr/bin/defaults write $plist RegistrantName "$registrantName" if [[ -e $plist ]]; then - /bin/echo "Fetch has been licensed!" - /bin/echo "***** license Fetch Process: COMPLETE *****" + echo "Fetch has been licensed!" + echo "***** license Fetch Process: COMPLETE *****" else - /bin/echo "Error: License does not exist." - /bin/echo "***** license Fetch Process: FAILED *****" + echo "Error: License does not exist." + echo "***** license Fetch Process: FAILED *****" exit 2 fi fi diff --git a/Software/license_JMP.sh b/Software/license_JMP.sh index 039a96a..a3ceb03 100755 --- a/Software/license_JMP.sh +++ b/Software/license_JMP.sh @@ -3,13 +3,13 @@ ################################################################################################### # Script Name: license_JMP.sh # By: Zack Thompson / Created: 3/3/2017 -# Version: 2.1 / Updated: 1/17/2018 / By: ZT +# Version: 2.1.1 / Updated: 3/30/2018 / By: ZT # # Description: This script applies the license for JMP applications. # ################################################################################################### -/usr/bin/logger -s "***** License JMP process: START *****" +echo "***** License JMP process: START *****" ################################################## # Define Variables @@ -20,13 +20,13 @@ licenseFile="/Library/Application Support/JMP/13/JMP.per" # Get the install JMP.app edition (standard vs Pro) appPath=$(/usr/bin/find /Applications -iname "JMP*.app" -maxdepth 1 -type d) - /usr/bin/logger -s "Applying license for: ${appPath}" + echo "Applying license for: ${appPath}" ################################################## # Create the license file. # Assign the proper license per edition - /usr/bin/logger -s "Creating license file..." + echo "Creating license file..." if [[ $appPath == *"JMP 13.app"* ]]; then /bin/cat > "${licenseFile}" < /dev/null # Mark as 'registration requested' so it doesn't ask the user. @@ -87,7 +87,7 @@ fi # Set permissions on the plist file. /bin/chmod 644 "/Users/${currentUser}/Library/Application Support/JMP/13/License.plist" -/usr/bin/logger -s "JMP has been activated!" -/usr/bin/logger -s "***** License JMP process: COMPLETE *****" +echo "JMP has been activated!" +echo "***** License JMP process: COMPLETE *****" exit 0 \ No newline at end of file diff --git a/Software/license_Minitab.sh b/Software/license_Minitab.sh index 41a3b94..4b65742 100644 --- a/Software/license_Minitab.sh +++ b/Software/license_Minitab.sh @@ -3,13 +3,13 @@ ################################################################################################### # Script Name: license_Minitab.sh # By: Zack Thompson / Created: 3/6/2017 -# Version: 1.1 / Updated: 1/10/2018 / By: ZT +# Version: 1.1.1 / Updated: 3/30/2018 / By: ZT # # Description: This script applies the license for Minitab. # ################################################################################################### -/usr/bin/logger -s "***** License Minitab process: START *****" +echo "***** License Minitab process: START *****" ################################################## # Define Variables @@ -19,20 +19,20 @@ licenseFile="/Library/Application Support/Minitab/Minitab Express/mtblic.plist" ################################################## # Bits staged, license software... -/usr/bin/logger -s "Configuring the License Manager Server..." +echo "Configuring the License Manager Server..." /usr/bin/defaults write "${licenseFile}" "License File" @license.server.com if [[ -e "${licenseFile}" ]]; then # Set permissions on the file for everyone to be able to read. - /usr/bin/logger -s "Applying permissions to license file..." + echo "Applying permissions to license file..." /bin/chmod 644 "${licenseFile}" else - /usr/bin/logger -s "ERROR: Failed to create the license file!" - /usr/bin/logger -s "***** License Minitab process: FAILED *****" + echo "ERROR: Failed to create the license file!" + echo "***** License Minitab process: FAILED *****" exit 1 fi -/usr/bin/logger -s "Minitab has been activated!" -/usr/bin/logger -s "***** License Minitab process: COMPLETE *****" +echo "Minitab has been activated!" +echo "***** License Minitab process: COMPLETE *****" exit 0 diff --git a/Software/license_Parallels.sh b/Software/license_Parallels.sh index 26123c5..43ee50e 100644 --- a/Software/license_Parallels.sh +++ b/Software/license_Parallels.sh @@ -3,13 +3,13 @@ ################################################################################################### # Script Name: license_Parallels.sh # By: Zack Thompson / Created: 8/17/2017 -# Version: 1.5.1 / Updated: 1/23/2018 / By: ZT +# Version: 1.5.2 / Updated: 3/30/2018 / By: ZT # -# Description: This script will apply a Parallels License provided as a JSS Script Parameter. +# Description: This script will apply a Parallels License provided as a Script Parameter. # ################################################################################################### -/bin/echo "***** license_Parallels Process: START *****" +echo "***** license_Parallels Process: START *****" ################################################## # Define Variables @@ -22,18 +22,18 @@ serviceParallels="/Applications/Parallels Desktop.app/Contents/MacOS/Parallels S # First, check to make sure that the prlsrvctl binary exists and is executable. if [[ ! -x "${Parallels}" ]]; then - /bin/echo "Error: Parallels is not properly installed." - /bin/echo "***** license_Parallels Process: FAILED *****" + echo "Error: Parallels is not properly installed." + echo "***** license_Parallels Process: FAILED *****" exit 1 else # Second, check if the Parallels Service is running, if not, start it. if $(! $(/usr/bin/pgrep -xq prl_disp_service)); then - /bin/echo "The Parallels Service is not running -- Starting it now..." + echo "The Parallels Service is not running -- Starting it now..." "${serviceParallels}" & # If needed, waiting for the service to start... until [[ $(/usr/bin/pkill -0 -ix prl_disp_service -q 2>/dev/null) -eq 0 ]]; do - /bin/echo "Waiting for the Parallels Service to start..." + echo "Waiting for the Parallels Service to start..." /bin/sleep 1 done fi @@ -46,23 +46,23 @@ else # Fourth, if the current status is active, we'll need to deactivate it, before activating a new license. if [[ $status == "ACTIVE" ]]; then - /bin/echo "Machine currently has an active license." - /bin/echo "Deactivating old license..." + echo "Machine currently has an active license." + echo "Deactivating old license..." "${Parallels}" deactivate-license fi # Fifth, install new license. - /bin/echo "Applying the provided license..." + echo "Applying the provided license..." "${Parallels}" install-license --key "${licenseKey}" exitCode=$? # Sixth, check the result of installing the license. if [[ $exitCode = 0 ]]; then - /bin/echo "Parallels has been licensed!" - /bin/echo "***** license_Parallels Process: COMPLETE *****" + echo "Parallels has been licensed!" + echo "***** license_Parallels Process: COMPLETE *****" else - /bin/echo "Error: License was likely invalid." - /bin/echo "***** license_Parallels Process: FAILED *****" + echo "Error: License was likely invalid." + echo "***** license_Parallels Process: FAILED *****" exit 2 fi fi diff --git a/Software/license_VMwareFusion.sh b/Software/license_VMwareFusion.sh index e626a53..6b92d20 100644 --- a/Software/license_VMwareFusion.sh +++ b/Software/license_VMwareFusion.sh @@ -3,7 +3,7 @@ ################################################################################################### # Script Name: license_VMwareFusion.sh # By: Zack Thompson / Created: 12/14/2017 -# Version: 1.0.1 / Updated: 1/18/2018 / By: ZT +# Version: 1.0.2 / Updated: 3/30/2018 / By: ZT # # Description: This script will apply a VMware Fusion License provided as a JSS Script Parameter. # - Supports VMware Fusion 4.x and later. @@ -11,26 +11,26 @@ # ################################################################################################### -/bin/echo "***** license_VMwareFusion Process: START *****" +echo "***** license_VMwareFusion Process: START *****" # Define Variables FusionApp="/Applications/VMware Fusion.app" -if [[ ! -x $FusionApp ]]; then - /bin/echo "Error: VMware Fusion is not properly installed." - /bin/echo "***** license_VMwareFusion Process: FAILED *****" +if [[ ! -x "${FusionApp}" ]]; then + echo "Error: VMware Fusion is not properly installed." + echo "***** license_VMwareFusion Process: FAILED *****" exit 1 else - /bin/echo "Applying the VMware Fusion license..." + echo "Applying the VMware Fusion license..." "${FusionApp}/Contents/Library/Initialize VMware Fusion.tool" set "" "" $4 exitCode=$? if [[ $exitCode = 0 ]]; then - /bin/echo "VMware Fusion has been licensed!" - /bin/echo "***** license_VMwareFusion Process: COMPLETE *****" + echo "VMware Fusion has been licensed!" + echo "***** license_VMwareFusion Process: COMPLETE *****" else - /bin/echo "Error: License was likely invalid." - /bin/echo "***** license_VMwareFusion Process: FAILED *****" + echo "Error: License was likely invalid." + echo "***** license_VMwareFusion Process: FAILED *****" exit 2 fi fi diff --git a/Software/uninstall_AcrobatDC2015.sh b/Software/uninstall_AcrobatDC2015.sh index e21b634..60de667 100644 --- a/Software/uninstall_AcrobatDC2015.sh +++ b/Software/uninstall_AcrobatDC2015.sh @@ -3,21 +3,21 @@ ################################################################################################### # Script Name: uninstall_AcrobatDC2015.sh # By: Zack Thompson / Created: 6/30/2017 -# Version: 1.0 / Updated: 6/30/2017 / By: ZT +# Version: 1.0.1 / Updated: 3/30/2017 / By: ZT # # Description: This script uninstalls Acrobat DC v2015. # ################################################################################################### # Call the built-in uninstall mechanism if the application is currently installed. -/bin/echo "Checking if Acrobat DC v2015 is currently installed..." +echo "Checking if Acrobat DC v2015 is currently installed..." if [[ -e "/Applications/Adobe Acrobat DC/Adobe Acrobat.app" ]]; then - /bin/echo "Uninstalling Acrobat DC v2015..." + echo "Uninstalling Acrobat DC v2015..." "/Applications/Adobe Acrobat DC/Adobe Acrobat.app/Contents/Helpers/Acrobat Uninstaller.app/Contents/MacOS/RemoverTool" "/Applications/Adobe Acrobat DC/Adobe Acrobat.app/Contents/Helpers/Acrobat Uninstaller.app/Contents/MacOS/RemoverTool" "/Applications/Adobe Acrobat DC/Adobe Acrobat.app" - /bin/echo "Uninstall Complete!" + echo "Uninstall Complete!" else - /bin/echo "Acrobat DC v2015 is not installed." + echo "Acrobat DC v2015 is not installed." fi exit 0 \ No newline at end of file diff --git a/Software/uninstall_AcrobatPro2017.sh b/Software/uninstall_AcrobatPro2017.sh index 389f843..8f84a2a 100644 --- a/Software/uninstall_AcrobatPro2017.sh +++ b/Software/uninstall_AcrobatPro2017.sh @@ -3,21 +3,21 @@ ################################################################################################### # Script Name: uninstall_AcrobatPro2017.sh # By: Zack Thompson / Created: 6/30/2017 -# Version: 1.0 / Updated: 6/30/2017 / By: ZT +# Version: 1.0.1 / Updated: 3/30/2017 / By: ZT # # Description: This script uninstalls Acrobat Pro v2017. # ################################################################################################### # Call the built-in uninstall mechanism if the application is currently installed. -/bin/echo "Checking if Acrobat Pro v2017 is currently installed..." +echo "Checking if Acrobat Pro v2017 is currently installed..." if [[ -e "/Applications/Adobe Acrobat 2017/Adobe Acrobat.app" ]]; then - /bin/echo "Uninstalling Acrobat Pro v2017..." + echo "Uninstalling Acrobat Pro v2017..." "/Applications/Adobe Acrobat 2017/Adobe Acrobat.app/Contents/Helpers/Acrobat Uninstaller.app/Contents/MacOS/RemoverTool" "/Applications/Adobe Acrobat 2017/Adobe Acrobat.app/Contents/Helpers/Acrobat Uninstaller.app/Contents/MacOS/RemoverTool" "/Applications/Adobe Acrobat 2017/Adobe Acrobat.app" - /bin/echo "Uninstall Complete!" + echo "Uninstall Complete!" else - /bin/echo "Acrobat Pro v2017 is not installed." + echo "Acrobat Pro v2017 is not installed." fi exit 0 From 27b6d58567688b45869edb3d4979c85e08c8f59b Mon Sep 17 00:00:00 2001 From: Zack T Date: Thu, 5 Apr 2018 11:17:44 -0700 Subject: [PATCH 7/7] v0.3 = Change the Location Logic + Change how to specify the location logic -- original concept was not possible --- System Configs/create_Shortcut.sh | 69 +++++++++++++++++-------------- 1 file changed, 38 insertions(+), 31 deletions(-) diff --git a/System Configs/create_Shortcut.sh b/System Configs/create_Shortcut.sh index 00e89d5..847f07e 100644 --- a/System Configs/create_Shortcut.sh +++ b/System Configs/create_Shortcut.sh @@ -3,7 +3,7 @@ ################################################################################################### # Script Name: create_Shortcut.sh # By: Zack Thompson / Created: 3/26/2018 -# Version: 0.2 / Updated: 3/27/2018 / By: ZT +# Version: 0.3 / Updated: 4/5/2018 / By: ZT # # Description: This script will create a website shortcut in a specified location with a specified icon. # @@ -28,7 +28,7 @@ echo "***** Create Shortcut process: START *****" getHelp() { echo " -usage: jamf_CreateShortcut.sh +usage: jamf_CreateShortcut.sh [ Dock | Desktop] Info: This script will create a website shortcut in a specified location with a specified icon. @@ -83,40 +83,47 @@ echo "Adding the requested icon..." /usr/bin/python -c "import Cocoa; import sys; Cocoa.NSWorkspace.sharedWorkspace().setIcon_forFile_options_(Cocoa.NSImage.alloc().initWithContentsOfFile_(sys.argv[1].decode('utf-8')), sys.argv[2].decode('utf-8'), 0) or sys.exit(\"Unable to set file icon\")" "${icon}" "${defaultLocation}/${fileName}.url" # Check where to place the file. -if [[ "${location}" == "Dock" ]]; then +case "${location}" in + Dock ) + # Setting a variable that holds whether the Dock item already exists or not (if it does, we don't want to unnecessarily edit and kill the Dock). + alreadyExists=0 - # Setting a variable that holds whether the Dock item already exists or not (if it does, we don't want to unnecessarily edit and kill the Dock). - alreadyExists=0 + # Get the number of items in the persistent-others node; then subtract one for Array value notation. + indexItem=$(/usr/libexec/PlistBuddy -x -c "Print :persistent-others" "/Users/${currentUser}/Library/Preferences/com.apple.dock.plist" | /usr/bin/xmllint --format - | /usr/bin/xpath 'count(//plist/array/dict)' 2>/dev/null) + indexItem=$((indexItem-1)) - # Get the number of items in the persistent-others node; then subtract one for Array value notation. - indexItem=$(/usr/libexec/PlistBuddy -x -c "Print :persistent-others" "/Users/${currentUser}/Library/Preferences/com.apple.dock.plist" | /usr/bin/xmllint --format - | /usr/bin/xpath 'count(//plist/array/dict)' 2>/dev/null) - indexItem=$((indexItem-1)) + # Loop through all the items in the persistent-others node and compare to the new item being added. + for ((i=1; i<=$indexItem; ++i)); do + indexLabel=$(/usr/libexec/PlistBuddy -c "Print :persistent-others:${i}:tile-data:file-label" "/Users/${currentUser}/Library/Preferences/com.apple.dock.plist") + indexData=$(/usr/libexec/PlistBuddy -c "Print :persistent-others:${i}:tile-data:file-data:_CFURLString" "/Users/${currentUser}/Library/Preferences/com.apple.dock.plist") - # Loop through all the items in the persistent-others node and compare to the new item being added. - for ((i=1; i<=$indexItem; ++i)); do - indexLabel=$(/usr/libexec/PlistBuddy -c "Print :persistent-others:${i}:tile-data:file-label" "/Users/${currentUser}/Library/Preferences/com.apple.dock.plist") - indexData=$(/usr/libexec/PlistBuddy -c "Print :persistent-others:${i}:tile-data:file-data:_CFURLString" "/Users/${currentUser}/Library/Preferences/com.apple.dock.plist") + # Check if the current indexItem values equal the new items' values. + if [[ "${indexLabel}" == "${fileName}" && "${indexData}" == "file://${defaultLocation}/${fileName}.url" ]]; then + alreadyExists=1 + echo "Already exists!" + fi + done - # Check if the current indexItem values equal the new items' values. - if [[ "${indexLabel}" == "${fileName}" && "${indexData}" == "file://${defaultLocation}/${fileName}.url" ]]; then - alreadyExists=1 - echo "Already exists!" + # If the new item does not already exist, add it to the Dock. + if [[ $alreadyExists == 0 ]]; then + echo "Adding to the dock..." + fileNameLocation=$(echo "${fileName}" | /usr/bin/sed 's/ /%20/g') + /usr/bin/sudo -s -u "${currentUser}" /usr/bin/defaults write "/Users/${currentUser}/Library/Preferences/com.apple.dock" persistent-others -array-add "tile-datafile-data_CFURLStringfile://${defaultLocation}/${fileNameLocation}.url_CFURLStringType15file-label${fileName}file-type32tile-typefile-tile" + /usr/bin/killall Dock fi - done - - # If the new item does not already exist, add it to the Dock. - if [[ $alreadyExists == 0 ]]; then - echo "Adding to the dock..." - fileNameLocation=$(echo "${fileName}" | /usr/bin/sed 's/ /%20/g') - /usr/bin/sudo -s -u "${currentUser}" /usr/bin/defaults write "/Users/${currentUser}/Library/Preferences/com.apple.dock" persistent-others -array-add "tile-datafile-data_CFURLStringfile://${defaultLocation}/${fileNameLocation}.url_CFURLStringType15file-label${fileName}file-type32tile-typefile-tile" - /usr/bin/killall Dock - fi - -else - # Move file to the specified location if not adding to the Dock. - echo "Moving file in place..." - /bin/mv "${defaultLocation}/${fileName}.url" "${location}" -fi + ;; + Desktop ) + # Move file to the specified location if not adding to the Dock. + echo "Moving file in place..." + /bin/mv "${defaultLocation}/${fileName}.url" "/Users/${currentUser}/Desktop" + ;; + * ) + echo "ERROR: The specified location is not configurable at this time." + # Function getHelp + getHelp + echo "***** Create Shortcut process: FAILED *****" + ;; +esac echo "***** Create Shortcut process: COMPLETE *****" exit 0 \ No newline at end of file