/usr/bin/sesha-add-stock is in php-horde-sesha 1.0.0~beta1-4.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | #!/usr/bin/env php
<?php
/**
* This script adds data into the sesha inventory.
*
* Copyright 2012 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (GPL). If you
* did not receive this file, see http://www.horde.org/licenses/gpl.
*
* @author Ralf Lang <lang@b1-systems.de>
*/
if (file_exists(__DIR__ . '/../../sesha/lib/Application.php')) {
$baseDir = __DIR__ . '/../';
} else {
require_once 'PEAR/Config.php';
$baseDir = PEAR_Config::singleton()
->get('horde_dir', null, 'pear.horde.org') . '/sesha/';
}
require_once $baseDir . 'lib/Application.php';
Horde_Registry::appInit('sesha', array('cli' => true));
// Read command line parameters.
if (count($argv) < 4 || count($argv) > 6) {
$cli->message('Too many or too few parameters.', 'cli.error');
usage();
}
list($script, $name, $categories, $description, $attributes) = $argv;
/* Currently we only support one category per item added with this script */
if (!is_array($categories)) {
$categories = array($categories);
}
$driver = $GLOBALS['injector']->getInstance('Sesha_Factory_Driver')->create();
/* Find the categories */
$categoryList = $driver->getCategories(null, $categories);
if ($categoryList->count() == 0) {
$GLOBALS['cli']->message(_('Could not find the requested categories'), 'cli.error');
exit;
}
$properties = array();
foreach ($categoryList as $category) {
foreach ($category->properties as $property) {
$properties[] = $property;
}
print $category->hasRelation('properties', $properties[0]);
}
$cli->message($name, 'cli.success');
function usage()
{
$GLOBALS['cli']->writeln('Usage: sesha-add-stock "name" "category" "description" "prop1:val1,prop2:val2"');
exit;
}
|