#
# Cookbook:: irrigate-php
# Recipe:: sugarcrm
#
# Copyright:: 2017 The Orchard
#
# All rights reserved - Do Not Redistribute
#

if platform_family?('rhel')
  if node['platform_version'].start_with?('7')

    packages = %w(
      php56-php-imap
    )

    packages.each do |name|
      package name
    end

    # Set binary and library locations
    pecl_location = '/opt/remi/php56/root/usr/bin/pecl'
    jsmin_lib_location = '/opt/remi/php56/root/usr/lib64/php/modules/jsmin.so'

    execute 'build-jsmin' do
      command "#{pecl_location} install jsmin-1.1.0"
      creates jsmin_lib_location
    end

    file jsmin_lib_location do
      mode '0755'
    end

    # Enable jsmin extension after build
    file '/opt/remi/php56/root/etc/php.d/10-jsmin.ini' do
      mode '0644'
      owner 'root'
      group 'root'
      content 'extension=jsmin.so'
    end

  end
end
