diff --git a/README.md b/README.md index 8a81fba2ef1426f18221848fa0a8761daeee22a8..72c42c75fdfed5fc31371f5abf90b1e1113c26b0 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ And deploy the code into somewhere in your server's www root folder, for instance cd osTicket-1.8 - php setup/cli/manage.php deploy --setup /var/www/htdocs/osticket/ + php manage.php deploy --setup /var/www/htdocs/osticket/ Then you can configure your server if necessary to serve that folder, and visit the page and install osTicket as usual. Go ahead and even delete @@ -52,7 +52,7 @@ later, you can fetch updates and deploy them (from the folder where you cloned the git repo into) git pull - php setup/cli/manage.php deploy -v /var/www/htdocs/osticket/ + php manage.php deploy -v /var/www/htdocs/osticket/ Upgrading --------- diff --git a/bootstrap.php b/bootstrap.php index 6d80b6330ad075c087c0ad915a6276e2f4e99b3c..c7ba0a41575eab6fc47ed3b566359303ab4f1795 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -309,6 +309,7 @@ define('SETUP_DIR',ROOT_DIR.'setup/'); define('UPGRADE_DIR', INCLUDE_DIR.'upgrader/'); define('I18N_DIR', INCLUDE_DIR.'i18n/'); +define('CLI_DIR', INCLUDE_DIR.'cli/'); /*############## Do NOT monkey with anything else beyond this point UNLESS you really know what you are doing ##############*/ diff --git a/setup/cli/modules/class.module.php b/include/class.cli.php similarity index 100% rename from setup/cli/modules/class.module.php rename to include/class.cli.php diff --git a/setup/cli/cli.inc.php b/include/cli/cli.inc.php similarity index 93% rename from setup/cli/cli.inc.php rename to include/cli/cli.inc.php index 31bdbfe8993cdadadbc4896c1e9257b3909b8cc0..401ddba40fc5d5f7fa74fd3523d58cc5078de8eb 100644 --- a/setup/cli/cli.inc.php +++ b/include/cli/cli.inc.php @@ -21,11 +21,9 @@ if(!strcasecmp(basename($_SERVER['SCRIPT_NAME']),basename(__FILE__))) die('kwahe define('ROOT_PATH', '/'); define('INC_DIR',dirname(__file__).'/../inc/'); //local include dir! -require_once(dirname(__file__).'/../../bootstrap.php'); +require_once INCLUDE_DIR . "class.cli.php"; Bootstrap::loadConfig(); Bootstrap::defineTables(TABLE_PREFIX); Bootstrap::loadCode(); Bootstrap::i18n_prep(); - -?> diff --git a/setup/cli/modules/cron.php b/include/cli/modules/cron.php similarity index 87% rename from setup/cli/modules/cron.php rename to include/cli/modules/cron.php index 724c06caca04c3fd2e6870c6896052727a3e8431..c2df9458be0e35bfcfb6be5edcf2445019784f15 100644 --- a/setup/cli/modules/cron.php +++ b/include/cli/modules/cron.php @@ -1,6 +1,4 @@ <?php -require_once dirname(__file__) . "/class.module.php"; -require_once dirname(__file__) . "/../cli.inc.php"; class CronManager extends Module { var $prologue = 'CLI cron manager for osTicket'; diff --git a/setup/cli/modules/deploy.php b/include/cli/modules/deploy.php similarity index 99% rename from setup/cli/modules/deploy.php rename to include/cli/modules/deploy.php index c616e321f9a2c5ad253b3e8c52e0d1da6eedce9f..7a795e6630a2e7a521c250fb4a71f0dd54b7db5e 100644 --- a/setup/cli/modules/deploy.php +++ b/include/cli/modules/deploy.php @@ -1,5 +1,4 @@ <?php -require_once dirname(__file__) . "/class.module.php"; require_once dirname(__file__) . "/unpack.php"; class Deployment extends Unpacker { diff --git a/setup/cli/modules/export.php b/include/cli/modules/export.php similarity index 96% rename from setup/cli/modules/export.php rename to include/cli/modules/export.php index a6c45fcee9f0f43de791ea17e2745bef70953dc3..dc7d7ae3a82c806c284587c74e4a1388ddb6f3cc 100644 --- a/setup/cli/modules/export.php +++ b/include/cli/modules/export.php @@ -13,8 +13,6 @@ vim: expandtab sw=4 ts=4 sts=4: **********************************************************************/ -require_once dirname(__file__) . "/class.module.php"; -require_once dirname(__file__) . "../../cli.inc.php"; class Exporter extends Module { var $prologue = diff --git a/setup/cli/modules/file.php b/include/cli/modules/file.php similarity index 99% rename from setup/cli/modules/file.php rename to include/cli/modules/file.php index b1a2f9be697e36f6c837b4584d6a6f5c7eed6735..f3f7991d31ee725dfbac98b725b430a330d71081 100644 --- a/setup/cli/modules/file.php +++ b/include/cli/modules/file.php @@ -1,6 +1,4 @@ <?php -require_once dirname(__file__) . "/class.module.php"; -require_once dirname(__file__) . "/../cli.inc.php"; class FileManager extends Module { var $prologue = 'CLI file manager for osTicket'; diff --git a/setup/cli/modules/i18n.php b/include/cli/modules/i18n.php similarity index 99% rename from setup/cli/modules/i18n.php rename to include/cli/modules/i18n.php index 9d5e6ca4c1fe6af88c246ff7798f3418853e195d..617960cfd5d6d7f2be1ac88327416fcee52994b7 100644 --- a/setup/cli/modules/i18n.php +++ b/include/cli/modules/i18n.php @@ -1,7 +1,5 @@ <?php -require_once dirname(__file__) . "/class.module.php"; -require_once dirname(__file__) . "/../cli.inc.php"; require_once INCLUDE_DIR . 'class.format.php'; class i18n_Compiler extends Module { diff --git a/setup/cli/modules/import.php b/include/cli/modules/import.php similarity index 98% rename from setup/cli/modules/import.php rename to include/cli/modules/import.php index 27bf8962ef8d73880547ad3347c533c1c5ac3cbf..78946919c4f554bc2dd52ff9c62700f2bf02c1c4 100644 --- a/setup/cli/modules/import.php +++ b/include/cli/modules/import.php @@ -13,8 +13,6 @@ vim: expandtab sw=4 ts=4 sts=4: **********************************************************************/ -require_once dirname(__file__) . "/class.module.php"; -require_once dirname(__file__) . "../../cli.inc.php"; require_once INCLUDE_DIR . "class.export.php"; require_once INCLUDE_DIR . 'class.json.php'; diff --git a/setup/cli/modules/list.php b/include/cli/modules/list.php similarity index 96% rename from setup/cli/modules/list.php rename to include/cli/modules/list.php index 33867acba77236c8cb61a6f1752cfcb310f6f4b3..c1c5512d2d659730d3c2296f7e4a12225232cb35 100644 --- a/setup/cli/modules/list.php +++ b/include/cli/modules/list.php @@ -1,6 +1,4 @@ <?php -require_once dirname(__file__) . "/class.module.php"; -require_once dirname(__file__) . "/../cli.inc.php"; include_once INCLUDE_DIR .'class.translation.php'; diff --git a/setup/cli/modules/org.php b/include/cli/modules/org.php similarity index 95% rename from setup/cli/modules/org.php rename to include/cli/modules/org.php index c47e5cd7d628d1638d922e1f28a09ac9cc7599a9..ae2fd79320324fdc1f7ecb6cfeffb7eb9203255f 100644 --- a/setup/cli/modules/org.php +++ b/include/cli/modules/org.php @@ -1,6 +1,4 @@ <?php -require_once dirname(__file__) . "/class.module.php"; -require_once dirname(__file__) . "/../cli.inc.php"; class OrganizationManager extends Module { var $prologue = 'CLI organization manager'; diff --git a/setup/cli/modules/package.php b/include/cli/modules/package.php similarity index 100% rename from setup/cli/modules/package.php rename to include/cli/modules/package.php diff --git a/setup/cli/modules/unpack.php b/include/cli/modules/unpack.php similarity index 99% rename from setup/cli/modules/unpack.php rename to include/cli/modules/unpack.php index cc4b9d9d93a4058bfadab56239fd096540004b71..add4abf5c9d68145aa7187c998ee77ebbb98b022 100644 --- a/setup/cli/modules/unpack.php +++ b/include/cli/modules/unpack.php @@ -1,7 +1,5 @@ <?php -require_once dirname(__file__) . "/class.module.php"; - class Unpacker extends Module { var $prologue = "Unpacks osTicket into target install path"; diff --git a/setup/cli/modules/user.php b/include/cli/modules/user.php similarity index 98% rename from setup/cli/modules/user.php rename to include/cli/modules/user.php index 6fd05f7782eaa1dcf163cb3a3734df08e185ffe7..1504aacd2fcfaba3b423f82147e4a505e3c699eb 100644 --- a/setup/cli/modules/user.php +++ b/include/cli/modules/user.php @@ -1,6 +1,4 @@ <?php -require_once dirname(__file__) . "/class.module.php"; -require_once dirname(__file__) . "/../cli.inc.php"; class UserManager extends Module { var $prologue = 'CLI user manager'; diff --git a/manage.php b/manage.php new file mode 100755 index 0000000000000000000000000000000000000000..37317e7f5cc5c0643de09a92d5a5830ef8141605 --- /dev/null +++ b/manage.php @@ -0,0 +1,84 @@ +#!/usr/bin/env php +<?php +/********************************************************************* + manage.php + + CLI (command line interface) for osTicket management. Use + + php manage.php --help + + for detailed and updated getting started information. + + Jared Hancock <jared@osticket.com> + Copyright (c) 2006-2015 osTicket + http://www.osticket.com + + Released under the GNU General Public License WITHOUT ANY WARRANTY. + See LICENSE.TXT for details. + + vim: expandtab sw=4 ts=4 sts=4: +**********************************************************************/ +if (PHP_SAPI != "cli") + die("Management only supported from command-line\n"); + +require_once 'bootstrap.php'; +require_once CLI_DIR . 'cli.inc.php'; + +if (!function_exists('noop')) { function noop() {} } +session_set_save_handler('noop','noop','noop','noop','noop','noop'); + +class Manager extends Module { + var $prologue = + "Manage one or more osTicket installations"; + + var $arguments = array( + 'action' => "Action to be managed" + ); + + var $usage = '$script action [options] [arguments]'; + + var $autohelp = false; + + function showHelp() { + foreach (glob(CLI_DIR.'modules/*.php') as $script) + include_once $script; + + global $registered_modules; + $this->epilog = + "Currently available modules follow. Use 'manage.php <module> + --help' for usage regarding each respective module:"; + + parent::showHelp(); + + echo "\n"; + ksort($registered_modules); + $width = max(array_map('strlen', array_keys($registered_modules))); + foreach ($registered_modules as $name=>$mod) + echo str_pad($name, $width + 2) . $mod->prologue . "\n"; + } + + function run($args, $options) { + if ($options['help'] && !$args['action']) + $this->showHelp(); + + else { + $action = $args['action']; + + global $argv; + foreach ($argv as $idx=>$val) + if ($val == $action) + unset($argv[$idx]); + + require_once CLI_DIR . "modules/{$args['action']}.php"; + if (($module = Module::getInstance($action))) + return $module->_run($args['action']); + + $this->stderr->write("Unknown action given\n"); + $this->showHelp(); + } + } +} + +$manager = new Manager(); +$manager->parseOptions(); +$manager->_run(basename(__file__)); diff --git a/setup/cli/manage.php b/setup/cli/manage.php index 83d715ac12f87de14aee5aa66bc80140c9bb44f6..d2ae92b5a22eb59a16700e5dc5fac1692d9b200a 100755 --- a/setup/cli/manage.php +++ b/setup/cli/manage.php @@ -1,66 +1,3 @@ -#!/usr/bin/env php <?php -require_once "modules/class.module.php"; - -if (!function_exists('noop')) { function noop() {} } -session_set_save_handler('noop','noop','noop','noop','noop','noop'); - -class Manager extends Module { - var $prologue = - "Manage one or more osTicket installations"; - - var $arguments = array( - 'action' => "Action to be managed" - ); - - var $usage = '$script action [options] [arguments]'; - - var $autohelp = false; - - function showHelp() { - foreach (glob(dirname(__file__).'/modules/*.php') as $script) - include_once $script; - - global $registered_modules; - $this->epilog = - "Currently available modules follow. Use 'manage.php <module> - --help' for usage regarding each respective module:"; - - parent::showHelp(); - - echo "\n"; - foreach ($registered_modules as $name=>$mod) - echo str_pad($name, 20) . $mod->prologue . "\n"; - } - - function run($args, $options) { - if ($options['help'] && !$args['action']) - $this->showHelp(); - - else { - $action = $args['action']; - - global $argv; - foreach ($argv as $idx=>$val) - if ($val == $action) - unset($argv[$idx]); - - require_once dirname(__file__)."/modules/{$args['action']}.php"; - if (($module = Module::getInstance($action))) - return $module->_run($args['action']); - - $this->stderr->write("Unknown action given\n"); - $this->showHelp(); - } - } -} - -if (php_sapi_name() != "cli") - die("Management only supported from command-line\n"); - -$manager = new Manager(); -$manager->parseOptions(); -$manager->_run(basename(__file__)); - -?> +include dirname(__file__) . '/../../manage.php'; diff --git a/setup/doc/i18n.md b/setup/doc/i18n.md index 92409a0ded3d22ccd9c03050bb2d72e71c373a53..bc995667d8442b2ac8769ebf4bfb86ff9d1e204a 100644 --- a/setup/doc/i18n.md +++ b/setup/doc/i18n.md @@ -110,7 +110,7 @@ comments can be used. For instance: Use the command line to compile the POT file to standard out - php setup/cli/manage.php i18n make-pot > message.pot + php manage.php i18n make-pot > message.pot ### Building language packs diff --git a/setup/doc/package.md b/setup/doc/package.md index 5570bb60931b910e3281e29ee5d326c938f6eae7..c9c3f0eca350dfde0540f892ce6bea66d2d0d941 100644 --- a/setup/doc/package.md +++ b/setup/doc/package.md @@ -11,11 +11,11 @@ being added to the distribution. More information is available via the automated help output. - php setup/cli/manage.php package --help + php manage.php package --help Creating the ZIP file --------------------- To package the system using the defaults (as a ZIP file), just invoke the packager with no other options. - php setup/cli/manage.php package + php manage.php package