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 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
!/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?
Is the touch
needed? Seems like the >
bit takes care of creating the file.
@plauer If that's your Sketch license, you may want to edit
emove it.
want to know wether the app ls licenced or not via extension attriboot
@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?
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
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.
@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.
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.
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.
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
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.
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.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.