Sketch Application - So many updates so quickly

jrepasky
New Contributor III

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

!/bin/sh

Update Sketch Application - Created by Justin Repasky 03-03-2016 ####

Remove any older versions of sketch-updates folder and re-create

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"

18 REPLIES 18

kpowerbook
New Contributor II

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?

travis_gingrich
New Contributor
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

kpowerbook
New Contributor II

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

travis_gingrich
New Contributor

Awesome! Thanks @kpowerbook !

travis_gingrich
New Contributor

@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?

cdev
Contributor III

@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.

victorco
New Contributor

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.

mrory
New Contributor

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?

dwils
New Contributor

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

greatkemo
Contributor II

@dwils Could have at least cited where you got the script from.

oklair
New Contributor III

Thanks @kpowerbook & @cdev! It works perfectly!

uiqbaljamf
New Contributor II

@dwils Thanks! that worked perfectly

aarron_tilley
New Contributor II

This still works great, thanks jrepasky and dwils

RAW-ONLY
New Contributor

This works great @dwils

joemitchell
New Contributor
curl -L -o "http://download.sketchapp.com/sketch.zip"

Anyone else seeing issues with this zip file post download?

Joostvantwout
New Contributor III

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?

see my post below 

fballer987
New Contributor II

the URL changed. It is now this:

https://download.sketch.com/sketch.zip