-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSketch-Install-Update.sh
More file actions
129 lines (107 loc) · 4.43 KB
/
Sketch-Install-Update.sh
File metadata and controls
129 lines (107 loc) · 4.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/bin/bash
function ConfigureSketch () {
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 '\n' ' '`
LicenseKey="SK3-####-####-####-####-####"
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"
ConfigureSketch
}
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