commit | author | age
|
fee8c6
|
1 |
#!/usr/bin/php |
T |
2 |
<?php |
|
3 |
|
|
4 |
define('INSTALL_PATH', realpath(dirname(__FILE__) . '/..') . '/' ); |
|
5 |
|
|
6 |
require_once INSTALL_PATH . 'program/include/iniset.php'; |
|
7 |
require_once INSTALL_PATH . 'installer/rcube_install.php'; |
|
8 |
|
|
9 |
$RCI = rcube_install::get_instance(); |
|
10 |
$RCI->load_config(); |
|
11 |
|
|
12 |
if ($RCI->configured) { |
|
13 |
if ($messages = $RCI->check_config()) { |
|
14 |
$err = 0; |
|
15 |
|
|
16 |
// list missing config options |
|
17 |
if (is_array($messages['missing'])) { |
|
18 |
echo "WARNING: Missing config options:\n"; |
|
19 |
echo "(These config options should be present in the current configuration)\n"; |
|
20 |
|
|
21 |
foreach ($messages['missing'] as $msg) { |
cbffc2
|
22 |
echo "- '" . $msg['prop'] . ($msg['name'] ? "': " . $msg['name'] : "'") . "\n"; |
fee8c6
|
23 |
$err++; |
T |
24 |
} |
|
25 |
echo "\n"; |
|
26 |
} |
|
27 |
|
|
28 |
// list old/replaced config options |
|
29 |
if (is_array($messages['replaced'])) { |
|
30 |
echo "WARNING: Replaced config options:\n"; |
|
31 |
echo "(These config options have been replaced or renamed)\n"; |
|
32 |
|
|
33 |
foreach ($messages['replaced'] as $msg) { |
cbffc2
|
34 |
echo "- '" . $msg['prop'] . "' was replaced by '" . $msg['replacement'] . "'\n"; |
fee8c6
|
35 |
$err++; |
T |
36 |
} |
|
37 |
echo "\n"; |
|
38 |
} |
|
39 |
|
|
40 |
// list obsolete config options (just a notice) |
|
41 |
if (is_array($messages['obsolete'])) { |
|
42 |
echo "NOTICE: Obsolete config options:\n"; |
|
43 |
echo "(You still have some obsolete or inexistent properties set. This isn't a problem but should be noticed)\n"; |
|
44 |
|
|
45 |
foreach ($messages['obsolete'] as $msg) { |
cbffc2
|
46 |
echo "- '" . $msg['prop'] . ($msg['name'] ? "': " . $msg['name'] : "'") . "\n"; |
fee8c6
|
47 |
$err++; |
T |
48 |
} |
|
49 |
echo "\n"; |
|
50 |
} |
|
51 |
|
|
52 |
// ask user to update config files |
|
53 |
if ($err) { |
|
54 |
echo "Do you want me to fix your local configuration? (y/N)\n"; |
|
55 |
$input = trim(fgets(STDIN)); |
|
56 |
|
|
57 |
// positive: let's merge the local config with the defaults |
|
58 |
if (strtolower($input) == 'y') { |
|
59 |
$copy1 = $copy2 = $write1 = $write2 = false; |
|
60 |
|
|
61 |
// backup current config |
|
62 |
echo ". backing up the current config files...\n"; |
|
63 |
$copy1 = copy(RCMAIL_CONFIG_DIR . '/main.inc.php', RCMAIL_CONFIG_DIR . '/main.old.php'); |
|
64 |
$copy2 = copy(RCMAIL_CONFIG_DIR . '/db.inc.php', RCMAIL_CONFIG_DIR . '/db.old.php'); |
|
65 |
|
|
66 |
if ($copy1 && $copy2) { |
|
67 |
$RCI->merge_config(); |
|
68 |
|
|
69 |
echo ". writing " . RCMAIL_CONFIG_DIR . "/main.inc.php...\n"; |
|
70 |
$write1 = file_put_contents(RCMAIL_CONFIG_DIR . '/main.inc.php', $RCI->create_config('main', true)); |
|
71 |
echo ". writing " . RCMAIL_CONFIG_DIR . "/main.db.php...\n"; |
|
72 |
$write2 = file_put_contents(RCMAIL_CONFIG_DIR . '/db.inc.php', $RCI->create_config('db', true)); |
|
73 |
} |
|
74 |
|
|
75 |
// Success! |
|
76 |
if ($write1 && $write2) { |
|
77 |
echo "Done.\n"; |
|
78 |
echo "Your configuration files are now up-tp-date!\n"; |
|
79 |
} |
|
80 |
else { |
|
81 |
echo "Failed to write config files!\n"; |
|
82 |
echo "Grant write privileges to the current user or update the files manually according to the above messages.\n"; |
|
83 |
} |
|
84 |
} |
|
85 |
else { |
|
86 |
echo "Please update your config files manually according to the above messages.\n"; |
|
87 |
} |
|
88 |
} |
|
89 |
|
|
90 |
// check dependencies based on the current configuration |
|
91 |
if (is_array($messages['dependencies'])) { |
|
92 |
echo "WARNING: Dependency check failed!\n"; |
|
93 |
echo "(Some of your configuration settings require other options to be configured or additional PHP modules to be installed)\n"; |
|
94 |
|
|
95 |
foreach ($messages['dependencies'] as $msg) { |
|
96 |
echo "- " . $msg['prop'] . ': ' . $msg['explain'] . "\n"; |
|
97 |
} |
|
98 |
echo "Please fix your config files and run this script again!\n"; |
|
99 |
echo "See ya.\n"; |
|
100 |
} |
|
101 |
|
|
102 |
} |
|
103 |
else { |
|
104 |
echo "This instance of RoundCube is up-to-date.\n"; |
|
105 |
echo "Have fun!\n"; |
|
106 |
} |
|
107 |
} |
|
108 |
else { |
|
109 |
echo "This instance of RoundCube is not yet configured!\n"; |
|
110 |
echo "Open http://url-to-roundcube/installer/ in your browser and follow the instuctions.\n"; |
|
111 |
} |
|
112 |
|
|
113 |
echo "\n"; |
|
114 |
|
|
115 |
?> |