install

in chef/cookbooks/cpe_nudge/resources/cpe_nudge_python_install.rb [49:150]


  def install
    unless ::File.exists?(node['cpe_nudge']['nudge-python']['python_path'])
      Chef::Log.warn("Python defined in node['cpe_nudge']['nudge-python']['python_path'] is not installed.")
      return
    end
    
    [
      base_path,
      ::File.join(base_path, 'Resources'),
      ::File.join(base_path, 'Resources', 'nudge.nib'),
    ].each do |dir|
      directory dir do
        owner root_owner
        group node['root_group']
        mode '0755'
      end
    end

    
    directory ::File.join(base_path, 'Logs') do
      owner root_owner
      group node['root_group']
      mode '0777'
    end

    
    file ::File.join(base_path, 'Logs', 'nudge.log') do
      mode '0777'
    end

    
    nudge_files = [
      'gurl.py',
      'nibbler.py',
      'nudge',
    ]

    
    
    
    
    nudge_files.each do |item|
      cookbook_file ::File.join(base_path, 'Resources', item) do
        owner root_owner
        group node['root_group']
        mode '0755'
        path ::File.join(base_path, 'Resources', item)
        source "nudge-python/resources/#{item}"
        notifies :disable, "launchd[#{launchagent_label}]", :immediately if ::File.exists?(launchagent_path)
      end
    end

    
    nudge_resource_files = [
      'company_logo.png',
      'update_ss.png',
    ]

    
    if custom_resources?
      source_path = 'custom'
    else
      source_path = 'resources'
    end

    
    nudge_resource_files.each do |item|
      cookbook_file ::File.join(base_path, 'Resources', item) do
        owner root_owner
        group node['root_group']
        mode '0755'
        path ::File.join(base_path, 'Resources', item)
        source "nudge-python/#{source_path}/#{item}"
        notifies :disable, "launchd[#{launchagent_label}]", :immediately if ::File.exists?(launchagent_path)
      end
    end

    
    nudge_nib_files = [
      'designable.nib',
      'keyedobjects.nib',
    ]

    
    nudge_nib_files.each do |item|
      cookbook_file ::File.join(base_path, 'Resources', 'nudge.nib', item) do
        owner root_owner
        group node['root_group']
        mode '0755'
        path "/Library/nudge/Resources/nudge.nib/#{item}"
        source "nudge-python/resources/nudge.nib/#{item}"
        notifies :disable, "launchd[#{launchagent_label}]", :immediately if ::File.exists?(launchagent_path)
      end
    end

    
    launchd launchagent_label do
      action :nothing
      type 'agent'
    end
  end