Changeset 533 for trunk/bin


Ignore:
Timestamp:
Jul 13, 2015 8:48:29 PM (9 years ago)
Author:
anonymous
Message:

Adapted module maker scripts to use the new cli config file. Updated config to load codebase classes from its own codebase dir.

Location:
trunk/bin
Files:
1 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/bin/_config.inc.php

    r532 r533  
    2727*/
    2828
    29 $this_script = basename($_SERVER['argv'][0]);
     29// The name of the CLI.
     30$cli_executed = basename($_SERVER['argv'][0]);
    3031
    31 // Assume execution occurs while in the common app directory.
    32 define('COMMON_BASE', realpath('.'));
     32// Enforce "relaxed" directory location, if set by the called script.
     33// This script can be executed in any directory that is an ancestor 2 directories above the db_auth file.
     34if (!defined('COMMON_BASE')) {
     35    define('COMMON_BASE', realpath('.'));
     36}
     37
     38// Use codebase files releative to this file.
     39define('CODEBASE_PATH', realpath(dirname(__FILE__) . '/../'));
     40
    3341$db_auth_file = false;
    3442$rii = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(COMMON_BASE));
     
    4149}
    4250if (!$db_auth_file) {
    43     die(sprintf("%s error: the current directory must be common site directory (i.e. the parent directory of the document root) AND a db_auth file must exist within two directory levels.\n", $this_script));
     51    die(sprintf("%s error: the current directory must be common site directory (i.e. the parent directory of the document root) AND a db_auth file must exist within two directory levels.\n", $cli_executed));
    4452}
    4553if (fileowner($db_auth_file) != getmyuid()) {
    46     die(sprintf("%s error: you must execute this script as the owner of the web files.\n", $this_script));
     54    die(sprintf("%s error: you must execute this script as the owner of the web files.\n", $cli_executed));
    4755}
    4856
     
    5563
    5664// Include core libraries.
    57 require_once 'codebase/lib/App.inc.php';
    58 require_once 'codebase/lib/Utilities.inc.php';
     65require_once CODEBASE_PATH . '/lib/App.inc.php';
     66require_once CODEBASE_PATH . '/lib/Utilities.inc.php';
    5967
    6068define('_CLI', true);
     
    7482    'log_file_priority' => false,
    7583    'log_screen_priority' => LOG_INFO,
    76     'log_directory' => COMMON_BASE . '/log',
     84    'log_directory' => '/tmp',
    7785    'log_filename' => 'site_log',
    7886));
  • trunk/bin/acl.cli.php

    r532 r533  
    4242
    4343// ACL!
    44 require_once 'codebase/lib/ACL.inc.php';
     44require_once CODEBASE_PATH . '/lib/ACL.inc.php';
    4545$acl =& ACL::getInstance();
    4646$acl->setParam(array('create_table' => false));
     
    181181function help()
    182182{
    183     global $this_script;
     183    global $cli_executed;
    184184
    185185    ?>
     
    210210implying access to any object of that type.
    211211
    212 Usage: <?php echo $this_script; ?> command [args]
     212Usage: <?php echo $cli_executed; ?> command [args]
    213213
    214214Where command is any of the following (with arguments):
     
    255255    $app =& App::getInstance();
    256256    $db =& DB::getInstance();
    257     global $this_script;
    258257
    259258    echo "\n";
     
    314313    $app =& App::getInstance();
    315314    $db =& DB::getInstance();
    316     global $this_script;
    317315
    318316    // Retrieve access value from db.
  • trunk/bin/init_codebase_tables.cli.php

    r532 r533  
    3333
    3434require_once dirname(__FILE__) . '/_config.inc.php';
    35 require_once 'codebase/lib/ACL.inc.php';
    36 require_once 'codebase/lib/Auth_SQL.inc.php';
    37 require_once 'codebase/lib/Lock.inc.php';
    38 require_once 'codebase/lib/Prefs.inc.php';
    39 require_once 'codebase/lib/Version.inc.php';
     35require_once CODEBASE_PATH . '/lib/ACL.inc.php';
     36require_once CODEBASE_PATH . '/lib/Auth_SQL.inc.php';
     37require_once CODEBASE_PATH . '/lib/Lock.inc.php';
     38require_once CODEBASE_PATH . '/lib/Prefs.inc.php';
     39require_once CODEBASE_PATH . '/lib/Version.inc.php';
    4040
    4141/********************************************************************
     
    5454    exit(1);
    5555}
     56
     57$app->logMsg(sprintf('Running initDB on %s codebase tables in db %s', $class, $db->getParam('db_name')), LOG_INFO, __FILE__, __LINE__);
    5658
    5759if ('all' == $class) {
     
    8284function help()
    8385{
    84     global $this_script;
     86    global $cli_executed;
    8587    ?>
    86 This script initializes DB tables managed by Codebase classes.
     88This script initializes DB tables managed by Codebase classes. If database schema is changed a log message will display.
    8789
    88 Usage: <?php echo $this_script; ?> [OPTIONS] CLASSNAME
     90Usage: <?php echo $cli_executed; ?> [OPTIONS] CLASSNAME
    8991
    9092OPTIONS
  • trunk/bin/module_maker/form_template.cli.php

    r523 r533  
    2626 */
    2727
    28 include_once dirname(__FILE__) . '/_config.inc.php';
     28if ($_SERVER['argc'] > 1 && isset($_SERVER['argv'][1]) && '' != $_SERVER['argv'][1] && is_dir($_SERVER['argv'][1])) {
     29    // First arg is path to current site. Realpath removes trailing /s
     30    define('COMMON_BASE', realpath($_SERVER['argv'][1]));
     31} else {
     32    die("Error: First argument must be the directory path to an existing site (ex: /home/sc/www.strangecode.com).\n");
     33}
     34
     35include_once dirname(__FILE__) . '/../_config.inc.php';
    2936
    3037// Test arguments.
  • trunk/bin/module_maker/list_template.cli.php

    r468 r533  
    2626 */
    2727
    28 include_once dirname(__FILE__) . '/_config.inc.php';
     28if ($_SERVER['argc'] > 1 && isset($_SERVER['argv'][1]) && '' != $_SERVER['argv'][1] && is_dir($_SERVER['argv'][1])) {
     29    // First arg is path to current site. Realpath removes trailing /s
     30    define('COMMON_BASE', realpath($_SERVER['argv'][1]));
     31} else {
     32    die("Error: First argument must be the directory path to an existing site (ex: /home/sc/www.strangecode.com).\n");
     33}
     34
     35include_once dirname(__FILE__) . '/../_config.inc.php';
    2936
    3037$op = null;
  • trunk/bin/module_maker/module.cli.php

    r500 r533  
    2626 */
    2727
    28 include_once dirname(__FILE__) . '/_config.inc.php';
     28if ($_SERVER['argc'] > 1 && isset($_SERVER['argv'][1]) && '' != $_SERVER['argv'][1] && is_dir($_SERVER['argv'][1])) {
     29    // First arg is path to current site. Realpath removes trailing /s
     30    define('COMMON_BASE', realpath($_SERVER['argv'][1]));
     31} else {
     32    die("Error: First argument must be the directory path to an existing site (ex: /home/sc/www.strangecode.com).\n");
     33}
     34
     35include_once dirname(__FILE__) . '/../_config.inc.php';
    2936
    3037$op = null;
  • trunk/bin/module_maker/sql.cli.php

    r468 r533  
    2626 */
    2727
    28 include_once dirname(__FILE__) . '/_config.inc.php';
     28if ($_SERVER['argc'] > 1 && isset($_SERVER['argv'][1]) && '' != $_SERVER['argv'][1] && is_dir($_SERVER['argv'][1])) {
     29    // First arg is path to current site. Realpath removes trailing /s
     30    define('COMMON_BASE', realpath($_SERVER['argv'][1]));
     31} else {
     32    die("Error: First argument must be the directory path to an existing site (ex: /home/sc/www.strangecode.com).\n");
     33}
     34
     35include_once dirname(__FILE__) . '/../_config.inc.php';
    2936
    3037$op = null;
  • trunk/bin/module_maker/validation.cli.php

    r468 r533  
    55 * For details visit the project site: <http://trac.strangecode.com/codebase/>
    66 * Copyright 2001-2012 Strangecode, LLC
    7  * 
     7 *
    88 * This file is part of The Strangecode Codebase.
    99 *
     
    1212 * Free Software Foundation, either version 3 of the License, or (at your option)
    1313 * any later version.
    14  * 
     14 *
    1515 * The Strangecode Codebase is distributed in the hope that it will be useful, but
    1616 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1717 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
    1818 * details.
    19  * 
     19 *
    2020 * You should have received a copy of the GNU General Public License along with
    2121 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>.
     
    2626 */
    2727
    28 include_once dirname(__FILE__) . '/_config.inc.php';
     28if ($_SERVER['argc'] > 1 && isset($_SERVER['argv'][1]) && '' != $_SERVER['argv'][1] && is_dir($_SERVER['argv'][1])) {
     29    // First arg is path to current site. Realpath removes trailing /s
     30    define('COMMON_BASE', realpath($_SERVER['argv'][1]));
     31} else {
     32    die("Error: First argument must be the directory path to an existing site (ex: /home/sc/www.strangecode.com).\n");
     33}
     34
     35include_once dirname(__FILE__) . '/../_config.inc.php';
    2936
    3037// Test arguments.
Note: See TracChangeset for help on using the changeset viewer.