Config File Variables
In a config file (or mysql or other value documented as using these variables) there are many variables that are available. If you need custom configuration variables for your script's installer, you will need to define those variables both inside your install/upgrade functions and inside your configuration file, or any other location using these variables.
The basic paradigm is
[% variable_name %] (left square bracket, percent sign, space, \w+ string name, space, percent sign, right square bracket). You can create customized ones by setting it in the object inside the given function.
sub install {
my $obj = shift;
$obj->{'vendor_special_value'} = _get_random_vendor_special_value();
$obj->stdinstall(@_);
}
Then you can get it into the config file by having this in your config file:
$special_value = '[% vendor_special_value %]',
The following variables are used in the default config file:
$VAR1 = {
'mysql.$meta_info->{mysql}[0].sqldb' => 'database_name', #MySQL database name
'installed_on_domain' => 'domain.com', #Domain associated with addon
'mysql_user_post' => 'uniqueid', #Unique id after database name i.e database_name1
'workinginstall' => '', #Internal use only
'hostname' => 'server.domain.com', #Hostname of the server
'email' => 'user@domain.com', #Contact email from install form
'mysql.$meta_info->{mysql}[0].sqluser' => 'user_uniqueid',#mysql user_uniqueid
'url_to_install' => 'http://domain.com/dir/', #URL the addon is installed at
'password' => 'abcdefghijkl', #Password from install form
'unix_time' => 1141098572, #Server Time at Install
'addon' => 'Vendor::Category::Name', #Addon's name space
'mysql_pass' => 'abcdefghijklm', #Password for MySQL database user
'user' => 'aoz', #Database user
'salt' => 'abbccdde', #Salt for password encryption
'lang' => 'english', #Language used for install
'installed_1.5.2' => 1141098575, #Timestamp of when the version is installed
'mysql.$meta_info->{mysql}[0].sqlpass' => 'abcdefghik', #MySQL database password
'username' => 'abbccdde', #Username for install
'mysql.$meta_info->{mysql}[0].mysql-version' => '4.1', #MySQL version on server
'$meta_info->{mysql}[1]' => 'user_uniqueid', #Mysql user_uniqueid
'table_prefix' => 'pfix', #MySQL Table Prefix (keep this under 4 chars [^\w+$ string])
'installpath' => 'dir', #Directory where addon will be installed
'registry' => 'Vendor::Category::Name.0', #~/.cpaddons/file_where_config_is_stored
'public_html' => '/home/user/public_html', #Location of the user's document root
'domain' => 'domain.com', #Domain the addon is installed for
'adminarea_name' => undef, #Name of admin area for addon
'addon_path' => 'Vendor/Category/Name', #Path of install files on server
'password_base64' => 'cEBzc3cwcmQ=', #Base64 encoded version of password in install form***
'password_md5_hex' => '6R54Ty3', #Hexadecimal MD5 sum of password in install form (Note: This is the most commonly used MD5 sum)
'password_md5' => 'g5;'$3e', #MD5 sum of password from install form (binary MD5)
'url_to_install_admin' => http://domain.com/dir, #URL to install admin interface to
'version' => '1.5.2', #Version of addon installed
'installdir' => '/home/user/public_html/dir', #Install path on the server
'mysql.$meta_info->{mysql}[0]._post' => 'uniqueid', #Uniqueid after database name
'mysql_user' => 'domainuser_dbuser', #MySQL Database user
'autoupdate' => 0, #Autoupdate addon installs (0=no 1=yes)
'suexec' => 1, #Was suexec enabled when this addon was installed? (0=no 1=yes)
'homedir' => '/home/user', #Domain user's home directory location
'password_crypt' => 'dfiF72Po.urHc', #[% password %] crpyted using [% salt %]
'gmt_hour_offset' => '-6', #Hours away from GMT the server is
'mysql_version' => '4.1', #Version of MySQL on server
'password_md5_base64' => 'gZFn5TS30qjWeXKcBQpgjA', #Base64 md5 sum of [ % password % ] (or password from install form)
'url_to_install_without_trailing_slash' => 'http://domain.com/dir', #Directory to install to without trailing slash
'no_protocol_url_to_install' => 'domain.com/dir/', #Directory to install to without http://
'no_protocol_url_to_install_without_trailing_slash' => 'domain.com/dir', #Directory to install to without http:// or trailing slash
'mysql.$meta_info->{mysql}[0].sqlhost' => 'hostname', #Server the MySQL database is on (usually localhost)
'phpsuexec' => '' #DEPRECATED: Use php_is_running_as_user_at_this_moment instead. Was phpsuexec enabled when this addon was installed? (0=no 1=yes) Only available when the cPAddon in question has 'setphpsuexecvar' set to true.
'phpinfo_at_this_moment' => '', #raw output of phpinfo() on this domain when the cPAddon was installed. If its value is -1 then 'set_phpinfo_at_this_moment_error' may have more information on why. Only available when the cPAddon in question has 'set_phpinfo_at_this_moment' set to true.
, 'php_is_running_as_user_at_this_moment' => '' #boolean, was php running as the user when this cPAddon was installed. If its value is -1 then 'set_php_is_running_as_user_at_this_moment_error' may have more information on why. If you're curious 'set_php_is_running_as_user_at_this_moment_raw_output' has the raw output. Only available when the cPAddon in question has 'set_php_is_running_as_user_at_this_moment' set to true.
};
This variable is new and will not be available on all cPanel servers. You should test for its existence and work around it if it is not installed, like so:
sub install {
my ($obj) = @_;
if ( !exists $cpo->{'password_base64'} && exists $cpo->{'password'} ) {
require Cpanel::CPAN::MIME::Base64::Perl;
$cpo->{'password_base64'} =
Cpanel::CPAN::MIME::Base64::Perl::encode_base64( $cpo->{'password'} );
}
$obj->stdinstall(@_);
}