/** * handler for command line scripts * * @return boolean */ public function handle() { try { $opts = new Zend_Console_Getopt(array('help|h' => 'Display this help Message', 'verbose|v' => 'Output messages', 'config|c=s' => 'Path to config.inc.php file', 'setconfig' => 'Update config. To specify the key and value, append \' -- configKey="your_key" configValue="your config value"\' Examples: setup.php --setconfig -- configkey=sample1 configvalue=value11 setup.php --setconfig -- configkey=sample2 configvalue=arrayKey1:Value1,arrayKey2:value2', 'check_requirements' => 'Check if all requirements are met to install and run tine20', 'create_admin' => 'Create new admin user (or reactivate if already exists)', 'install-s' => 'Install applications [All] or comma separated list;' . ' To specify the login name and login password of the admin user that is created during installation, append \' -- adminLoginName="admin" adminPassword="******"\'' . ' To add imap or smtp settings, append (for example) \' -- imap="host:mail.example.org,port:143,dbmail_host:localhost" smtp="ssl:tls"\'', 'update-s' => 'Update applications [All] or comma separated list', 'uninstall-s' => 'Uninstall application [All] or comma separated list', 'list-s' => 'List installed applications', 'sync_accounts_from_ldap' => 'Import user and groups from ldap', 'egw14import' => 'Import user and groups from egw14 Examples: setup.php --egw14import egwdbhost egwdbuser egwdbpass egwdbname latin1 setup.php --egw14import egwdbhost egwdbuser egwdbpass egwdbname utf8')); $opts->parse(); } catch (Zend_Console_Getopt_Exception $e) { echo "Invalid usage: {$e->getMessage()}\n\n"; echo $e->getUsageMessage(); exit; } if (count($opts->toArray()) === 0 || $opts->h || empty($opts->install) && empty($opts->update) && empty($opts->uninstall) && empty($opts->list) && empty($opts->sync_accounts_from_ldap) && empty($opts->egw14import) && empty($opts->check_requirements) && empty($opts->create_admin) && empty($opts->setconfig)) { echo $opts->getUsageMessage(); exit; } if ($opts->config) { // add path to config.inc.php to include path $path = strstr($opts->config, 'config.inc.php') !== false ? dirname($opts->config) : $opts->config; set_include_path($path . PATH_SEPARATOR . get_include_path()); } Setup_Core::initFramework(); if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Is cli request. method: ' . (isset($opts->mode) ? $opts->mode : 'EMPTY')); } $setupServer = new Setup_Frontend_Cli(); #$setupServer->authenticate($opts->username, $opts->password); return $setupServer->handle($opts); }
/** * set config options (accounts/authentication/email/...) * * @param array $_options */ protected function _setupConfigOptions($_options) { // ignore empty options foreach ($_options as $key => $value) { if (empty($_options[$key])) { unset($_options[$key]); } } if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Saving config options (accounts/authentication/email/...)'); } // this is a dangerous TRACE as there might be passwords in here! //if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . print_r($_options, TRUE)); $defaults = empty($_options['authenticationData']) ? Setup_Controller::getInstance()->loadAuthenticationData() : $_options['authenticationData']; $defaultGroupNames = $this->_parseDefaultGroupNameOptions($_options); $defaults['accounts'][Tinebase_User::getConfiguredBackend()] = array_merge($defaults['accounts'][Tinebase_User::getConfiguredBackend()], $defaultGroupNames); $emailConfigKeys = Setup_Controller::getInstance()->getEmailConfigKeys(); $configsToSet = array_merge($emailConfigKeys, array('authentication', 'accounts', 'redirectSettings', 'acceptedTermsVersion')); if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) { Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . print_r($configsToSet, TRUE)); } if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) { Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . print_r($defaults, TRUE)); } $optionsToSave = array(); foreach ($configsToSet as $group) { if (isset($_options[$group])) { $parsedOptions = is_string($_options[$group]) ? Setup_Frontend_Cli::parseConfigValue($_options[$group]) : $_options[$group]; switch ($group) { case 'authentication': case 'accounts': $backend = isset($parsedOptions['backend']) ? ucfirst($parsedOptions['backend']) : Tinebase_User::SQL; $optionsToSave[$group][$backend] = isset($parsedOptions[$backend]) ? $parsedOptions[$backend] : $parsedOptions; $optionsToSave[$group]['backend'] = $backend; break; default: $optionsToSave[$group] = $parsedOptions; } } else { if (isset($defaults[$group])) { $optionsToSave[$group] = $defaults[$group]; } } } if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) { Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . print_r($optionsToSave, TRUE)); } Setup_Controller::getInstance()->saveEmailConfig($optionsToSave); Setup_Controller::getInstance()->saveAuthentication($optionsToSave); }
/** * (non-PHPdoc) * @see Tinebase_Server_Interface::handle() */ public function handle(\Zend\Http\Request $request = null, $body = null) { try { $opts = new Zend_Console_Getopt(array('help|h' => 'Display this help Message', 'verbose|v' => 'Output messages', 'config|c=s' => 'Path to config.inc.php file', 'setconfig' => 'Update config. To specify the key and value, append \' -- configkey="your_key" configValue="your config value"\' Examples: setup.php --setconfig -- configkey=sample1 configvalue=value11 setup.php --setconfig -- configkey=sample2 configvalue=arrayKey1:Value1,arrayKey2:value2 ', 'getconfig' => 'Get Config value for a specify the key \' -- configkey="your_key"\'', 'check_requirements' => 'Check if all requirements are met to install and run tine20', 'create_admin' => 'Create new admin user (or reactivate if already exists)', 'install-s' => 'Install applications [All] or comma separated list;' . ' To specify the login name and login password of the admin user that is created during installation, append \' -- adminLoginName="admin" adminPassword="******"\'' . ' To add imap or smtp settings, append (for example) \' -- imap="host:mail.example.org,port:143,dbmail_host:localhost" smtp="ssl:tls"\'', 'update-s' => 'Update applications [All] or comma separated list', 'uninstall-s' => 'Uninstall application [All] or comma separated list', 'list-s' => 'List installed applications', 'sync_accounts_from_ldap' => 'Import user and groups from ldap', 'dbmailldap' => 'Only usable with sync_accounts_from_ldap. Fetches dbmail email user data from LDAP.', 'onlyusers' => 'Only usable with sync_accounts_from_ldap. Fetches only users and no groups from LDAP.', 'syncdeletedusers' => 'Only usable with sync_accounts_from_ldap. Removes users from Tine 2.0 DB that no longer exist in LDAP', 'syncaccountstatus' => 'Only usable with sync_accounts_from_ldap. Synchronizes current account status from LDAP', 'syncontactphoto' => 'Only usable with sync_accounts_from_ldap. Always syncs contact photo from ldap', 'sync_passwords_from_ldap' => 'Synchronize user passwords from ldap', 'egw14import' => 'Import user and groups from egw14 Examples: setup.php --egw14import /path/to/config.ini', 'reset_demodata' => 'reinstall applications and install Demodata (Needs Admin user)', 'updateAllImportExportDefinitions' => 'update ImportExport definitions for all applications', 'backup' => 'backup config and data Examples: setup.php --backup -- config=1 db=1 files=1 backupDir=/backup/tine20 noTimestamp=1', 'restore' => 'restore config and data Examples: setup.php --restore -- config=1 db=1 files=1 backupDir=/backup/tine20')); $opts->parse(); } catch (Zend_Console_Getopt_Exception $e) { echo "Invalid usage: {$e->getMessage()}\n\n"; echo $e->getUsageMessage(); exit; } if (count($opts->toArray()) === 0 || $opts->h || empty($opts->install) && empty($opts->update) && empty($opts->uninstall) && empty($opts->list) && empty($opts->sync_accounts_from_ldap) && empty($opts->sync_passwords_from_ldap) && empty($opts->egw14import) && empty($opts->check_requirements) && empty($opts->reset_demodata) && empty($opts->updateAllImportExportDefinitions) && empty($opts->create_admin) && empty($opts->setconfig) && empty($opts->backup) && empty($opts->restore) && empty($opts->getconfig)) { echo $opts->getUsageMessage(); exit; } if ($opts->config) { // add path to config.inc.php to include path $path = strstr($opts->config, 'config.inc.php') !== false ? dirname($opts->config) : $opts->config; set_include_path($path . PATH_SEPARATOR . get_include_path()); } Setup_Core::initFramework(); if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Is cli request. method: ' . $this->getRequestMethod()); } $setupServer = new Setup_Frontend_Cli(); #$setupServer->authenticate($opts->username, $opts->password); return $setupServer->handle($opts); }