Pushing Sketch registration

brad_dunn
Release Candidate Programs Tester

I've packaged Sketch so that we can push out. Is there a way to automate the registration? I haven't been able to fund anything on this to date.

2 ACCEPTED SOLUTIONS

Look
Valued Contributor III

I contacted the vendor directly and this is their instructions.
You just need to create a hidden text file containing the appropriate serial key.
/Library/Application Support/com.bohemiancoding.sketch3/.deployment - for all users
~/Library/Application Support/com.bohemiancoding.sketch3/.deployment - for a specific user

View solution in original post

ThijsX
Valued Contributor
Valued Contributor

@brad.dunn Hi,

We use beneath script as postinstall in an package, it downloads the newest versions, installs it and register itself.

#!/bin/bash function ConfigureSkecth () { echo "date Adding preferences for all users" defaults write /Library/Preferences/com.bohemiancoding.sketch3.plist SUEnableAutomaticChecks -bool NO defaults write /Library/Preferences/com.bohemiancoding.sketch3.plist SUAutomaticallyUpdate -bool NO defaults write /Library/Preferences/com.bohemiancoding.sketch3.plist SUHasLaunchedBefore -bool YES defaults write /Library/Preferences/com.bohemiancoding.sketch3.plist hasShown23Welcome -bool YES echo "date All preferences are now added" echo "date Installation is now complete" echo "date ========== Installation Ended ==========" } function SerializeSketch () { # add serial number for current and all future users CurrentUsers=sudo -u $(ls -l /dev/console | awk {'print $3'}) ls /Users/ | tr ' ' ' ' LicenseKey="PUT YOUR SERIAL HERE" echo "date Adding license key for current users" if [[ -e /Library/Application Support/com.bohemiancoding.sketch3 ]]; then rm -rf /Library/Application Support/com.bohemiancoding.sketch3 mkdir -p /Library/Application Support/com.bohemiancoding.sketch3 touch /Library/Application Support/com.bohemiancoding.sketch3/.deployment echo "$LicenseKey" > /Library/Application Support/com.bohemiancoding.sketch3/.deployment else mkdir -p /Library/Application Support/com.bohemiancoding.sketch3 touch /Library/Application Support/com.bohemiancoding.sketch3/.deployment echo "$LicenseKey" > /Library/Application Support/com.bohemiancoding.sketch3/.deployment fi echo "date All license keys are now added" echo "date Starting Configuration" ConfigureSkecth } 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 echo "date App Installed" echo "date Starting Serialization" SerializeSketch } 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 Removing related files" for dir in Users private System; do find /$dir -name "bohemiancoding*" -exec rm -rf {} ; >/dev/null 2>&1 done echo "date All related files were 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 Cheers, Thijs - bol.com

View solution in original post

38 REPLIES 38

Look
Valued Contributor III

I contacted the vendor directly and this is their instructions.
You just need to create a hidden text file containing the appropriate serial key.
/Library/Application Support/com.bohemiancoding.sketch3/.deployment - for all users
~/Library/Application Support/com.bohemiancoding.sketch3/.deployment - for a specific user

Bernard_Huang
Contributor III

Hi @Look

Could you elaborate on that?

For the all users /Library/Application Support/com.bohemiancoding.sketch3/.deployment , is there some sort of volume license key we need to supply?

ThijsX
Valued Contributor
Valued Contributor

@brad.dunn Hi,

We use beneath script as postinstall in an package, it downloads the newest versions, installs it and register itself.

#!/bin/bash function ConfigureSkecth () { echo "date Adding preferences for all users" defaults write /Library/Preferences/com.bohemiancoding.sketch3.plist SUEnableAutomaticChecks -bool NO defaults write /Library/Preferences/com.bohemiancoding.sketch3.plist SUAutomaticallyUpdate -bool NO defaults write /Library/Preferences/com.bohemiancoding.sketch3.plist SUHasLaunchedBefore -bool YES defaults write /Library/Preferences/com.bohemiancoding.sketch3.plist hasShown23Welcome -bool YES echo "date All preferences are now added" echo "date Installation is now complete" echo "date ========== Installation Ended ==========" } function SerializeSketch () { # add serial number for current and all future users CurrentUsers=sudo -u $(ls -l /dev/console | awk {'print $3'}) ls /Users/ | tr ' ' ' ' LicenseKey="PUT YOUR SERIAL HERE" echo "date Adding license key for current users" if [[ -e /Library/Application Support/com.bohemiancoding.sketch3 ]]; then rm -rf /Library/Application Support/com.bohemiancoding.sketch3 mkdir -p /Library/Application Support/com.bohemiancoding.sketch3 touch /Library/Application Support/com.bohemiancoding.sketch3/.deployment echo "$LicenseKey" > /Library/Application Support/com.bohemiancoding.sketch3/.deployment else mkdir -p /Library/Application Support/com.bohemiancoding.sketch3 touch /Library/Application Support/com.bohemiancoding.sketch3/.deployment echo "$LicenseKey" > /Library/Application Support/com.bohemiancoding.sketch3/.deployment fi echo "date All license keys are now added" echo "date Starting Configuration" ConfigureSkecth } 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 echo "date App Installed" echo "date Starting Serialization" SerializeSketch } 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 Removing related files" for dir in Users private System; do find /$dir -name "bohemiancoding*" -exec rm -rf {} ; >/dev/null 2>&1 done echo "date All related files were 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 Cheers, Thijs - bol.com

I know I'm a little late on this but I can't get this to run at all. I'm a bit new to Bash and it seems like a formatting issue but i'm not sure how to format this properly. Anyone have a version of this script that is properly formated?

YoshiiZee
New Contributor II

@txhaflaire Thank you, Thank you! That post install script works without a hitch.

caboundeh
New Contributor II

From Sketch support: Create a text file with your license key and name it .deployment and place it here:

/Library/Application Support/com.bohemiancoding.sketch3/ - for all users

~/Library/Application Support/com.bohemiancoding.sketch3/ - for a specific user

It should be a plain text file with no .txt extension. (so no RTF format eg).

The content of the file should be your license key, the one starting with SK3XX.

brad_dunn
Release Candidate Programs Tester

Thanks @txhaflaire

Quick question though... After installing, Sketch - About & Registration stills shows as Free Trial. Does Sketch only try to register itself after the trial period has ended?

ThijsX
Valued Contributor
Valued Contributor

@brad.dunn Hi, Are you sure you entered correctly the serial in the post-install script? and still have enough seats available under your license?

Cheers,
Thijs - bol.com

junderwood
New Contributor III

This script is great! Thanks! How about the reverse, though? Does anyone have a good method for unregistering sketch licenses from inactive users and/or machines removed from JSS?

Look
Valued Contributor III

@junderwood If it's just creating the license file as referenced by myself and @caboundeh I imagine you could just create a simple script to find and remove those files.
Even something as simple as

#!/bin/bash
if [ -f /Library/Application Support/com.bohemiancoding.sketch3/.deployment ]; then
rm /Library/Application Support/com.bohemiancoding.sketch3/.deployment
fi

Should do it.

cdev
Contributor III

@junderwood if you're referring to unlinking the computers from the Sketch license manager, to my knowledge there's no exposed API to interact there and automatically free the license.

@brad.dunn Sketch has to phone-home to validate the license key every couple of weeks (can't remember if it's 21 or 30 days) and when the license key is first installed. If it cannot communicate, it appears as a trial. I know I had to make a proxy change to allow the traffic through. My short-term fix was having users connect to an external network, launch the app, then switch back.

isterling_goaaa
New Contributor III

@txhaflaire If I want to push out the unregistered version of Sketch using your script, would I be able to do it without the

function SerializeSketch ()

section included? At this point, my group doesn't provide serial numbers for Sketch; we let the department managers do that. I've noticed that when I created the package using Composer, the extended attributes aren't passed on and the app just crashes without so much as an "ohai!" to warn the user what's going on. Your script would make it much easier for me to deploy the Application via self service.

ThijsX
Valued Contributor
Valued Contributor

Hi @isterling.goaaa

Why not using the default DMG/PKG for deploying via Self Service?

isterling_goaaa
New Contributor III

@txhaflaire Sketch comes as a .app inside a zipfile. I packaged it up using Composer. Once it deploys and the user tries to run it, it just crashes without putting anything in the logs (that I can find). I packaged up a previous release the same way, but this new release doesn't seem to want to run after packaging.

ThijsX
Valued Contributor
Valued Contributor

@isterling.goaaa Hmm clear. try using https://macapps.link/en just put below in terminal, or in a policy payload, or in a package with postinstall script

curl -s 'https://macapps.link/en/sketch' | sh

Not my preferred way, it does its thing and may help you out.

isterling_goaaa
New Contributor III

Thank you sir!

ThijsX
Valued Contributor
Valued Contributor

@isterling.goaaa No problem, if it itches what the issue is with composer, you can try to check the permissions you create the package with.
If the package is composed with your user permissions, at which the end the end user is not able to open the application/required files.

isterling_goaaa
New Contributor III

I made sure that the app was 755, and that the owner was root:wheel. We do have macadmin:staff as well, which I'll try using next time I'm in Composer.

ThijsX
Valued Contributor
Valued Contributor

Hmm, creating the app on APFS machine , end user on HFS+? Or vice versa

isterling_goaaa
New Contributor III

Both machines were 10.13.6, APFS.

summoner2100
Contributor

Haven't tried an APFS install yet, and I don't use the function a lot now, but Composers snapshot does pretty well for capturing Sketch in a DMG and deploying to fill user profiles.

But I may look into that bash script posted above. That looks interesting.

nberanger
Contributor

@txhaflaire Thanks for the script. I am running into a problem with this line though:

CurrentUsers=sudo -u $(ls -l /dev/console | awk {'print $3'}) ls /Users/ | tr ' ' ' '

It tells me '-bash: -u: command not found'.

ThijsX
Valued Contributor
Valued Contributor

@nberanger How are you running the script?

nberanger
Contributor

I've tried running it both as part of a policy, and just locally. If I remove that line it seems to function fine though.

dsidick
New Contributor

This works great. put your serial number in place of “SK3-XXXX”, make sure yopu remove the "".

If you open the Terminal application, the following 3 commands should be able to help you getting the job done:

  1. sudo bash
  2. mkdir /Library/Application Support/com.bohemiancoding.sketch3
  3. echo “SK3-XXXX” > /Library/Application Support/com.bohemiancoding.sketch3/.deployment

RaGL
New Contributor III

.

iVoidWarrantiez
New Contributor III

I am providing my script I use to license Sketch for all users. It does what is posted above by creating a hidden text file with your serial key in it. Replace the X's with your serial key.

#!/bin/sh

# make application support dir for Sketch
mkdir /Library/Application Support/com.bohemiancoding.sketch3

# create empty, hidden license file
touch /Library/Application Support/com.bohemiancoding.sketch3/.deployment

# echo info into license file
echo "XXX-XXXX-XXXX-XXXX-XXXX-XXXX" > /Library/Application Support/com.bohemiancoding.sketch3/.deployment

# correct any permissions issues
chmod -R 755 /Library/Application Support/com.bohemiancoding.sketch3

plauer
New Contributor II

!/bin/sh

make application support dir for Sketch

mkdir /Library/Application Support/com.bohemiancoding.sketch3

create empty, hidden license file

touch /Library/Application Support/com.bohemiancoding.sketch3/.deployment

echo info into license file

echo "SK3-8799-6840-5835-0391-0016" > /Library/Application Support/com.bohemiancoding.sketch3/.deployment

correct any permissions issues

chmod -R 755 /Library/Application Support/com.bohemiancoding.sketch3

I tried the above by iVoidWarrantiez with version 66.1 of Sketch and it did not work. Everything landed where it was supposed to but the app was not serialized when opened. Suggestions?

donmontalvo
Esteemed Contributor III

Is the touch needed? Seems like the > bit takes care of creating the file.

--
https://donmontalvo.com

summoner2100
Contributor

@plauer If that's your Sketch license, you may want to edit emove it. ;)

mani2care
Contributor

want to know wether the app ls licenced or not via extension attriboot

AtillaTheC
Contributor II

This worked for me in placing the deployment file but its not set as a hidden file, it saves as an executable, any ideas?

 

 

#!/bin/sh

# make application support dir for Sketch
mkdir ~/Library/Application\ Support/com.bohemiancoding.sketch3

# create empty, hidden license file
touch ~/Library/Application\ Support/com.bohemiancoding.sketch3/.deployment

# echo info into license file
echo "SK3-xxxxxxxx" > ~/Library/Application\ Support/com.bohemiancoding.sketch3/.deployment

# correct any permissions issues
chmod -R 755 ~/Library/Application\ Support/com.bohemiancoding.sketch3

 

@AtillaTheCYou can try using chflags to change it to hidden. Adding  the . in front of the file should make it hidden already.

Also I saw you are pointing to  ~/path/to/file, the users directory. This will only work for the user running the script. If you are running this script with the trigger login and execution frequency set to ongoing you will be fine.

Try chflags hidden /path/to/file

About the file being an executable, does it still work? Does it license Sketch?

Best of luck.

Reason I'm doing the ~ is because its running via self service and it was the only way to get it to execute that way. It's not working as an executable 

I ended up just creating a separate dmg and policy for the license and running it via a custom trigger to the install package. Working so far and when I need to update the PKG in the future I won't need to mess with the licensing portion. 

If running from self service, it will run as root. So it will go in the root users library folder.  Any reason you don't just put it in system library for all users? That's what I do. 

This works for me doing our deploys. Pieced together from different parts, and has a couple of checks in place if file is there. It needs a little bit of cleanup, but I'm lazy if the script is working for me haha. Just put your serial where the x's are. There are echo statements through it so when you look at the Jamf policy log, you can see steps a little more easier about what it's doing. 

But as I mentioned in my comment previous, I place it in the /Library folder not the user library. Ignore the comments about users at the end, it goes in /Library so every one has it. Also adds the options for not checking for updates. So I can re-deploy when I* know there's one, not when users ask haha

 

#!/bin/bash
## Installs Sketch by downloading in direct from the Sketch website and then applying the license
#Created by Andrew Purvis v1.0
##################################################################################################

LicenseKey="SK3-xxxx-xxxx-xxxx-xxxx-xxxx" 

 #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 

 		#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" 
        rm -rf /Applications/Sketch.app
        find /$dir -name "bohemiancoding*" -exec rm -rf {} \; >/dev/null 2>&1
fi
 #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/
        #if [[ -d /tmp/Sketch.app ]]; 
        #then
            #rm -rf /tmp/Sketch.app
        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
    echo "date App Installed"
    echo "date Starting Serialization"

#add serial number for current and all future users 


	echo "date Adding license key for current users"
 if [[ -e /Library/Application\ Support/com.bohemiancoding.sketch3 ]]; then 
 	rm -rf /Library/Application\ Support/com.bohemiancoding.sketch3 
 	mkdir -p /Library/Application\ Support/com.bohemiancoding.sketch3 
 	touch /Library/Application\ Support/com.bohemiancoding.sketch3/.deployment 
 	echo "$LicenseKey" > /Library/Application\ Support/com.bohemiancoding.sketch3/.deployment 
 else 
 	mkdir -p /Library/Application\ Support/com.bohemiancoding.sketch3 
 	touch /Library/Application\ Support/com.bohemiancoding.sketch3/.deployment 
 	echo "$LicenseKey" > /Library/Application\ Support/com.bohemiancoding.sketch3/.deployment fi 
 	echo "date All license keys are now added" 
 	echo "date Starting Configuration" 
fi
#Disable Auto Update Checks
	echo "date Adding preferences for all users" 
	defaults write /Library/Preferences/com.bohemiancoding.sketch3.plist SUEnableAutomaticChecks -bool NO 
	defaults write /Library/Preferences/com.bohemiancoding.sketch3.plist SUAutomaticallyUpdate -bool NO 
	defaults write /Library/Preferences/com.bohemiancoding.sketch3.plist SUHasLaunchedBefore -bool YES 
	defaults write /Library/Preferences/com.bohemiancoding.sketch3.plist hasShown23Welcome -bool YES 
	echo "date All preferences are now added" 
    echo "date Installation is now complete" 
	echo "date ========== Installation Ended =========="
exit 0

 

when I run your script it opens to a "enter license screen" even though I put my license key in the field in the beginning. The way i'm deploying, while not the prettiest, is working so i'll leave it as is for now. 

Oh, interesting. To be fair, I haven't looked at it for a while. Will have to double check and see. Yeah, the way you do it is the way I used to. At least for updates you only have to do the package, and not touch the license.