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.
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
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?
@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
@txhaflaire Thank you, Thank you! That post install script works without a hitch.
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.
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?
@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
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?
@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.
@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.
@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.
@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.
@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.
Thank you sir!
@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.
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.
Hmm, creating the app on APFS machine , end user on HFS+? Or vice versa
Both machines were 10.13.6, APFS.
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.
@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'.
@nberanger How are you running the script?
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.
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:
- sudo bash
- mkdir /Library/Application Support/com.bohemiancoding.sketch3
- echo “SK3-XXXX” > /Library/Application Support/com.bohemiancoding.sketch3/.deployment
.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.