From 6c4d7e581efd5fabc96fa3d4bb80ad7859798ec8 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Tue, 31 Aug 2010 10:12:25 -0600 Subject: [PATCH] Add postinstall script to set horde_dir config value. --- framework/Role/Setconfig.php | 75 ++++++++++++++++++++++++++++++++++++++++++++ framework/Role/package.xml | 12 +++++++ 2 files changed, 87 insertions(+) create mode 100644 framework/Role/Setconfig.php diff --git a/framework/Role/Setconfig.php b/framework/Role/Setconfig.php new file mode 100644 index 000000000..29364f6ed --- /dev/null +++ b/framework/Role/Setconfig.php @@ -0,0 +1,75 @@ + + * @category Horde + * @copyright 2010 The Horde Project (http://www.horde.org/) + * @license http://www.fsf.org/copyleft/gpl.html GPL + * @package Role + */ + +/** + * @author Michael Slusarz + * @category Horde + * @copyright 2010 The Horde Project (http://www.horde.org/) + * @license http://www.fsf.org/copyleft/gpl.html GPL + * @package Role + */ +class Setconfig_postinstall +{ + /** + * PEAR config object. + * + * @var PEAR_Config + */ + protected $_config; + + /** + * Init postinstall task. + * + * @param PEAR_Config $config Config object. + * @param PEAR_PackageFile_v2 $pkg Package object. + * @param string $version Last version installed. + * + * @returns boolean Success. + */ + public function init($config, $pkg, $version) + { + $this->_config = $config; + + return true; + } + + /** + * Run task after prompt. + * + * @param array $info Parameter array. + * @param string $name Postinstall phase. + */ + public function run($info, $phase) + { + if ($phase !== 'first') { + return; + } + + if (!$this->_config->set('horde_dir', $info['horde_dir'], 'user', 'pear.horde.org')) { + print "Could not save horde_dir configuration value to PEAR config.\n"; + return; + } + + $res = $this->_config->writeConfigFile(); + if ($res instanceof PEAR_Error) { + print 'ERROR: ' . $res->getMessage() . "\n"; + exit; + } + + print "Configuration successfully saved to PEAR config.\n"; + } + +} diff --git a/framework/Role/package.xml b/framework/Role/package.xml index 450a0f558..d04be4f14 100644 --- a/framework/Role/package.xml +++ b/framework/Role/package.xml @@ -31,6 +31,18 @@ http://pear.php.net/dtd/package-2.0.xsd"> + + + + first + + horde_dir + Filesystem location where the Horde application is installed. + string + + + + -- 2.11.0