6 define(
'CLIENT_CONFIG_LOCATION',
'../custom/runtime/client_main.php');
10 require
'../framework/yii.php';
11 require
'../framework/db/CDbConnection.php';
13 $ClientMainConfiguration = include
'../custom/config/client_main.php';
41 $settings[
'components'][
'db'] = array();
43 if (prompt(
'Do you use a database?')) {
46 $n = ask(
"What database:\n1) MySQL \n2) Postgres \n3) Oracle");
47 }
while (!in_array($n, array(1, 2, 3)));
48 $host = ask(
'Host (i.e. localhost):');
49 $port = ask(
'Port (i.e. 3306, you can also leave it blank):');
50 $database = ask(
'Database name:');
51 $settings[
'components'][
'db'][
'username'] = ask(
'Username:');
52 $settings[
'components'][
'db'][
'password'] = ask(
'Password:');
55 $settings[
'components'][
'db'][
'connectionString'] =
"mysql:host=$host" . ($port ?
":$port" :
'') .
";dbname=$database";
58 $settings[
'components'][
'db'][
'connectionString'] =
"pgsql:host=$host;" . ($port ?
"port=$port;" :
'') .
"dbname=$database";
61 $settings[
'components'][
'db'][
'connectionString'] =
"oci:dbname=$host" . ($port ?
":$port" :
'') .
"/$database;charset=UTF8";
64 $connection =
new CDbConnection($settings[
'components'][
'db'][
'connectionString'], $settings[
'components'][
'db'][
'username'], $settings[
'components'][
'db'][
'password']);
66 $connection->setActive(
true);
67 write(
'Connection success!');
68 }
catch (Exception $e) {
69 write($e->getMessage());
70 if (yes(ask(
'Try again?'))) {
73 write(
"You can configure it manually. In client_main.php set 'db' component settings. ");
80 if (prompt(
'Will you use Dynamic Content Renderer (DCR) (recommended) (you must have a Gentics Content Connector running)?')) {
81 $sett = &$settings[
'modules'][
'contentSource'][
'sourceSettings'][
'DynamicContentSource'];
82 $sett[
'cacheFolder'] = ask(
'Location of your cache folder (i.e. /var/www/DCR/), must be writeable for webserver-user:');
83 $sett[
'usePersonalisation'] =
false;
84 $sett[
'personalisationFields'] = array();
85 if (prompt(
'Will you use personalisation?')) {
86 $sett[
'usePersonalisation'] =
true;
87 $personalisationFields = ask(
'Enter personalisation attributes (multivalue) requested by Gentics Content Connector - must be defined in CMS (Tagmap) (i.e. permissions):');
88 $sett[
'personalisationFields'] = array_map(
'trim', explode(
',', $personalisationFields));
90 $settings[
'modules'][
'contentSource'][
'sourceClass'] =
'DynamicContentSource';
93 if (prompt(
'Will you use File System Content Renderer (FSCR) alternatively?')) {
94 $sett = &$settings[
'modules'][
'contentSource'][
'sourceSettings'][
'FileSystemContentSource'];
95 $sett[
'contentFolder'] = ask(
'Location of your published CMS files (i.e. /var/www/FSCR/):');
96 $sett[
'usePersonalisation'] =
false;
97 $sett[
'personalisationFields'] = array();
98 if (prompt(
'Will you use personalisation?')) {
99 $sett[
'usePersonalisation'] =
true;
100 $personalisationFields = ask(
'Enter personalisation attributes (multivalue) requested by Gentics Content Connector - must be defined in CMS (Tagmap) (i.e. permissions):');
101 if (!empty($personalisationFields)) {
102 $sett[
'personalisationFields'] = array_map(
'trim', explode(
',', $personalisationFields));
105 $settings[
'modules'][
'contentSource'][
'sourceClass'] =
'FileSystemContentSource';
111 if (prompt(
'Will you use memcached as caching system (recommended, is necessary for session)?')) {
112 $settings[
'components'][
'cache'][
'servers'][
'server1'] = array(
'host' =>
'127.0.0.1',
'port' => 11211,
'weight' => 60);
116 $settings[
'components'][
'eauth'][
'services'][
'standard'] = array(
117 'title' =>
'Use default login with username and password?'
119 if (prompt(
'Google authentication?')) {
120 $settings[
'components'][
'eauth'][
'services'][
'google'] = array(
121 'class' =>
'site.common.modules.user.services.GoogleService',
122 'title' =>
'Use login with Google Open ID?'
126 if (prompt(
'Facebook Authentication (you need a Facebook App)?')) {
127 $settings[
'components'][
'eauth'][
'services'][
'facebook'] = array(
128 'title' =>
'Use login with Facebook?',
129 'class' =>
'site.common.modules.user.services.FacebookService',
133 file_put_contents(CLIENT_CONFIG_LOCATION,
'<?php return ' . var_export(CMap::mergeArray($ClientMainConfiguration, $settings),
true) .
' ; ?>');
135 write(
'Configuration finished! Settings are in file ' . realpath(CLIENT_CONFIG_LOCATION));
138 $myOldConsole = include
'../custom/config/client_console.php';
139 file_put_contents(
'../custom/config/client_console.php',
'<?php Yii::setPathOfAlias(\'site\', dirname(__FILE__) . DIRECTORY_SEPARATOR . \'..\' . DIRECTORY_SEPARATOR . \'..\'); return ' .
140 var_export(CMap::mergeArray($myOldConsole, array(
'components' => array(
'db' => $settings[
'components'][
'db']))),
true) .
' ; ?>');
142 function write($text)
144 fwrite(STDOUT, $text .
"\n");
147 function prompt($question)
149 $answer = ask(
"\n" . $question .
"\n[y|n]");
152 elseif (no($answer)) {
155 return prompt($question);
161 fwrite(STDOUT, $text .
"\n");
162 return trim(fgets(STDIN));
165 function yes($string)
167 return substr($string, 0, 1) ==
'y';
172 return substr($string, 0, 1) ==
'n';