Skip to content

Instantly share code, notes, and snippets.

@chicks
Created June 17, 2012 10:50
Show Gist options
  • Save chicks/2944189 to your computer and use it in GitHub Desktop.
Save chicks/2944189 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 );
}
?>
@chicks
Copy link
Author

chicks commented Jun 17, 2012

This is an example of how to use the SugarCRM Silent Installer.

Simple update the values in config_si.php, and place in the SugarCRM root. Invoke silent_installer.php and watch as the install completes magically!

When things go wrong, check install.log and sugarcrm.log.

@vjaro
Copy link

vjaro commented Mar 26, 2014

Hi, Do you have a silent installer for SugarCRM 7?

@sadekbaroudi
Copy link

Updated version here:
https://gist.github.com/sadekbaroudi/f0f3c759df00ce1094f9

I've been using this for Sugar 7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment