This repository has been archived by the owner on Jun 13, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
fh
committed
Mar 7, 2014
1 parent
de5480b
commit b017715
Showing
10 changed files
with
238 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
default["easybib_deploy"] = {} | ||
default["easybib_deploy"]["gearman_file"] = "pecl_manager_env" | ||
default["easybib_deploy"]["env_source"] = nil | ||
default["easybib_deploy"]["provide_pear"] = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
default["php-pear"] = {} | ||
default["php-pear"]["packages"] = { | ||
"Crypt_HMAC2-beta" => "pear.php.net", | ||
"Net_Gearman-alpha" => "pear.php.net", | ||
"Services_Amazon_S3-0.4.0" => "pear.php.net", | ||
"Net_CheckIP2-1.0.0RC3" => "pear.php.net", | ||
"Easybib_Form_Decorator-0.3.2" => "easybib.github.com/pear", | ||
"StatsD-alpha" => "easybib.github.com/pear", | ||
"Lagged_Session_SaveHandler_Memcache-0.8.0b2" => "easybib.github.com/pear", | ||
"Rediska-0.5.6" => "easybib.github.com/pear" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
name "php-pear" | ||
maintainer "Till Klampaeckel" | ||
maintainer_email "till@php.net" | ||
license "BSD License" | ||
description "Installs various PEAR packages" | ||
version "0.1" | ||
|
||
depends "php" | ||
depends "php-fpm" | ||
|
||
supports 'ubuntu' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
def initialize(*args) | ||
super(*args) | ||
|
||
pear = pear_run("which pear").strip | ||
|
||
if pear.empty? | ||
fail Chef::Exceptions::ShellCommandFailed, "PEAR is not installed, or not in the path." | ||
end | ||
|
||
@pear_cmd = pear | ||
|
||
Chef::Log.debug("Looks like we found a PEAR installer: #{@pear_cmd}") | ||
pear_run("#{@pear_cmd} config-set auto_discover 1") | ||
Chef::Log.debug("Enabled auto_discover") | ||
end | ||
|
||
def pear_run(cmd) | ||
cmd = Mixlib::ShellOut.new(cmd) | ||
out = cmd.run_command.stdout.strip | ||
# Chef::Log.debug("Command '#{cmd.command}' ran with exit status: #{cmd.exitstatus}") | ||
# Chef::Log.debug("StdOut: #{cmd.stdout}") | ||
# Chef::Log.debug("StdErr: #{cmd.stderr}") | ||
|
||
if cmd.exitstatus > 0 | ||
fail "Failed: #{cmd.command}, StdOut: #{cmd.stdout}, StdErr: #{cmd.stderr}" | ||
end | ||
|
||
out | ||
end | ||
|
||
def discovered?(pear, channel) | ||
command = "#{pear} channel-info #{channel}" | ||
cmd = Mixlib::ShellOut.new(command) | ||
|
||
cmd.run_command | ||
|
||
if cmd.exitstatus > 0 | ||
return false | ||
else | ||
return true | ||
end | ||
end | ||
|
||
def pear_cmd(pear, action, package, force, channel, version) | ||
if !discovered?(pear, channel) | ||
discover = Mixlib::ShellOut.new("#{pear} channel-discover #{channel}") | ||
discover.run_command | ||
end | ||
|
||
# get the alias - BUT Y U NEED ALIAS?! - because when the channel is 'foo.example.org/pear' it screws up pear install | ||
command_alias = "#{pear} channel-info #{channel}|grep -a Alias|awk '{print $2}'" | ||
channel_alias = pear_run(command_alias) | ||
if channel_alias.empty? | ||
fail "Could not find alias for #{channel}" | ||
end | ||
Chef::Log.debug("Channel: #{channel}, Alias: #{channel_alias}") | ||
|
||
# avoid roundtrip to channel if it's installed | ||
if action == 'install_if_missing' | ||
p_count = pear_run("#{pear} list -c #{channel_alias}|grep -a #{package}|wc -l") | ||
if p_count.to_i > 0 | ||
Chef::Log.debug("PEAR package #{package} is already installed.") | ||
return | ||
end | ||
action = "install" | ||
end | ||
|
||
# force whatever comes next (probably a good idea) | ||
f_param = "" | ||
if force == true | ||
f_param = " -f" | ||
end | ||
|
||
# version string | ||
version_str = "" | ||
if version && !version.empty? | ||
version_str = "-#{version}" | ||
end | ||
|
||
complete_command = "#{pear} #{action}#{f_param} #{channel_alias}/#{package}#{version_str}" | ||
execute "PEAR: run #{action}: #{complete_command}" do | ||
command complete_command | ||
end | ||
end | ||
|
||
action :install do | ||
pear_cmd(@pear_cmd, "install", new_resource.name, new_resource.force, new_resource.channel, new_resource.version) | ||
new_resource.updated_by_last_action(true) | ||
end | ||
|
||
action :uninstall do | ||
pear_cmd(@pear_cmd, "uninstall", new_resource.name, new_resource.force, new_resource.channel, new_resource.version) | ||
new_resource.updated_by_last_action(true) | ||
end | ||
|
||
action :upgrade do | ||
pear_cmd(@pear_cmd, "upgrade", new_resource.name, new_resource.force, new_resource.channel, new_resource.version) | ||
new_resource.updated_by_last_action(true) | ||
end | ||
|
||
action :install_if_missing do | ||
pear_cmd(@pear_cmd, "install_if_missing", new_resource.name, new_resource.force, new_resource.channel, new_resource.version) | ||
new_resource.updated_by_last_action(true) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# | ||
# Cookbook Name:: php-fpm | ||
# Recipe:: default | ||
# | ||
# Copyright 2010-2012, Till Klampaeckel | ||
# | ||
# All rights reserved. | ||
# | ||
# Redistribution and use in source and binary forms, with or without modification, | ||
# are permitted provided that the following conditions are met: | ||
# | ||
# * Redistributions of source code must retain the above copyright notice, this list | ||
# of conditions and the following disclaimer. | ||
# * Redistributions in binary form must reproduce the above copyright notice, this | ||
# list of conditions and the following disclaimer in the documentation and/or other | ||
# materials provided with the distribution. | ||
# * The names of its contributors may not be used to endorse or promote products | ||
# derived from this software without specific prior written permission. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | ||
# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | ||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
# POSSIBILITY OF SUCH DAMAGE. | ||
# | ||
|
||
pears = ["/usr/local/bin/pear", "/usr/bin/pear"] | ||
|
||
pears.each do |pear| | ||
link pear do | ||
to "#{node["php-fpm"]["prefix"]}/bin/pear" | ||
end | ||
end | ||
|
||
# fucking hack. remove when pear is newer than 1.9.4 | ||
# see https://github.com/pear/pear-core/commit/8d569263eac91ad9484b45acb3a6381759138f3c#diff-b0dfa4abcb5cde685dae6b352ae38a17 | ||
remote_file "/opt/easybib/pear/PEAR/REST.php" do | ||
source "https://raw2.github.com/pear/pear-core/8d569263eac91ad9484b45acb3a6381759138f3c/PEAR/REST.php" | ||
mode 0644 | ||
end | ||
|
||
if !node["php-pear"]["packages"].empty? | ||
include_recipe "php-pear::packages" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# | ||
# Cookbook Name:: php-pear | ||
# Recipe:: packages | ||
# | ||
# Copyright 2010-2012, Till Klampaeckel | ||
# | ||
# All rights reserved. | ||
# | ||
# Redistribution and use in source and binary forms, with or without modification, | ||
# are permitted provided that the following conditions are met: | ||
# | ||
# * Redistributions of source code must retain the above copyright notice, this list | ||
# of conditions and the following disclaimer. | ||
# * Redistributions in binary form must reproduce the above copyright notice, this | ||
# list of conditions and the following disclaimer in the documentation and/or other | ||
# materials provided with the distribution. | ||
# * The names of its contributors may not be used to endorse or promote products | ||
# derived from this software without specific prior written permission. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | ||
# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | ||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
# POSSIBILITY OF SUCH DAMAGE. | ||
# | ||
|
||
# install packages | ||
node["php-pear"]["packages"].each do |pear_package, pear_channel| | ||
|
||
version = "" | ||
if !pear_package.index('-').nil? | ||
attrs = pear_package.split('-') | ||
pear_package, pear_version = attrs | ||
end | ||
|
||
# Chef::Log.info("PACKAGE: #{package}, Version: #{version}, Channel: #{channel}") | ||
|
||
php_pear pear_package do | ||
action :install_if_missing | ||
channel pear_channel | ||
force true | ||
version pear_version | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
actions :install, :uninstall, :upgrade, :install_if_missing | ||
|
||
default_action :install | ||
|
||
attribute :package, :kind_of => String, :name_attribute => true | ||
attribute :channel, :kind_of => String, :default => 'pear.php.net' | ||
attribute :version, :kind_of => String, :default => nil | ||
attribute :force, :equal_to => [true, false], :default => false |