This repository has been archived by the owner on Mar 24, 2022. It is now read-only.
/
mouse_locator.rb
54 lines (46 loc) · 1.72 KB
/
mouse_locator.rb
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
unless File.exists?(node['mouse_locator_dst'])
remote_file "/tmp/mouse_locator.dmg" do
source node["mouse_locator_download_uri"]
mode "0644"
action :create_if_missing
end
execute "mount mouse_locator dmg" do
command "hdid /tmp/mouse_locator.dmg"
user WS_USER
end
# We're bypassing the installer.app because it requires intervention.
# per the installer readme, the installer does the following:
# (I put YES/NO in front of each step if we do it/don't do it).
# - NO: Deactivate any previous version of Mouse Locator
# - YES: Close the System Preferences, if open
# - NO: Remove any previously installed Mouse Locator
# - YES: Install a new version of Mouse Locator into:
# {HomeFolder}/Library/PreferencePanes/
# - YES: Activate Mouse Locator, if previously active
# - NO: Open the System Preferences, and display the Mouse Locator
# Preferences Pane
execute "Close System Preferences" do
command 'killall "System Preferences"'
user WS_USER
# we don't care if it fails because it means
# System Prefs wasn't running in the first place
returns [0, 1]
end
execute "Copy mouse_locator to ~/Library/PreferencePanes/" do
command "cp -rf #{Regexp.escape(node["mouse_locator_src"])} #{Regexp.escape(node['mouse_locator_dst'])}"
user WS_USER
end
execute "unmount dmg" do
command "hdiutil detach #{Regexp.escape(node["mouse_locator_dmg_mnt"])}"
user WS_USER
end
execute "Activate Mouse Locator" do
command "open #{node["mouse_locator_app"]} &"
user WS_USER
end
ruby_block "test to see if mouse_locator was installed" do
block do
raise "Mouse Locator install failed" unless File.exists?(node['mouse_locator_dst'])
end
end
end