An Installatron installer is comprised of several files and directories, placed in the Installatron's installer directory:
/var/installatron/installers/installerid/
init.xml // information about the installer and the script
locale_en.php // the default (english) locale file
button.gif // a button image for the script
logo.gif // a logo image for the scriptversion1/ // a version sub-directory
LICENSE // license agreement for this version (optional)
init.xml // information for this version
install.php // install code for this versionversion2/ // another version sub-directory (optional)
LICENSE
init.xml
install.php
upgrade.php // upgrade code for upgrading to this version (optional)
installerid is the unique lowercase-alphanumeric id of the installer.
version1, version2, etc are the versions (eg. "2.1.0p1", "2.1.1", etc).
Creating an Installer
The easiest way to create an Installatron installer is to use the Installer Maker/Editor tool. This tool creates a basic template and has a GUI for editing most of the commonly used installer features.
The editor must be used if your server uses PHP4, however if your server uses PHP5 then you also have the option of creating the installer by hand. (TIP: all editing is done in PHP5 format, but the editor automatically compiles a PHP4 version.)
See the SDK: Variables, Commands, and How-Tos page for a closer look at the things you can use in an installer, the SDK: Using an Installer page for information on adding the installer to your server, or click on the headers before for a closer look at each file and directory in an Installatron installer:
The installer id is lowercase alphanumeric key that must be unique to the installer. Usually these are named after the script being installed, so for example the id for the phpBB installer is phpbb.
build_number is the current build number of the installer. Increment this number whenever the installer is edited.
_installer_installerid_* are references to locale entries. You can use plain text here if you don't want to use the locale file.
url_to_* are all optional, though users do like to see at least a website link for the script.
version1, version2, etc are the versions (eg. "2.1.0p1", "2.1.1", etc), with the newest version at the top. If upgrading is not supported then there will be a single version in this area.
upgrade types, in the versions section, can be: none (cannot upgrade to this version), manual (can only upgrade manually to this version), auto (auto-upgrading is supported by the installer), or skip (auto-upgrading is supported by the installer, and this version can be skipped over if upgrading to a later version).
install types, in the versions section, can be: none (cannot install this version), auto (auto-installing is supported by the installer).
There is one version/ directory for each version of the script that is supported by the installer. If the installer installs a single version, or does not support upgrading, then there will be a single version directory. The version should have no spaces, and should only use characters that can be used in a directory name.
version is this version of the script (eg. "2.1.0p1").
license_type can be any text, or a reference to the script's locale file, or the global locale keys: _scripts_license_free or _scripts_license_opensource
default_directory_name is an optional default install directory name. If not present, the default directory when installing the script will be the installerid.
All links are optional, and all are relative to the install directory. admin adds an [admin] button to the Installed Scripts page and is a link to an "administration" page. config is the same except it is for a [config] button. edit-1, edit-2, etc are files that can be edited inside Installatron (for templates or config files that can't be edited through the script itself).
requirements are all optional. Leave empty if the script doesn't have a specific requirement.
archives is used to register archives for this version of the script. The "main" archive is required and "xtra1", "xtra2", etc are optional. The archive_type can be either: zip or tar.gzmd5_value is an optional md5 value for the archives, which is used by Installatron to check that the archive downloaded correctly. Editor automatically adds an md5 value when saving from the Version Info tab, if no md5 value is already present.
The install.php file installs this version of the script.
The install process is comprised of steps, and each step is comprised of an _init (configures the page for the step), and a _process (performs actions).
Step 1 is always a "settings collection" page. This is where the user selects a location for the install and database values if required by the script. You can optionally use the step1_init() to add Custom Inputs, to collect things like passwords and email addresses, which can then be used in a later step to configure the install. The step1_process() can be used to error-check values collected from step1_init().
Step 2 is usually used to extract the "main" archive (see the version/init.xml file above).
Step 4 is usually used as the main processing step. Here it CHMODS, moves and edits files, populates a database if the script uses one, and so on.
Step 5 can be used as an optional External Task, and then Step 6 would be for final processing.
Here is the format, with some example content included:
<?php
class i_installerid_strippedversion_install extends i_action_install
{
//==========================================================================// STEP I: INTERNAL CONFIGURABLES//==========================================================================
public function step1_init()
{
$this->setStepLabel("_step_progress_settings");
// OPTIONAL CUSTOM INPUTS (a READONLY and a PASSWORD)$this->setInputFields(array(
array(
"ID" => "login",
"LABEL" => "_installer_installerid_input_login_label",
"TEXT" => "_installer_installerid_input_login_text",
"TYPE" => "text",
"VALUE" => "admin",
"STORE" => true,
"READONLY" => true,
),
array(
"ID" => "passwd",
"LABEL" => "_installer_phpbb_input_passwd_label",
"TEXT" => "_installer_phpbb_input_passwd_text",
"TYPE" => "password",
"STORE" => true,
),
));
}
public function step1_process()
{
// OPTIONAL ERROR CHECKING ON CUSTOM INPUT VALUES// passwd: check that length is at least 2 characters:
if ( !isset($this->input["field_passwd"]) || !isset($this->input["field_passwd"][1]) )
{
$this->addError("_errors_tooshort", "field_passwd");
}
}
//==========================================================================// STEP II: ARCHIVE EXTRACTION//==========================================================================
public function step2_init()
{
$this->setStepLabel("_step_progress_extracting");
}
public function step2_process()
{
// extract main archive:$this->extract("main");
}
//==========================================================================// STEP III: CONFIGURING INSTALL//==========================================================================
public function step3_init()
{
$this->setStepLabel("_step_progress_processing");
}
public function step3_process()
{
// THIS IS AN EXAMPLE SET OF INSTALL STEPS// move the contents of this directory back into the install directory$this->mv('myscript-2.0.0/*','.');
// chmod files and/or directories$this->chmod(array('CHMOD_DIRECTORY_ONE','CHMOD_DIRECTORY_TWO'),0777);
$this->chmod(array('CHMOD_FILE_ONE','CHMOD_FILE_TWO','PATH/CHMOD_FILE_THREE'),0666);
// use regex to edit a file (replace the hard-coded table prefix with the Installatron-generated prefix)$this->sr("INSTALL/MYSQL_FILE_ONE.sql", "#PREFIX_#", "{$this->db_prefix}");
// import a MySQL .sql file to create or populate the database$this->db_import('INSTALL/MYSQL_FILE_ONE.sql');
// modify a database table using the values collected in step 1$this->db_query("UPDATE {$this->db_prefix}usertable SET username='{$this->input['field_login']}', user_password='".md5($this->input['field_passwd'])."' WHERE user_id='1'");
// use regex to edit a file (insert the Installatron-generated database values into the config file)$this->sr("CONFIG_FILE.php", "#DB_VAR_HOST = '.*?'#", "DB_VAR_HOST = '{$this->db_host}'");
$this->sr("CONFIG_FILE.php", "#DB_VAR_NAME = '.*?'#", "DB_VAR_NAME = '{$this->db_name}'");
$this->sr("CONFIG_FILE.php", "#DB_VAR_USER = '.*?'#", "DB_VAR_USER = '{$this->db_user}'");
$this->sr("CONFIG_FILE.php", "#DB_VAR_PASS = '.*?'#", "DB_VAR_PASS = '{$this->db_pass}'");
$this->sr("CONFIG_FILE.php", "#DB_VAR_PREF = '.*?'#", "DB_VAR_PREF = '{$this->db_prefix}'");
// use regex to edit a file (insert the path and url into the config file)$this->sr("CONFIG_FILE.php", "#SCRIPT_PATH_VAR = '.*?'#", "SCRIPT_PATH_VAR = '{$this->path}'");
$this->sr("CONFIG_FILE.php", "#SCRIPT_URL_VAR = '.*?'#", "SCRIPT_URL_VAR = '{$this->url}'");
// delete these files and/or directories$this->rm(array('DELETE_ONE','DELETE_TWO'));
}
//==========================================================================// OPTIONAL STEP: EXTERNAL COFIGURATION//==========================================================================
public function step4_init()
{
$this->setStepLabel("_step_progress_externaltask");
// creates external task screen$this->setExternalConfig("install/install.php");
}
public function step4_process()
{
}
//==========================================================================// OPTIONAL STEP: FINALIZE//==========================================================================
public function step5_init()
{
$this->setStepLabel("_step_progress_processing");
}
public function step5_process()
{
$this->chmod('FILEONE',0644);
$this->rm(array('FILETWO','DIRECTORYONE'));
}
}
?>
installerid is the unique id of the installer.
strippedversion is the "version" with all special characters: ( ) { } < > . :replaced by underscores. For example, the strippedversion for '2.0 (p1)' would be: 2_0__p1_
The upgrade.php file upgrades an install to this version of the script from the previous version.
The upgrade file uses the same format as install.php (see above), with any number of steps and each step has an _init (for setting up the page for that step) and _process (for doing stuff). Unlike install.php, step 1 is not reserved for settings, and it's more common to have just one or two steps.
Here is the format, with some example content included:
<?php
class i_installerid_strippedversion_upgrade extends i_action_upgrade
{
//==========================================================================// STEP I: ARCHIVE EXTRACTION//==========================================================================
public function step1_init()
{
$this->setStepLabel("_step_progress_extracting");
}
public function step1_process()
{
$this->extract("xtra1", "upgradetemp");
}
//==========================================================================// STEP II: CONFIGURING INSTALL//==========================================================================
public function step2_init()
{
$this->setStepLabel("_step_progress_processing");
}
public function step2_process()
{
$this->rm("upgradetemp/config.php");
$this->mv("upgradetemp/*");
$this->fetch("upgrade/update_to_latest.php");
$this->rm("upgrade");
}
}
?>
installerid is the unique id of the installer.
strippedversion is the "version" with all special characters: ( ) { } < > . :replaced by underscores. For example, the strippedversion for '2.0 (p1)' would be: 2_0__p1_