diff --git a/utils/Commands/UploadextensionCommand.php b/utils/Commands/UploadextensionCommand.php new file mode 100644 index 000000000..65a75817f --- /dev/null +++ b/utils/Commands/UploadextensionCommand.php @@ -0,0 +1,77 @@ +settings = $settings; + $this->logger = $logger; + $this->translator = $translator; + $this->extmgr = $extmgr; + parent::__construct(); + } + + protected function configure() + { + $this->setName('ext:upload') + ->setDescription('Upload extension') + ->setHelp('Uploads an extensions, which replaces an exiting extension or inserts a new extension.') + ->addOption('file', '', InputOption::VALUE_REQUIRED, 'Filename of zipped extension.', null) + ; + } + + protected function execute(InputInterface $input, OutputInterface $output) : int + { + $settings = $this->settings; + $logger = $this->logger; + $translator = $this->translator; + $extmgr = $this->extmgr; + + $output->writeln("Using configuration from '".$settings->_configFilePath."'.", OutputInterface::VERBOSITY_VERBOSE); + + if (!is_writable($settings->_configFilePath)) { + $output->writeln(sprintf("The configuration file '%s' is not writable by the system user running this script.", $settings->_configFilePath)); + return Command::FAILURE; + } + + if (!is_writable($settings->_cacheDir)) { + $output->writeln(sprintf("The cache dir '%s' is not writable for the system user running this script.", $settings->_cacheDir)); + return Command::FAILURE; + } + + if (!$extmgr->updateExtension($filename)) { + foreach ($extmgr->getErrorMsgs() as $msg) { + $output->writeln(sprintf("%s", $msg)); + } + return Command::FAILURE; + } + + return Command::SUCCESS; + } +} + +// vim: ts=4 sw=4 expandtab diff --git a/utils/console b/utils/console index ccd021a4a..4e1581f1d 100755 --- a/utils/console +++ b/utils/console @@ -16,6 +16,7 @@ use Seeddms\Console\Commands\ClearcacheCommand; use Seeddms\Console\Commands\ListcacheCommand; use Seeddms\Console\Commands\ListextensionCommand; use Seeddms\Console\Commands\ConfigureextensionCommand; +use Seeddms\Console\Commands\UploadextensionCommand; use Seeddms\Console\Commands\PackageextensionCommand; use Seeddms\Console\Commands\ReloadextensionCommand; use Seeddms\Seeddms\Settings; @@ -42,6 +43,7 @@ $application->add(new ClearcacheCommand($settings, $logger, $translator)); $application->add(new ListcacheCommand($settings, $logger, $translator)); $application->add(new ListextensionCommand($settings, $logger, $translator, $extmgr)); $application->add(new ConfigureextensionCommand($settings, $logger, $translator, $extmgr)); +$application->add(new UploadextensionCommand($settings, $logger, $translator, $extmgr)); $application->add(new PackageextensionCommand($settings, $logger, $translator, $extmgr)); $application->add(new ReloadextensionCommand($settings, $logger, $translator, $extmgr));