v0.3 = Change the Location Logic

+ Change how to specify the location logic -- original concept was not possible
This commit is contained in:
Zack T
2018-04-05 11:17:44 -07:00
parent 1bda43f7e7
commit 27b6d58567

View File

@@ -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 <filename> <URL> <icon> <location>
usage: jamf_CreateShortcut.sh <filename> <URL> <icon> [<location> Dock | Desktop]
Info: This script will create a website shortcut in a specified location with a specified icon.
@@ -83,8 +83,8 @@ 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
@@ -111,12 +111,19 @@ if [[ "${location}" == "Dock" ]]; then
/usr/bin/sudo -s -u "${currentUser}" /usr/bin/defaults write "/Users/${currentUser}/Library/Preferences/com.apple.dock" persistent-others -array-add "<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>file://${defaultLocation}/${fileNameLocation}.url</string><key>_CFURLStringType</key><integer>15</integer></dict><key>file-label</key><string>${fileName}</string><key>file-type</key><integer>32</integer></dict><key>tile-type</key><string>file-tile</string></dict>"
/usr/bin/killall Dock
fi
else
;;
Desktop )
# Move file to the specified location if not adding to the Dock.
echo "Moving file in place..."
/bin/mv "${defaultLocation}/${fileName}.url" "${location}"
fi
/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