-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathinstall-screen_savers.sh
166 lines (142 loc) · 3.75 KB
/
install-screen_savers.sh
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#!/bin/bash
## Screen Savers Installer
## Version 2.0.1
## Created by JakeNology on 2018-04-11
## MIT License
## Quick Execution
## curl -fkL https://raw.githubusercontent.com/jakenology/Scripts/master/install-screen_savers.sh | sh
## Set Variables
username=$(stat -f%Su /dev/console)
homedir=$(eval echo "~${username}")
DESTINATION=/Library/Screen\ Savers
logfile=~/Library/Logs/install-screen_savers.log
num=0
usercheck() {
if [ "$EUID" -ne 0 ]; then
DESTINATION="$homedir""$DESTINATION"
else
DESTINATION=/System"$DESTINATION"
fi
}
initialize() {
# Create the log file
touch ${logfile}
echo 'Installation Started on $(date)'
# Tell the installer the current progress
echo "PROGRESS:$num"
echo 'Installer Initialized' >> ${logfile}
}
## Check if Online
internet() {
echo -e "GET http://google.com HTTP/1.0\n\n" | nc google.com 80 > /dev/null 2>&1
if [ $? -eq 0 ]; then
online=true
else
echo
osascript -e 'display dialog "The connection is down. Please try again later."'
exit 0
fi
}
start() {
usercheck
initialize
internet
echo $homedir
}
## Start the Installation
start
## Download ZIP file
progress=5
echo 'Downloading ZIP...'
echo 'Downloading ZIP...' >> ${logfile}
curl -Lo "/tmp/Screen Savers.zip" https://github.com/jakenology/Screen-Savers/raw/master/Screen%20Savers.zip --silent > /dev/null
num=$(($num + $progress))
echo "$num% Complete"
echo "PROGRESS:$num"
## Download Success icon
progress=5
echo 'Downloading Installer Support Files...'
curl -Lo "/tmp/Success.pdf" https://github.com/jakenology/Screen-Savers/raw/master/Success.pdf --silent > /dev/null
num=$(($num + $progress))
echo "$num% Complete"
echo "PROGRESS:$num"
## Wait
progress=5
echo 'Processing...'
num=$(($num + $progress))
echo "$num% Complete"
echo "PROGRESS:$num"
## Unzip files to temp
progress=10
echo 'Unzipping files to /tmp...'
unzip -oqq "/tmp/Screen Savers.zip" -d /tmp > /dev/null
num=$(($num + $progress))
echo "$num% Complete"
echo "PROGRESS:$num"
## Move Screen Savers to their folder
echo 'Moving files into place...'
for f in /tmp/Screen\ Savers/*
do
rsync -av "${f}" "$DESTINATION" > /dev/null
num=$(($num + 2))
echo "PROGRESS:$num"
echo "$num% Complete"
done
## Remove ZIP
progress=10
echo 'Removing File 1 of 3...'
rm -R "/tmp/Screen Savers.zip" > /dev/null
num=$(($num + $progress))
echo "$num% Complete"
echo "PROGRESS:$num"
## Remove the Screen Saver folder
progress=5
echo 'Removing file 2 of 3...'
rm -R "/tmp/Screen Savers" > /dev/null
num=$(($num + $progress))
echo "$num% Complete"
echo "PROGRESS:$num"
## Remove the macOS folder
progress=5
echo 'removing file 3 of 3...'
rm -R "/tmp/__MACOSX" > /dev/null
num=$(($num + $progress))
echo "$num% Complete"
echo "PROGRESS:$num"
## Wait
progress=5
echo 'Processing'
num=$(($num + $progress))
echo "$num% Complete"
echo "PROGRESS:$num"
## Display Success Notification
progress=5
echo 'Displaying Success Alert...'
afplay "/tmp/burn complete.aif" &
osascript -e 'tell application "System Events"
display dialog "Your Screen Savers have been successfully installed." buttons {"Thanks!"} default button {"Thanks!"} with icon {"/tmp/success.pdf"} giving up after 3
end tell' > /dev/null
num=$(($num + $progress))
echo "$num% Complete"
echo "PROGRESS:$num"
## Open the Screensaver Pane
progress=5
echo 'Opening System Preferences...'
osascript -e 'tell application "System Preferences"
activate
reveal anchor "ScreenSaverPref" of pane "com.apple.preference.desktopscreeneffect"
end tell' > /dev/null
num=$(($num + $progress))
echo "$num% Complete"
echo "PROGRESS:$num"
## Remove the success icon
progress=5
echo 'Cleaning Up'
rm -R /tmp/Success.pdf > /dev/null
num=$(($num + $progress))
num=$(($num + $progress))
echo "$num% Complete"
echo "PROGRESS:$num" 1<&2
## Exit the Installer
echo 'Install Screensavers Complete! Exiting...'
echo 'QUITAPP\n'