Page 1 of 1
Custom Installer
Posted: Fri Jan 06, 2006 4:54 am
by axelseaa
I am trying to take the simple installation (minus the db section) and create a simple page for users to install from. This is a multisite install.
I'm having trouble figuring out what information has to be included into my script from s9y for this to work properly. So far i have the following:
Code: Select all
define('IN_installer', true);
define('IN_upgrader', true);
define('IN_serendipity', true);
define('IN_serendipity_admin', true);
define('S9Y_INCLUDE_PATH', '/usr/local/lib/s9y/');
require_once('/usr/local/lib/s9y/serendipity_config.inc.php');
require_once('/usr/local/lib/s9y/include/db/db.inc.php');
require_once('/usr/local/lib/s9y/include/functions_permalinks.inc.php');
require_once('/usr/local/lib/s9y/include/functions_installer.inc.php');
require_once('/usr/local/lib/s9y/include/functions_config.inc.php');
Am I on the right path?
Re: Custom Installer
Posted: Fri Jan 06, 2006 9:46 am
by garvinhicking
Hi axel!
You can only include the db/db.inc.php file if you specified all the serendipity[dbprefix, dbuser etc.] parameters; did you do that?
I'd also suggest tojust include the include/finctions.inc.php file which includes all the other files; apartfrom that, yes,you're on the right track:)
regards,
Garvin
Posted: Fri Jan 06, 2006 2:46 pm
by Guest
Here is what i currently have:
Code: Select all
define('IN_installer', true);
define('IN_upgrader', true);
define('IN_serendipity', true);
define('IN_serendipity_admin', true);
define('S9Y_INCLUDE_PATH', '/usr/local/lib/s9y/');
$serendipity['dbType'] = 'mysql';
$serendipity['dbHost'] = 'localhost';
$serendipity['dbUser'] = $dbInfo[1]; //generated above
$serendipity['dbPass'] = $dbInfo[2]; //generated above
$serendipity['dbName'] = $dbInfo[0]; //generated above
$serendipity['dbPrefix'] = 'serendipity_';
$serendipity['dbPersistent'] = false;
require_once('/usr/local/lib/s9y/include/functions.inc.php');
require_once('/usr/local/lib/s9y/include/db/db.inc.php');
It seems to work a little better just including the functions. Thanks!
Are there any other core serendipity variables that I will need to set that I overlooked? All the other aspects of the simple install come in from the form on the page before this script.
Posted: Tue Jan 10, 2006 12:39 am
by axelseaa
I pretty much got it. Except the config values are not being populated in the database, and when i try to load the blog i get the following error:
Code: Select all
Warning: Smarty error: unable to read resource: "" in /usr/local/lib/s9y/bundled-libs/Smarty/libs/Smarty.class.php on line 1088
I've got to be missing something. The script i'm using is below:
Code: Select all
define('IN_installer', true);
define('IN_upgrader', true);
define('IN_serendipity', true);
define('IN_serendipity_admin', true);
define('IS_installed', false);
define('S9Y_INCLUDE_PATH', '/usr/local/lib/s9y/');
$serendipity['dbType'] = 'mysql';
require_once('/usr/local/lib/s9y/include/functions.inc.php');
require_once('/usr/local/lib/s9y/serendipity_config.inc.php');
$serendipity['dbType'] = 'mysql';
$serendipity['dbHost'] = 'localhost';
$serendipity['dbUser'] = $dbInfo[1];
$serendipity['dbPass'] = $dbInfo[2];
$serendipity['dbName'] = $dbInfo[0];
$serendipity['dbPrefix'] = 'serendipity_';
$serendipity['dbPersistent'] = false;
$serendipity['version'] = $app->getVersion();
$serendipity['serendipityPath'] = "/home/".$_SESSION['username']."/".$domain->getDomain()."/docs/$dirName";
$serendipityPath = "/home/".$_SESSION['username']."/".$domain->getDomain()."/docs/$dirName";
/*
* Attempt to connect to the database
*/
if (!serendipity_db_connect()) {
serendipity_die(DATABASE_ERROR);
}
echo CHECK_DATABASE_EXISTS .'...';
echo "SELECT * FROM {$serendipity['dbPrefix']}authors";
$t = serendipity_db_query("SELECT * FROM {$serendipity['dbPrefix']}authors", false, 'both', false, false, false, true);
if ( is_array($t) ) {
echo ' <strong>'. THEY_DO .'</strong>, '. WONT_INSTALL_DB_AGAIN;
echo '<br />';
echo '<br />';
} else {
echo ' <strong>'. THEY_DONT .'</strong>';
echo '<br />';
echo CREATE_DATABASE;
serendipity_installDatabase();
echo ' <strong>' . DONE . '</strong><br />';
echo sprintf(CREATING_PRIMARY_AUTHOR, $_POST['user']) .'...';
$authorid = serendipity_addAuthor($_POST['user'], $_POST['pass'], $_POST['realname'],$_POST['email'], USERLEVEL_ADMIN);
$mail_comments = (serendipity_db_bool($_POST['want_mail']) ? 1 : 0);
serendipity_set_user_var('mail_comments', $mail_comments, $authorid);
serendipity_set_user_var('mail_trackbacks', $mail_comments, $authorid);
serendipity_set_user_var('right_publish', 1, $authorid);
serendipity_addDefaultGroup('USERLEVEL_EDITOR_DESC', USERLEVEL_EDITOR);
serendipity_addDefaultGroup('USERLEVEL_CHIEF_DESC', USERLEVEL_CHIEF);
serendipity_addDefaultGroup('USERLEVEL_ADMIN_DESC', USERLEVEL_ADMIN);
echo ' <strong>' . DONE . '</strong><br />';
echo SETTING_DEFAULT_TEMPLATE .'... ';
serendipity_set_config_var('template', $serendipity['defaultTemplate']);
echo ' <strong>' . DONE . '</strong><br />';
echo INSTALLING_DEFAULT_PLUGINS .'... ';
include_once S9Y_INCLUDE_PATH . 'include/plugin_api.inc.php';
serendipity_plugin_api::register_default_plugins();
echo ' <strong>' . DONE . '</strong><br />';
}
$errors = serendipity_installFiles($basedir);
if ( $errors === true ) {
echo ' <strong>' . DONE . '</strong><br />';
} else {
echo ' <strong>' . FAILED . '</strong><br />';
foreach ( $errors as $error ) {
echo '<div class="serendipityAdminMsgError">'. $error .'</div>';
}
}
// This can't actuall write the file, but it appears to popular the config options
if ( serendipity_updateConfiguration() ) {
echo '<div class="serendipityAdminMsgSuccess">'. SERENDIPITY_INSTALLED .'</div>';
echo '<div align="center">'. THANK_YOU_FOR_CHOOSING .'</div>';
} else {
echo '<div class="serendipityAdminMsgSuccess">'. ERROR_DETECTED_IN_INSTALL .'</div>';
}
// Write .htaccess file
$s9y->writeHtaccess($serendipityPath,$dirName);
// Call function to write config
$s9y->writeConfig($serendipity['dbName'],$serendipity['dbPrefix'],$serendipity['dbHost'],
$serendipity['dbUser'],$serendipity['dbPass'],$serendipity['dbType'],$serendipity['dbPersistent'],
$serendipity['version'],$serendipityPath);
PHP is running under cgi, so the script doesnt actually have premissions to write the files, so that is why I called the two functions i created at the bottom to create the files with the proper permissions
Posted: Tue Jan 10, 2006 12:47 pm
by garvinhicking
The Smarty error comes from the "templates_c" directory not being existant or writable!
The second problem of config values: You must store the config values on your own. That's what the previous serendipity install steps are for: Those read the include/tpl/config_local.inc.php file and offer the installation config values, put them into one large POST array, which is evaluated in the installer page. Check how the referring functions sometimes acces $serendipity['POST'].
So you'll need to insert the required config values on your own; basically you should be able to use the serendipity config parsing functions for that; just have a look at the include/functions_installer and include/admin/installer.inc.php files, on how they use parsing calls?
HTH,
Garvin