7 * @license http://www.gnu.org/licenses/agpl.html AGPL Version 3
8 * @copyright Copyright (c) 2007-2012 Metaways Infosystems GmbH (http://www.metaways.de)
9 * @author Philipp Schüle <p.schuele@metaways.de>
14 * Cli Server class with handle() function
19 class Setup_Server_Cli implements Tinebase_Server_Interface
23 * @see Tinebase_Server_Interface::handle()
25 public function handle(\Zend\Http\Request $request = null, $body = null)
28 $opts = new Zend_Console_Getopt(
30 'help|h' => 'Display this help Message',
31 'verbose|v' => 'Output messages',
32 'config|c=s' => 'Path to config.inc.php file',
33 'setconfig' => 'Update config. To specify the key and value, append \' -- configkey="your_key" configValue="your config value"\'
35 setup.php --setconfig -- configkey=sample1 configvalue=value11
36 setup.php --setconfig -- configkey=sample2 configvalue=arrayKey1:Value1,arrayKey2:value2
38 'getconfig' => 'Get Config value for a specify the key \' -- configkey="your_key"\'',
39 'check_requirements' => 'Check if all requirements are met to install and run tine20',
40 'create_admin' => 'Create new admin user (or reactivate if already exists)',
41 'install-s' => 'Install applications [All] or comma separated list;'
42 . ' To specify the login name and login password of the admin user that is created during installation, append \' -- adminLoginName="admin" adminPassword="password"\''
43 . ' To add imap or smtp settings, append (for example) \' -- imap="host:mail.example.org,port:143,dbmail_host:localhost" smtp="ssl:tls"\'',
44 'update-s' => 'Update applications [All] or comma separated list',
45 'uninstall-s' => 'Uninstall application [All] or comma separated list',
46 'list-s' => 'List installed applications',
47 'sync_accounts_from_ldap' => 'Import user and groups from ldap',
48 'dbmailldap' => 'Only usable with sync_accounts_from_ldap. Fetches dbmail email user data from LDAP.',
49 'onlyusers' => 'Only usable with sync_accounts_from_ldap. Fetches only users and no groups from LDAP.',
50 'sync_passwords_from_ldap' => 'Synchronize user passwords from ldap',
51 'egw14import' => 'Import user and groups from egw14
53 setup.php --egw14import /path/to/config.ini'
56 } catch (Zend_Console_Getopt_Exception $e) {
57 echo "Invalid usage: {$e->getMessage()}\n\n";
58 echo $e->getUsageMessage();
62 if (count($opts->toArray()) === 0 || $opts->h ||
63 (empty($opts->install) &&
64 empty($opts->update) &&
65 empty($opts->uninstall) &&
67 empty($opts->sync_accounts_from_ldap) &&
68 empty($opts->sync_passwords_from_ldap) &&
69 empty($opts->egw14import) &&
70 empty($opts->check_requirements) &&
71 empty($opts->create_admin) &&
72 empty($opts->setconfig) &&
73 empty($opts->getconfig)))
75 echo $opts->getUsageMessage();
80 // add path to config.inc.php to include path
81 $path = strstr($opts->config, 'config.inc.php') !== false ? dirname($opts->config) : $opts->config;
82 set_include_path($path . PATH_SEPARATOR . get_include_path());
85 Setup_Core::initFramework();
87 if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ .' Is cli request. method: ' . $this->getRequestMethod());
89 $setupServer = new Setup_Frontend_Cli();
90 #$setupServer->authenticate($opts->username, $opts->password);
91 return $setupServer->handle($opts);
95 * returns request method
99 public function getRequestMethod()
101 $opts = Tinebase_Core::get('opts');
102 return (isset($opts->mode)) ? $opts->mode : NULL;