Skip to content

Commit

Permalink
Merge pull request #310 from mcrauwel/master
Browse files Browse the repository at this point in the history
no further config required for PEAR extensions
  • Loading branch information
igalic committed Feb 22, 2017
2 parents 18dd672 + a89c005 commit 3341b7b
Showing 1 changed file with 57 additions and 55 deletions.
112 changes: 57 additions & 55 deletions manifests/extension.pp
Original file line number Diff line number Diff line change
Expand Up @@ -142,74 +142,76 @@
$package_depends = undef
}

if $zend == true {
$extension_key = 'zend_extension'
if $php_api_version != undef {
$module_path = "/usr/lib/php5/${php_api_version}/"
if $provider != 'pear' { # PEAR packages don't require antu further configuration, they just need to "be there".
if $zend == true {
$extension_key = 'zend_extension'
if $php_api_version != undef {
$module_path = "/usr/lib/php5/${php_api_version}/"
}
else {
$module_path = undef
}
}
else {
$extension_key = 'extension'
$module_path = undef
}
}
else {
$extension_key = 'extension'
$module_path = undef
}

if $so_name != $name {
$lowercase_title = $so_name
}
else {
$lowercase_title = downcase($title)
}
if $so_name != $name {
$lowercase_title = $so_name
}
else {
$lowercase_title = downcase($title)
}

# Ensure "<extension>." prefix is present in setting keys if requested
if $settings_prefix {
if is_string($settings_prefix) {
$full_settings_prefix = $settings_prefix
# Ensure "<extension>." prefix is present in setting keys if requested
if $settings_prefix {
if is_string($settings_prefix) {
$full_settings_prefix = $settings_prefix
} else {
$full_settings_prefix = $lowercase_title
}
$full_settings = ensure_prefix($settings, "${full_settings_prefix}.")
} else {
$full_settings_prefix = $lowercase_title
$full_settings = $settings
}
$full_settings = ensure_prefix($settings, "${full_settings_prefix}.")
} else {
$full_settings = $settings
}

$final_settings = deep_merge(
{"${extension_key}" => "${module_path}${so_name}.so"},
$full_settings
)

$config_root_ini = pick_default($::php::config_root_ini, $::php::params::config_root_ini)
::php::config { $title:
file => "${config_root_ini}/${lowercase_title}.ini",
config => $final_settings,
require => $package_depends,
}

# Ubuntu/Debian systems use the mods-available folder. We need to enable
# settings files ourselves with php5enmod command.
$ext_tool_enable = pick_default($::php::ext_tool_enable, $::php::params::ext_tool_enable)
$ext_tool_query = pick_default($::php::ext_tool_query, $::php::params::ext_tool_query)
$ext_tool_enabled = pick_default($::php::ext_tool_enabled, $::php::params::ext_tool_enabled)
$final_settings = deep_merge(
{"${extension_key}" => "${module_path}${so_name}.so"},
$full_settings
)

if $::osfamily == 'Debian' and $ext_tool_enabled {
$cmd = "${ext_tool_enable} -s ${sapi} ${lowercase_title}"
$config_root_ini = pick_default($::php::config_root_ini, $::php::params::config_root_ini)
::php::config { $title:
file => "${config_root_ini}/${lowercase_title}.ini",
config => $final_settings,
require => $package_depends,
}

if $sapi == 'ALL' {
exec { $cmd:
onlyif => "${ext_tool_query} -s cli -m ${lowercase_title} | /bin/grep 'No module matches ${lowercase_title}'",
require =>::Php::Config[$title],
}
} else {
exec { $cmd:
onlyif => "${ext_tool_query} -s ${sapi} -m ${lowercase_title} | /bin/grep 'No module matches ${lowercase_title}'",
require =>::Php::Config[$title],
# Ubuntu/Debian systems use the mods-available folder. We need to enable
# settings files ourselves with php5enmod command.
$ext_tool_enable = pick_default($::php::ext_tool_enable, $::php::params::ext_tool_enable)
$ext_tool_query = pick_default($::php::ext_tool_query, $::php::params::ext_tool_query)
$ext_tool_enabled = pick_default($::php::ext_tool_enabled, $::php::params::ext_tool_enabled)

if $::osfamily == 'Debian' and $ext_tool_enabled {
$cmd = "${ext_tool_enable} -s ${sapi} ${lowercase_title}"

if $sapi == 'ALL' {
exec { $cmd:
onlyif => "${ext_tool_query} -s cli -m ${lowercase_title} | /bin/grep 'No module matches ${lowercase_title}'",
require =>::Php::Config[$title],
}
} else {
exec { $cmd:
onlyif => "${ext_tool_query} -s ${sapi} -m ${lowercase_title} | /bin/grep 'No module matches ${lowercase_title}'",
require =>::Php::Config[$title],
}
}
}

if $::php::fpm {
Package[$::php::fpm::package] ~> Exec[$cmd]
if $::php::fpm {
Package[$::php::fpm::package] ~> Exec[$cmd]
}
}
}
}

0 comments on commit 3341b7b

Please sign in to comment.