Posted on 03-03-2016 12:45 PM
So we don't give users admin for obvious reasons and Sketch comes out with updates almost weekly at this point.
The problem is their files are only compatible with the version they were made in.
I haven't worked autopkg into my workflow yet (I know!) so I wrote this today
Self service update script is as follows
if test -d "/Applications/Utilities/IT/sketch-updates/"
then rm -Rf "/Applications/Utilities/IT/sketch-updates/" | mkdir -p "/Applications/Utilities/IT/sketch-updates/" ;
else mkdir -p "/Applications/Utilities/IT/sketch-updates/"
fi;
cd "/Applications/Utilities/IT/sketch-updates/"
sudo curl -O http://download.sketchapp.com/sketch.zip /Applications/Utilities/IT/sketch-updates/sketch.zip;
sudo unzip sketch.zip;
if test -d "/Applications/Sketch.app"
then sudo rm -R "/Applications/Sketch.app" ;
fi;
sudo mv "/Applications/Utilities/IT/sketch-updates/Sketch.app" "/Applications/Sketch.app"
Posted on 04-22-2016 01:54 PM
Thanks for this!
We don't give our users admin either...how are you currently licensing the app in deployment? As far as I can tell there's a unique .license file tied to the registered computer.
We have a multi license serial but can't seem to apply it except manually typing it in. Any insights?
Posted on 06-23-2016 07:19 AM
how are you currently licensing the app in deployment? As far as I can tell there's a unique .license file tied to the registered computer.
Came here for same question. Any insights @jrepasky ? Or have you had any luck @kpowerbook
Posted on 06-23-2016 07:24 AM
I reached out to Sketch's support team for answer.
You just need to create a text file (make sure to use plain text) containing the serial key and save it as ".deployment" in one of the following directories: /Library/Application Support/com.bohemiancoding.sketch3/.deployment - for all users ~/Library/Application Support/com.bohemiancoding.sketch3/.deployment - for a specific user
Posted on 06-23-2016 11:34 AM
Awesome! Thanks @kpowerbook !
Posted on 08-15-2016 03:15 PM
@kpowerbook Have you been able to get this to work?
I've tried dropping the .deployment file in both locations but it doesn't seem to do anything...
Were there any other criteria?
Posted on 08-16-2016 06:23 AM
@travis.gingrich You're probably running into the same issue we did: Sketch checks for a manually installed license before it checks for the .deployment one. If a user has installed/launched Sketch prior to installing your copy with the .deployment serial, it ignores this file. What you need to do is remove:
/Users/$username/Library/Application Support/com.bohemiancoding.sketch3/.license
Then at next launch Sketch will see your .deployment file.
Posted on 08-17-2016 08:33 AM
what i did was to use self service to launch sketch as root and guide user to perform the update and install. after downloading and installation the software will close off and relaunch as user with updated version. license and every still intact.
understand this not the best way but you may wish to add a script with time to kill off the task if it takes too long incase user initial any other stuff using the root launch sketch.
Posted on 09-26-2016 07:00 PM
Modified the script slightly just to make it easier to read and only use for updating rather than deployment, but I'm having some issues
if [ -d "/tmp/IT/sketch-updates/" ]
then
sudo rm -Rf "/tmp/IT/sketch-updates/" | sudo mkdir -p "/tmp/IT/sketch-updates/"
else
sudo mkdir -p "/tmp/IT/sketch-updates/"
fi
cd "/tmp/IT/sketch-updates/"
sudo curl -L -O "http://download.sketchapp.com/sketch.zip"
sudo unzip "/tmp/IT/sketch-updates/sketch.zip"
sudo rm -R "/Applications/Sketch.app"
sudo mv "/tmp/IT/sketch-updates/Sketch.app" "/Applications/Sketch.app"
If I run the commands locally, everything seems to work as it should... but if I run through Self-Service, it errors out. Result from log:
[STEP 1 of 4]
Executing Policy Sketch
[STEP 2 of 4]
Running script Update Sketch...
Script exit code: 1
Script result: /Library/Application Support/JAMF/tmp/Update Sketch: line 12: cd: /tmp/IT/sketch-updates/: No such file or directory
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
18 21.2M 18 3935k 0 0 3585k 0 0:00:06 0:00:01 0:00:05 3585k
100 21.2M 100 21.2M 0 0 10.4M 0 0:00:02 0:00:02 --:--:-- 18.4M
unzip: cannot find or open /tmp/IT/sketch-updates/sketch.zip, /tmp/IT/sketch-updates/sketch.zip.zip or /tmp/IT/sketch-updates/sketch.zip.ZIP.
mv: rename /tmp/IT/sketch-updates/Sketch.app to /Applications/Sketch.app: No such file or directory
Error running script: return code was 1.
[STEP 3 of 4]
[STEP 4 of 4]
Seems like things are running out of order or it's skipping some commands, but I can't tell why. Any guidance on how to help troubleshoot when if I run the commands in a terminal everything seems to run as it should?
Posted on 10-25-2016 01:22 AM
Hi mrory i'm using this script to update sketch via the self service. Works perfect.
#!/bin/bash
function InstallSketch () {
# download and install the latest version
until [[ -d '/Applications/Sketch.app' ]]; do
if [[ -e /tmp/sketch.zip ]]; then
rm -rf /tmp/sketch.zip
fi
if [[ -d /tmp/__MACOSX ]]; then
rm -rf /tmp/__MACOSX/
fi
if [[ -d /tmp/Sketch.app ]]; then
rm -rf /tmp/Sketch.app
fi
echo "`date` Downloading Sketch"
curl -L -o /tmp/sketch.zip "http://download.sketchapp.com/sketch.zip" >/dev/null 2>&1
echo "`date` Download complete"
cd /tmp/
echo "`date` Unzipping archive"
unzip sketch.zip >/dev/null 2>&1
echo "`date` Archive unizpped"
echo "`date` Moving Sketch.app to the Applications directory"
mv Sketch.app /Applications
echo "`date` Editing permissions"
chown -R root:wheel /Applications/Sketch.app
chmod -R 755 /Applications/Sketch.app
cd ~
echo "`date` Removing temporary files"
rm -rf /tmp/sketch.zip && rm -rf /tmp/__MACOSX && rm -rf /tmp/Sketch.app
done
}
function RemoveSketch () {
# Remove and all related files if sketch if installed
echo "`date` Removing Sketch.app"
if [[ -d '/Applications/Sketch.app' ]]; then
until [[ ! -d '/Applications/Sketch.app' ]]; do
rm -rf /Applications/Sketch.app
done
echo "`date` Sketch.app was removed"
echo "`date` Begining installation of sketch3"
InstallSketch
fi
}
function DetectSketch () {
# Check to see whether Sketch is installed or not, if yes, remove it, then install latest, if no, then install latest.
pgrep Sketch >/dev/null
if [[ $? = 0 ]]; then
pkill Sketch
fi
echo "`date` ========== Installation Started =========="
echo "`date` Detecting if Sketch is installed or not"
if [[ -d '/Applications/Sketch.app' ]]; then
echo "`date` Sketch was detected, will remove"
RemoveSketch
else
echo "`date` Sketch was not detected, will install"
InstallSketch
fi
}
function LogSketch () {
# Setup log files if logs do not exists, create it, otherwise start logging
LogFile="/Library/Logs/sketch3_install.log"
if [[ ! -e $LogFile ]]; then
touch $LogFile && exec >> $LogFile
echo "`date` ========== Log File Created =========="
else
exec >> $LogFile
fi
}
LogSketch
DetectSketch
exit 0
Posted on 04-25-2017 04:34 AM
@dwils Could have at least cited where you got the script from.
Posted on 01-08-2019 06:15 PM
Thanks @kpowerbook & @cdev! It works perfectly!
Posted on 12-13-2019 08:01 AM
@dwils Thanks! that worked perfectly
Posted on 05-27-2020 07:32 AM
This still works great, thanks jrepasky and dwils
Posted on 09-01-2020 05:11 AM
This works great @dwils
Posted on 12-18-2020 01:43 PM
curl -L -o "http://download.sketchapp.com/sketch.zip"
Anyone else seeing issues with this zip file post download?
Posted on 09-27-2022 01:45 AM
Hi,
This script just broke down and it looks like the download link:
http://download.sketchapp.com/sketch.zip
The download link is unreachable at the moment.
Anyone else having these issues? If so, any solutions found?
Posted on 11-10-2022 10:16 AM
see my post below
Posted on 11-10-2022 10:15 AM
the URL changed. It is now this: