Index: trunk/bin/_config.inc.php
===================================================================
--- trunk/bin/_config.inc.php	(revision 532)
+++ trunk/bin/_config.inc.php	(revision 532)
@@ -0,0 +1,90 @@
+<?php
+/*
+* The Strangecode Codebase - a general application development framework for PHP
+* For details visit the project site: <http://trac.strangecode.com/>
+* Copyright Â© 2015 Strangecode, LLC
+*
+* This program is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/*
+* Small config file for cli scripts in the codebase/bin directory.
+*
+* @author   Quinn Comendant <quinn@strangecode.com>
+* @version  1.0
+* @since    12 Jul 2015 22:48:13
+*/
+
+$this_script = basename($_SERVER['argv'][0]);
+
+// Assume execution occurs while in the common app directory.
+define('COMMON_BASE', realpath('.'));
+$db_auth_file = false;
+$rii = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(COMMON_BASE));
+$rii->setMaxDepth(2);
+foreach ($rii as $filename => $file) {
+    if (in_array(basename($filename), ['db_auth.inc.php', 'db_auth.json'])) {
+        $db_auth_file = $filename;
+        break;
+    }
+}
+if (!$db_auth_file) {
+    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));
+}
+if (fileowner($db_auth_file) != getmyuid()) {
+    die(sprintf("%s error: you must execute this script as the owner of the web files.\n", $this_script));
+}
+
+// Set include path.
+ini_set('include_path', get_include_path() . PATH_SEPARATOR . COMMON_BASE);
+
+/********************************************************************
+* CONFIG
+********************************************************************/
+
+// Include core libraries.
+require_once 'codebase/lib/App.inc.php';
+require_once 'codebase/lib/Utilities.inc.php';
+
+define('_CLI', true);
+$app =& App::getInstance('codebase');
+$app->setParam(array(
+    'site_name' => 'codebase',
+    'site_email' => 'codebase@strangecode.com',
+    'enable_session' => false,
+    'enable_db' => true,
+    'db_create_tables' => true,
+    'db_auth_file' => $db_auth_file,
+    'db_always_debug' => false,
+    'db_debug' => true,
+    'db_die_on_failure' => true,
+    'display_errors' => true,
+    'error_reporting' => E_ALL,
+    'log_file_priority' => false,
+    'log_screen_priority' => LOG_INFO,
+    'log_directory' => COMMON_BASE . '/log',
+    'log_filename' => 'site_log',
+));
+
+if (strtolower(getFilenameExtension($db_auth_file)) != 'json') {
+    // DB auth file is not json, and will not be automaticlaly be loaded by $app's 'db_auth_file' parser.
+    require_once $db_auth_file;
+}
+
+// Start application-based functionality: database, session, environment, ini setup, etc.
+// Most configuration parameters must be set before starting the App.
+$app->start();
+
+// Global DB object. Automatically pre-configured by $app->start().
+$db =& DB::getInstance();
Index: trunk/bin/acl.cli.php
===================================================================
--- trunk/bin/acl.cli.php	(revision 523)
+++ trunk/bin/acl.cli.php	(revision 532)
@@ -1,3 +1,3 @@
-#!/usr/bin/php
+#!/usr/bin/env php
 <?php
 /**
@@ -26,14 +26,13 @@
 *
 * @author   Quinn Comendant <quinn@strangecode.com>
-* @version  1.0
+* @version  1.1
 * @since    14 Jun 2006 23:10:45
 */
 
-
 /********************************************************************
-* STARTUP
+* CONFIG
 ********************************************************************/
 
-$this_script = basename($_SERVER['argv'][0]);
+require_once dirname(__FILE__) . '/_config.inc.php';
 
 // Give them a fighting chance. Show the help message. ;P
@@ -41,59 +40,4 @@
     help();
 }
-
-// Make sure necessary files exist.
-define('COMMON_BASE', realpath('.'));
-$db_auth_file = false;
-$rii = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(COMMON_BASE));
-$rii->setMaxDepth(2);
-foreach ($rii as $filename => $file) {
-    if (mb_strpos($filename, 'db_auth.inc.php') !== false) {
-        $db_auth_file = $filename;
-        break;
-    }
-}
-if (!$db_auth_file) {
-    die(sprintf("%s error: the current directory must be common site directory (i.e. the parent directory of the document root) AND the db_auth.inc.php file must exist.\n", $this_script));
-}
-if (fileowner($db_auth_file) != getmyuid()) {
-    die(sprintf("%s error: you must execute this script as the owner of the web files.\n", $this_script));
-}
-
-// Set include path.
-ini_set('include_path', get_include_path() . PATH_SEPARATOR . COMMON_BASE);
-
-/********************************************************************
-* CONFIG
-********************************************************************/
-
-// Include core libraries.
-require_once 'codebase/lib/App.inc.php';
-require_once 'codebase/lib/Utilities.inc.php';
-
-define('_CLI', true);
-$app =& App::getInstance('module_maker');
-$app->setParam(array(
-    'site_name' => 'ACL cli',
-    'site_email' => 'codebase@strangecode.com',
-    'enable_session' => false,
-    'enable_db' => true,
-    'db_always_debug' => false,
-    'db_debug' => true,
-    'db_die_on_failure' => true,
-    'display_errors' => true,
-    'error_reporting' => E_ALL,
-    'log_file_priority' => LOG_INFO,
-    'log_screen_priority' => LOG_ERR,
-    'log_directory' => COMMON_BASE . '/log',
-    'log_filename' => 'site_log',
-));
-require_once $db_auth_file;
-
-// Start application-based functionality: database, session, environment, ini setup, etc.
-// Most configuration parameters must be set before starting the App.
-$app->start();
-
-// Global DB object. Automatically pre-configured by $app->start().
-$db =& DB::getInstance();
 
 // ACL!
Index: trunk/bin/init_codebase_tables.cli.php
===================================================================
--- trunk/bin/init_codebase_tables.cli.php	(revision 532)
+++ trunk/bin/init_codebase_tables.cli.php	(revision 532)
@@ -0,0 +1,160 @@
+#!/usr/bin/env php
+<?php
+/*
+* The Strangecode Codebase - a general application development framework for PHP
+* For details visit the project site: <http://trac.strangecode.com/>
+* Copyright Â© 2015 Strangecode, LLC
+*
+* This program is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/*
+* Initialize tables managed by Codebase classes.
+*
+* @author   Quinn Comendant <quinn@strangecode.com>
+* @version  1.0
+* @since    12 Jul 2015 22:44:58
+*/
+
+/********************************************************************
+* CONFIG
+********************************************************************/
+
+require_once dirname(__FILE__) . '/_config.inc.php';
+require_once 'codebase/lib/ACL.inc.php';
+require_once 'codebase/lib/Auth_SQL.inc.php';
+require_once 'codebase/lib/Lock.inc.php';
+require_once 'codebase/lib/Prefs.inc.php';
+require_once 'codebase/lib/Version.inc.php';
+
+/********************************************************************
+* MAIN
+********************************************************************/
+
+// Process command line options.
+$opt = getopt('fh');
+
+// Get class name.
+$class = strtolower(end($_SERVER['argv']));
+
+// Give them a fighting chance. Show the help message.
+if ($_SERVER['argc'] <= 1 || isset($opt['h'])) {
+    help();
+    exit(1);
+}
+
+if ('all' == $class) {
+    initClassDB('acl');
+    initClassDB('auth');
+    initClassDB('lock');
+    initClassDB('prefs');
+    initClassDB('version');
+} else {
+    initClassDB($class);
+}
+
+
+/********************************************************************
+* FUNCTIONS
+********************************************************************/
+
+/*
+*
+*
+* @access   public
+* @param
+* @return
+* @author   Quinn Comendant <quinn@strangecode.com>
+* @version  1.0
+* @since    12 Jul 2015 23:16:02
+*/
+function help()
+{
+    global $this_script;
+    ?>
+This script initializes DB tables managed by Codebase classes.
+
+Usage: <?php echo $this_script; ?> [OPTIONS] CLASSNAME
+
+OPTIONS
+
+    -f  Force recreation of tables, if they already exist.
+    -h  Show this help message.
+
+CLASSNAME is one of:
+
+    all         Special case: create tables for all classes.
+    acl         Create tables for ACL
+    auth        Create tables for Auth_SQL
+    lock        Create tables for Lock
+    prefs       Create tables for Prefs
+    version     Create tables for Version
+<?php
+}
+
+/*
+*
+*
+* @access   public
+* @param
+* @return
+* @author   Quinn Comendant <quinn@strangecode.com>
+* @version  1.0
+* @since    12 Jul 2015 23:25:35
+*/
+function initClassDB($class)
+{
+    global $opt;
+
+    switch ($class) {
+        case 'acl':
+            // ACL!
+            $acl =& ACL::getInstance();
+            $acl->setParam(array('create_table' => true));
+            $acl->initDB(isset($opt['f']));
+            break;
+
+        case 'auth':
+            // Auth_SQL!
+            $auth = new Auth_SQL('codebase');
+            $auth->setParam(array('create_table' => true));
+            $auth->initDB(isset($opt['f']));
+            break;
+
+        case 'lock':
+            // Lock!
+            $lock =& Lock::getInstance(new Auth_SQL('codebase'));
+            $lock->setParam(array('create_table' => true));
+            $lock->initDB(isset($opt['f']));
+            break;
+
+        case 'prefs':
+            // Prefs!
+            $prefs = new Prefs('codebase');
+            $prefs->setParam(array('create_table' => true));
+            $prefs->initDB(isset($opt['f']));
+            break;
+
+        case 'version':
+            // Version!
+            $version = Version::getInstance(new Auth_SQL('codebase'));
+            $version->setParam(array('create_table' => true));
+            $version->initDB(isset($opt['f']));
+            break;
+
+        default:
+            echo "The class $class is not setup to initClassDB.\n";
+            exit(1);
+    }
+}
