macos_install

in chef/cookbooks/cpe_crowdstrike_falcon_sensor/resources/cpe_crowdstrike_falcon_sensor.rb [122:195]


  def macos_install(receipt, reg_token, falconctl_path = falcon_agent_prefs['falconctl_path'])
    if node.os_less_than?('10.14.5')
      Chef::Log.warn('cpe_crowdstrike_falcon_sensor only supports macOS Mojave 10.14.5 and higher. Please use a prior '\
        'version of this cookbook if you need earlier support.')
      return
    end

    
    execute "/usr/sbin/pkgutil --forget #{receipt}" do
      not_if { macos_cs_file_integrity_healthy? }
      not_if { shell_out("/usr/sbin/pkgutil --pkg-info #{receipt}").error? }
    end

    file_name = "#{node['cpe_crowdstrike_falcon_sensor']['pkg']['app_name']}-"\
    "#{node['cpe_crowdstrike_falcon_sensor']['pkg']['version']}.pkg"
    file_path = ::File.join(Chef::Config[:file_cache_path], file_name)

    cpe_remote_file node['cpe_crowdstrike_falcon_sensor']['pkg']['app_name'] do
      backup 1
      file_name file_name
      checksum node['cpe_crowdstrike_falcon_sensor']['pkg']['checksum']
      path file_path
    end

    
    Dir[::File.join(Chef::Config[:file_cache_path], 'crowdstrike*.pkg')].each do |path|
      file path do
        action :delete
        not_if { path == file_path }
      end
    end

    
    
    cpe_remote_pkg 'Crowdstrike Falcon' do
      allow_downgrade node['cpe_crowdstrike_falcon_sensor']['pkg']['allow_downgrade']
      app node['cpe_crowdstrike_falcon_sensor']['pkg']['app_name']
      version node['cpe_crowdstrike_falcon_sensor']['pkg']['version']
      checksum node['cpe_crowdstrike_falcon_sensor']['pkg']['checksum']
      receipt receipt
      backup 1
      only_if { node.macos_install_compat_check(file_path) }
    end
    
    
    
    
    
    
    

    
    directory 'Ensure CrowdStrike directory path' do
      path falcon_support_path
      owner root_owner
      group node['root_group']
      mode '0755'
      recursive true
      only_if { node.macos_install_compat_check(file_path) }
    end

    
    
    execute 'Setting Crowdstrike Falcon registration token' do
      command "#{falconctl_path} license #{reg_token}"
      only_if { ::File.exists?(falconctl_path) }
      
      
      
      not_if { ::File.exists?(::File.join(falcon_support_path, 'License.bin')) }
      only_if { node.macos_install_compat_check(file_path) }
    end
  end