Skip to content

Instantly share code, notes, and snippets.

@matthewpoer
Forked from chicks/config_si.php
Created May 9, 2017 18:28
Show Gist options
  • Save matthewpoer/8c93e11f7a99c45628c9f22157c8824e to your computer and use it in GitHub Desktop.
Save matthewpoer/8c93e11f7a99c45628c9f22157c8824e to your computer and use it in GitHub Desktop.
SugarCRM Silent Installer
<?php
$sugar_config_si = array(
'setup_db_host_name' => 'localhost',
'setup_db_sugarsales_user' => 'sugarcrm',
'setup_db_sugarsales_password' => 'DB_USER_PASSWORD',
'setup_db_database_name' => 'sugarcrm',
'setup_db_type' => 'mysql',
'setup_db_pop_demo_data' => false,
'setup_db_create_database' => 1,
'setup_db_create_sugarsales_user' => 1,
'dbUSRData' => 'create',
'setup_db_drop_tables' => 0,
'setup_db_username_is_privileged' => true,
'setup_db_admin_user_name' => 'root',
'setup_db_admin_password' => 'DB_ROOT_PASSWORD',
'setup_site_url' => 'http://IP_ADDRESS',
'setup_site_admin_user_name'=>'admin',
'setup_site_admin_password' => 'ADMIN_PASSWORD',
'setup_license_key' => 'LICENSE_KEY',
'setup_site_sugarbeet_automatic_checks' => true,
'default_currency_iso4217' => 'USD',
'default_currency_name' => 'US Dollar',
'default_currency_significant_digits' => '2',
'default_currency_symbol' => '$',
'default_date_format' => 'Y-m-d',
'default_time_format' => 'H:i',
'default_decimal_seperator' => '.',
'default_export_charset' => 'ISO-8859-1',
'default_language' => 'en_us',
'default_locale_name_format' => 's f l',
'default_number_grouping_seperator' => ',',
'export_delimiter' => ',',
'setup_system_name' => 'SugarCRM - Commercial Open Source CRM',
);
?>
#!/usr/bin/php -q
<?php
# This script (currently) assumes that the sugarcrm app has been extracted
# and that all necessary files are in place for a successful install.
function usage( $exit_status ){
print( "Usage: " . $_SERVER['argv'][0] . " CONTEXT_ROOT\n" );
print( "Installs SugarCRM software on the localhost at the specified CONTEXT_ROOT.\n" );
exit( $exit_status );
}
if( $_SERVER['argc'] != 2 ){
usage( 1 );
}
else {
switch ( $_SERVER['argv'][1] ) {
case '-h':
case '-help':
case '--h':
case '--help':
usage( 0 );
break;
default:
$instance = $_SERVER['argv'][1];
break;
}
}
$si_results = "";
// usage php -f silent_install.php instancename %s.sugarondemand.com
// this would install at http://instancename.sugarondemand.com/install.php
$url = "http://" . $instance;
$server_page = $url . "/install.php";
print( "Installing SugarCRM located at: $server_page ...\n" );
$fh = fopen( $server_page . "?goto=SilentInstall&cli=true", "r" ) or die( $php_errormsg );
while( !feof( $fh ) ){
$si_results .= fread( $fh, 1048576 );
}
$info = stream_get_meta_data($fh);
fclose( $fh );
// message in a bottle
preg_match( '/<bottle>(.*)<\/bottle>/s', $si_results, $message );
if( count( $message ) == 2 ){
// success
print( $message[1] );
}
else {
// failure
preg_match( '/Exit (.*)/', $si_results, $message );
if( count( $message ) == 2 ){
print( "Error. Most likely your configuration file is invalid. Message returned was:\n" );
}
else if( $info['timed_out'] ){
print( "Error. Connection timed out!" );
}
else {
print( "Unknown error. I don't know about this type of error message:\n" );
}
print( $si_results . "\n" );
exit( 1 );
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment