Posted on 01-21-2018 06:48 PM
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.
Solved! Go to Solution.
Posted on 01-21-2018 07:15 PM
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
Posted on 01-22-2018 12:09 AM
@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
Posted on 01-21-2018 07:15 PM
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
Posted on 01-21-2018 09:08 PM
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?
Posted on 01-22-2018 12:09 AM
@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
Posted on 09-27-2021 02:13 PM
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?
Posted on 01-29-2018 10:44 AM
@txhaflaire Thank you, Thank you! That post install script works without a hitch.
Posted on 02-01-2018 09:50 AM
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.
Posted on 02-04-2018 05:01 PM
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?
Posted on 02-05-2018 03:16 AM
@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
Posted on 06-25-2018 08:41 AM
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?
Posted on 06-25-2018 01:04 PM
@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.
Posted on 06-29-2018 05:58 AM
@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.
Posted on 10-12-2018 11:51 AM
@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.
Posted on 10-14-2018 09:39 AM
Why not using the default DMG/PKG for deploying via Self Service?
Posted on 10-15-2018 08:30 AM
@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.
Posted on 10-15-2018 09:00 AM
@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.
Posted on 10-15-2018 10:02 AM
Thank you sir!
Posted on 10-15-2018 10:31 AM
@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.
Posted on 10-15-2018 10:35 AM
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.
Posted on 10-15-2018 10:41 AM
Hmm, creating the app on APFS machine , end user on HFS+? Or vice versa
Posted on 10-25-2018 08:53 AM
Both machines were 10.13.6, APFS.
Posted on 10-26-2018 03:03 AM
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.
Posted on 02-05-2019 08:14 AM
@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'.
Posted on 02-05-2019 08:20 AM
@nberanger How are you running the script?
Posted on 02-05-2019 09:30 AM
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.
Posted on 04-29-2019 04:34 AM
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:
Posted on 04-29-2019 06:46 AM
.
Posted on 07-12-2019 08:29 PM
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
Posted on 06-16-2020 04:26 PM
mkdir /Library/Application Support/com.bohemiancoding.sketch3
touch /Library/Application Support/com.bohemiancoding.sketch3/.deployment
echo "SK3-8799-6840-5835-0391-0016" > /Library/Application Support/com.bohemiancoding.sketch3/.deployment
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?
Posted on 06-16-2020 05:38 PM
Is the touch
needed? Seems like the >
bit takes care of creating the file.
Posted on 08-16-2020 12:55 PM
@plauer If that's your Sketch license, you may want to edit emove it. ;)
Posted on 02-12-2021 03:59 AM
want to know wether the app ls licenced or not via extension attriboot
09-28-2021 06:30 AM - edited 09-28-2021 06:40 AM
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
Posted on 09-28-2021 07:31 AM
@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.
09-28-2021 07:55 AM - edited 09-28-2021 07:57 AM
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.
Posted on 09-28-2021 12:28 PM
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.
Posted on 09-28-2021 12:42 PM
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
Posted on 09-28-2021 01:10 PM
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.
Posted on 09-28-2021 01:12 PM
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.