Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Berksfile.lock
.*.sw[a-z]
*.un~
/cookbooks
.kitchen

# Bundler
Gemfile.lock
Expand Down
14 changes: 14 additions & 0 deletions .kitchen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
driver:
name: vagrant

provisioner:
name: chef_zero

platforms:
- name: centos-7.3

suites:
- name: default
run_list:
- recipe[php-ioncube::install]
2 changes: 1 addition & 1 deletion Berksfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
site :opscode
source 'https://supermarket.chef.io'

metadata
25 changes: 5 additions & 20 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
Vagrant.configure('2') do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.

config.vm.hostname = "php-ioncube-berkshelf"
config.vm.hostname = 'php-ioncube-berkshelf'

# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "base"

# The url from where the 'config.vm.box' box will be fetched if it
# doesn't already exist on the user's system.
config.vm.box_url = "https://dl.dropbox.com/u/31081437/Berkshelf-CentOS-6.3-x86_64-minimal.box"
config.vm.box = 'bento/centos-7.3'

# Assign this VM to a host-only network IP, allowing you to access it
# via the IP. Host-only networks can talk to the host machine as well as
# any other machines on the same network, but cannot be accessed (through this
# network interface) by any external networks.
config.vm.network :private_network, ip: "33.33.33.10"
config.vm.network :private_network, ip: '33.33.33.10'

# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
Expand Down Expand Up @@ -52,9 +48,6 @@ Vagrant.configure("2") do |config|
# View the documentation for the provider you're using for more
# information on available options.

config.ssh.max_tries = 40
config.ssh.timeout = 120

# The path to the Berksfile to use with Vagrant Berkshelf
# config.berkshelf.berksfile_path = "./Berksfile"

Expand All @@ -67,16 +60,8 @@ Vagrant.configure("2") do |config|
# config.berkshelf.except = []

config.vm.provision :chef_solo do |chef|
chef.json = {
:mysql => {
:server_root_password => 'rootpass',
:server_debian_password => 'debpass',
:server_repl_password => 'replpass'
}
}

chef.run_list = [
"recipe[php-ioncube::default]"
'recipe[php-ioncube::install]'
]
end
end
14 changes: 7 additions & 7 deletions metadata.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name "php-ioncube"
maintainer "Andriy Samilyak"
maintainer_email "samilyak@gmail.com"
license "All rights reserved"
description "Installs/Configures php-ioncube"
name 'php-ioncube'
maintainer 'Andriy Samilyak'
maintainer_email 'samilyak@gmail.com'
license 'All rights reserved'
description 'Installs/Configures php-ioncube'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "0.2.0"
version '0.2.2'

depends "php"
depends 'php'
57 changes: 24 additions & 33 deletions providers/install.rb
Original file line number Diff line number Diff line change
@@ -1,59 +1,50 @@
use_inline_resources if defined?(use_inline_resources)

action :install do
arch_string = case node['kernel']['machine']
when 'x86_64'
'x86-64'
when /i[36]86/
'x86'
else
node['kernel']['machine']
end

case run_context.node[:kernel][:machine]
when 'x86_64'
arch_string = 'x86-64'
when /i[36]86/
arch_string = 'x86'
else
arch_string = run_context.node[:kernel][:machine]
end

Chef::Log.debug("case selected #{arch_string}")
Chef::Log.debug("Selected #{arch_string} arch")

remote_file "/usr/local/src/ioncube_loaders_lin_#{arch_string}.tar.gz" do
source "http://downloads3.ioncube.com/loader_downloads/ioncube_loaders_lin_#{arch_string}.tar.gz"
mode "0644"
action :create_if_missing
notifies :run, "script[extract_ioncube_php]", :immediately
notifies :run, 'script[Extract_ioncube_php]', :immediately
end

script "extract_ioncube_php" do
interpreter "bash"
user "root"
cwd "/usr/local/src/"
script 'Extract_ioncube_php' do
interpreter 'bash'
user 'root'
cwd '/usr/local/src/'
action :nothing
code <<-EOH
tar xvfz /usr/local/src/ioncube_loaders_lin_#{arch_string}.tar.gz
mv /usr/local/src/ioncube /usr/local
EOH
end

ruby_block "determine php version" do
ruby_block 'Determine php version' do
block do
php_version_output = `php --version`
php_version_output = shell_out!('php --version').stdout
php_version = php_version_output.match(/PHP ([0-9]+\.[0-9]+)\.[0-9]+/)[1]
Chef::Log.info("detected PHP version #{php_version}")
ioncube_file_resource = run_context.resource_collection.find(:file => "#{run_context.node[:php][:ext_conf_dir]}/ioncube.ini")
Chef::Log.info("Detected PHP version #{php_version}")
ioncube_file_resource = resource_collection.find(file: "#{node['php']['ext_conf_dir']}/ioncube.ini")
ioncube_file_resource.content "; priority=00\nzend_extension=/usr/local/ioncube/ioncube_loader_lin_" + php_version + ".so\n"
end
only_if { run_context.node[:php_ioncube][:version] == '' }
only_if { node['php_ioncube']['version'] == '' }
end

file "#{run_context.node[:php][:ext_conf_dir]}/ioncube.ini" do
content "; priority=00\nzend_extension=/usr/local/ioncube/ioncube_loader_lin_" + run_context.node[:php_ioncube][:version] + ".so\n" # dynamically defined during convergence in above ruby_block
owner "root"
group "root"
mode "0644"
action :create
file "#{node['php']['ext_conf_dir']}/ioncube.ini" do
content "; priority=00\nzend_extension=/usr/local/ioncube/ioncube_loader_lin_" + node['php_ioncube']['version'] + ".so\n"
end

if new_resource.updated_by_last_action?
Chef::Log.info("new_resource.updated_by_last_action is true")
Chef::Log.info('new_resource.updated_by_last_action is true')
else
Chef::Log.info("new_resource.updated_by_last_action is false")
Chef::Log.info('new_resource.updated_by_last_action is false')
end

end
end
2 changes: 1 addition & 1 deletion recipes/default.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include_recipe "php"
include_recipe 'php'
5 changes: 1 addition & 4 deletions recipes/install.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
include_recipe 'php-ioncube::default'

php_ioncube_install "ioncube" do
action :install
end
php_ioncube_install 'ioncube'
3 changes: 1 addition & 2 deletions resources/install.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
actions :install

attribute :name, :kind_of => String, :default => 'phpioncube', :name_attribute => true
attribute :arch, :kind_of => String, :default => node[:kernel][:machine]
property :arch, String, default: node['kernel']['machine']

def initialize(*args)
super
Expand Down
3 changes: 3 additions & 0 deletions test/integration/default/bats/ioncube.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@test "Check if ionCube Loader is loaded" {
php -m | grep -E '^ionCube Loader'
}