in chef/cookbooks/cpe_umad/resources/cpe_umad_install.rb [51:239]
def install
[
'/Library/umad',
'/Library/umad/Resources',
'/Library/umad/Resources/umad.nib',
].each do |dir|
directory dir do
owner root_owner
group node['root_group']
mode '0755'
action :create
end
end
directory '/Library/umad/Logs' do
owner root_owner
group node['root_group']
mode '0777'
action :create
end
file '/Library/umad/Logs/umad.log' do
mode '0777'
action :create
end
umad_files = [
'FoundationPlist.py',
'nibbler.py',
'umad',
'umad_check_dep_record',
'umad_trigger_nag',
]
ld_la_identifiers = [
label(node['cpe_umad']['la_identifier']),
label(node['cpe_umad']['ld_dep_identifier']),
label(node['cpe_umad']['ld_nag_identifier']),
]
umad_files.each do |item|
umad_bins = ['umad', 'umad_check_dep_record', 'umad_trigger_nag']
if umad_bins.include?(item)
if ::File.exists?(node['cpe_umad']['python_path'])
template "/Library/umad/Resources/#{item}" do
backup false
owner root_owner
group node['root_group']
mode '0755'
source item
variables('shebang' => node['cpe_umad']['shebang'])
ld_la_identifiers.each do |identifier|
if ::File.exists?("/Library/LaunchAgents/#{identifier}.plist") \
|| ::File.exists?("/Library/LaunchDaemons/#{identifier}.plist")
notifies :disable, "launchd[#{identifier}]", :immediately
end
end
end
else
cookbook_file "/Library/umad/Resources/#{item}" do
backup false
owner root_owner
group node['root_group']
mode '0755'
action :create
path "/Library/umad/Resources/#{item}"
source "resources/py2_#{item}"
ld_la_identifiers.each do |identifier|
if ::File.exists?("/Library/LaunchAgents/#{identifier}.plist") \
|| ::File.exists?("/Library/LaunchDaemons/#{identifier}.plist")
notifies :disable, "launchd[#{identifier}]", :immediately
end
end
end
end
elsif item == 'FoundationPlist.py' && ::File.exists?(node['cpe_umad']['python_path'])
next
else
cookbook_file "/Library/umad/Resources/#{item}" do
owner root_owner
group node['root_group']
mode '0755'
action :create
path "/Library/umad/Resources/#{item}"
if ::File.exists?(node['cpe_umad']['python_path'])
source "resources/#{item}"
else
source "resources/py2_#{item}"
end
ld_la_identifiers.each do |identifier|
if ::File.exists?("/Library/LaunchAgents/#{identifier}.plist") \
|| ::File.exists?("/Library/LaunchDaemons/#{identifier}.plist")
notifies :disable, "launchd[#{identifier}]", :immediately
end
end
end
end
end
umad_resource_files = [
'company_logo.png',
'nag_ss.png',
'uamdm_ss.png',
]
if custom_resources?
source_path = 'custom'
else
source_path = 'resources'
end
umad_resource_files.each do |item|
cookbook_file "/Library/umad/Resources/#{item}" do
owner root_owner
group node['root_group']
mode '0755'
action :create
path "/Library/umad/Resources/#{item}"
source "#{source_path}/#{item}"
ld_la_identifiers.each do |identifier|
if ::File.exists?("/Library/LaunchAgents/#{identifier}.plist") \
|| ::File.exists?("/Library/LaunchDaemons/#{identifier}.plist")
notifies :disable, "launchd[#{identifier}]", :immediately
end
end
end
end
umad_nib_files = [
'designable.nib',
'keyedobjects.nib',
]
umad_nib_files.each do |item|
cookbook_file "/Library/umad/Resources/umad.nib/#{item}" do
owner root_owner
group node['root_group']
mode '0755'
action :create
path "/Library/umad/Resources/umad.nib/#{item}"
source "umad.nib/#{item}"
ld_la_identifiers.each do |identifier|
if ::File.exists?("/Library/LaunchAgents/#{identifier}.plist") \
|| ::File.exists?("/Library/LaunchDaemons/#{identifier}.plist")
notifies :disable, "launchd[#{identifier}]", :immediately
end
end
end
end
launchd label(node['cpe_umad']['la_identifier']) do
action :nothing
type 'agent'
end
launchd label(node['cpe_umad']['ld_dep_identifier']) do
action :nothing
type 'daemon'
end
launchd label(node['cpe_umad']['ld_nag_identifier']) do
action :nothing
type 'daemon'
end
directory '/Library/Application Support/umad' do
action :delete
recursive true
end
end