commit | author | age
|
e28b0e
|
1 |
<?php |
L |
2 |
/* |
|
3 |
Copyright (c) 2007-2010, Till Brehm, projektfarm Gmbh |
|
4 |
All rights reserved. |
|
5 |
|
|
6 |
Redistribution and use in source and binary forms, with or without modification, |
|
7 |
are permitted provided that the following conditions are met: |
|
8 |
|
|
9 |
* Redistributions of source code must retain the above copyright notice, |
|
10 |
this list of conditions and the following disclaimer. |
|
11 |
* Redistributions in binary form must reproduce the above copyright notice, |
|
12 |
this list of conditions and the following disclaimer in the documentation |
|
13 |
and/or other materials provided with the distribution. |
|
14 |
* Neither the name of ISPConfig nor the names of its contributors |
|
15 |
may be used to endorse or promote products derived from this software without |
|
16 |
specific prior written permission. |
|
17 |
|
|
18 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
|
19 |
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
|
20 |
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
|
21 |
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, |
|
22 |
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
|
23 |
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
24 |
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
|
25 |
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
|
26 |
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
|
27 |
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
28 |
*/ |
|
29 |
|
|
30 |
/* |
|
31 |
ISPConfig 3 updater. |
|
32 |
*/ |
|
33 |
|
a2b619
|
34 |
die("Autoupdate has been removed.\nPlease start the update on the shell with the command ispconfig_update.sh as root user.\n"); |
T |
35 |
|
e28b0e
|
36 |
error_reporting(E_ALL|E_STRICT); |
L |
37 |
|
|
38 |
/* |
|
39 |
* If the auto-updater flag is not on (the file does not exist) then cancel the auto-update! |
|
40 |
*/ |
|
41 |
if (!file_exists('autoupdate')) { |
|
42 |
|
|
43 |
//** The banner on the command line |
|
44 |
echo "\n\n".str_repeat('-',80)."\n"; |
|
45 |
echo " _____ ___________ _____ __ _ ____ |
|
46 |
|_ _/ ___| ___ \ / __ \ / _(_) /__ \ |
|
47 |
| | \ `--.| |_/ / | / \/ ___ _ __ | |_ _ __ _ _/ / |
|
48 |
| | `--. \ __/ | | / _ \| '_ \| _| |/ _` | |_ | |
|
49 |
_| |_/\__/ / | | \__/\ (_) | | | | | | | (_| | ___\ \ |
|
50 |
\___/\____/\_| \____/\___/|_| |_|_| |_|\__, | \____/ |
|
51 |
__/ | |
|
52 |
|___/ "; |
|
53 |
echo "\n".str_repeat('-',80)."\n"; |
|
54 |
echo "\n\n>>This script is for internal use only! Please use update.php! \n\n"; |
|
55 |
exit; |
|
56 |
} |
|
57 |
|
|
58 |
//** Include the library with the basic installer functions |
|
59 |
require_once('lib/install.lib.php'); |
|
60 |
|
|
61 |
//** Include the library with the basic updater functions |
|
62 |
require_once('lib/update.lib.php'); |
|
63 |
|
|
64 |
//** Include the base class of the installer class |
|
65 |
require_once('lib/installer_base.lib.php'); |
|
66 |
|
|
67 |
//** Ensure that current working directory is install directory |
|
68 |
$cur_dir = getcwd(); |
|
69 |
if(realpath(dirname(__FILE__)) != $cur_dir) die("Please run installation/update from _inside_ the install directory!\n"); |
|
70 |
|
|
71 |
//** Install logfile |
|
72 |
define('ISPC_LOG_FILE', '/var/log/ispconfig_install.log'); |
|
73 |
define('ISPC_INSTALL_ROOT', realpath(dirname(__FILE__).'/../')); |
|
74 |
|
|
75 |
//** Get distribution identifier |
|
76 |
$dist = get_distname(); |
|
77 |
|
|
78 |
include_once("/usr/local/ispconfig/server/lib/config.inc.php"); |
|
79 |
$conf_old = $conf; |
|
80 |
unset($conf); |
|
81 |
|
|
82 |
if($dist['id'] == '') die('Linux distribution or version not recognized.'); |
|
83 |
|
|
84 |
//** Include the distribution-specific installer class library and configuration |
|
85 |
if(is_file('dist/lib/'.$dist['baseid'].'.lib.php')) include_once('dist/lib/'.$dist['baseid'].'.lib.php'); |
|
86 |
include_once('dist/lib/'.$dist['id'].'.lib.php'); |
|
87 |
include_once('dist/conf/'.$dist['id'].'.conf.php'); |
|
88 |
|
|
89 |
//** Get hostname |
|
90 |
exec('hostname -f', $tmp_out); |
|
91 |
$conf['hostname'] = $tmp_out[0]; |
|
92 |
unset($tmp_out); |
|
93 |
|
|
94 |
//** Set the mysql login information |
|
95 |
$conf["mysql"]["host"] = $conf_old["db_host"]; |
|
96 |
$conf["mysql"]["database"] = $conf_old["db_database"]; |
|
97 |
$conf['mysql']['charset'] = 'utf8'; |
|
98 |
$conf["mysql"]["ispconfig_user"] = $conf_old["db_user"]; |
|
99 |
$conf["mysql"]["ispconfig_password"] = $conf_old["db_password"]; |
|
100 |
$conf['language'] = $conf_old['language']; |
|
101 |
if($conf['language'] == '{language}') $conf['language'] = 'en'; |
|
102 |
|
|
103 |
if(isset($conf_old["dbmaster_host"])) $conf["mysql"]["master_host"] = $conf_old["dbmaster_host"]; |
|
104 |
if(isset($conf_old["dbmaster_database"])) $conf["mysql"]["master_database"] = $conf_old["dbmaster_database"]; |
|
105 |
if(isset($conf_old["dbmaster_user"])) $conf["mysql"]["master_ispconfig_user"] = $conf_old["dbmaster_user"]; |
|
106 |
if(isset($conf_old["dbmaster_password"])) $conf["mysql"]["master_ispconfig_password"] = $conf_old["dbmaster_password"]; |
|
107 |
|
|
108 |
//* Check if this is a master / slave setup |
|
109 |
$conf['mysql']['master_slave_setup'] = 'n'; |
|
110 |
if($conf["mysql"]["master_host"] != '' && $conf["mysql"]["host"] != $conf["mysql"]["master_host"]) { |
|
111 |
$conf['mysql']['master_slave_setup'] = 'y'; |
|
112 |
} |
|
113 |
|
|
114 |
// Resolve the IP address of the mysql hostname. |
|
115 |
if(!$conf['mysql']['ip'] = gethostbyname($conf['mysql']['host'])) die('Unable to resolve hostname'.$conf['mysql']['host']); |
|
116 |
|
|
117 |
$conf['server_id'] = intval($conf_old["server_id"]); |
|
118 |
$conf['ispconfig_log_priority'] = $conf_old["log_priority"]; |
|
119 |
|
|
120 |
$inst = new installer(); |
|
121 |
$inst->is_update = true; |
|
122 |
|
|
123 |
//** Detect the installed applications |
|
124 |
$inst->find_installed_apps(); |
|
125 |
|
|
126 |
//** Initialize the MySQL server connection |
|
127 |
include_once('lib/mysql.lib.php'); |
|
128 |
|
|
129 |
//** Database update is a bit brute force and should be rebuild later ;) |
|
130 |
|
|
131 |
/* |
|
132 |
* Try to read the DB-admin settings |
|
133 |
*/ |
|
134 |
$clientdb_host = ''; |
|
135 |
$clientdb_user = ''; |
|
136 |
$clientdb_password = ''; |
|
137 |
include_once("/usr/local/ispconfig/server/lib/mysql_clientdb.conf"); |
|
138 |
$conf["mysql"]["admin_user"] = $clientdb_user; |
|
139 |
$conf["mysql"]["admin_password"] = $clientdb_password; |
|
140 |
$clientdb_host = ''; |
|
141 |
$clientdb_user = ''; |
|
142 |
$clientdb_password = ''; |
|
143 |
|
|
144 |
//** There is a error if user for mysql admin_password if empty |
|
145 |
if( empty($conf["mysql"]["admin_password"]) ) { |
|
146 |
die("internal error - MYSQL-Root passord not known"); |
|
147 |
} |
|
148 |
|
88273a
|
149 |
//** Test mysql root connection |
T |
150 |
if(!@mysql_connect($conf["mysql"]["host"],$conf["mysql"]["admin_user"],$conf["mysql"]["admin_password"])) { |
|
151 |
die("internal error - MYSQL-Root passord wrong"); |
|
152 |
} |
|
153 |
|
e28b0e
|
154 |
/* |
L |
155 |
* Check all tables |
|
156 |
*/ |
|
157 |
checkDbHealth(); |
|
158 |
|
|
159 |
/* |
|
160 |
* Prepare the dump of the database |
|
161 |
*/ |
|
162 |
prepareDBDump(); |
|
163 |
|
|
164 |
//* initialize the database |
|
165 |
$inst->db = new db(); |
|
166 |
|
|
167 |
/* |
|
168 |
* The next line is a bit tricky! |
|
169 |
* At the automated update we have no connection to the master-db (we don't need it, because |
|
170 |
* there are only TWO points, where this is needed) |
|
171 |
* 1) update the rights --> the autoupdater sets the rights of all clients when the server is |
|
172 |
* autoupdated) |
|
173 |
* 2) update the server-settings (is web installed, is mail installed) --> the autoupdates |
|
174 |
* doesn't change any of this settings, so there ist no need to update this. |
|
175 |
* This means, the autoupdater did not need any connection to the master-db (only to the local bd |
|
176 |
* of the master-server). To avoid any problems, we set the master-db to the local one. |
|
177 |
*/ |
|
178 |
$inst->dbmaster = $inst->db; |
|
179 |
|
|
180 |
/* |
|
181 |
* If it is NOT a master-slave - Setup then we are at the Master-DB. So set all rights |
|
182 |
*/ |
|
183 |
if($conf['mysql']['master_slave_setup'] != 'y') { |
|
184 |
$inst->grant_master_database_rights(true); |
|
185 |
} |
|
186 |
|
|
187 |
/* |
|
188 |
* dump the new Database and reconfigure the server.ini |
|
189 |
*/ |
|
190 |
updateDbAndIni(); |
|
191 |
|
|
192 |
/* |
|
193 |
* Reconfigure all Services |
|
194 |
*/ |
|
195 |
if($conf['services']['mail'] == true) { |
|
196 |
//** Configure postfix |
|
197 |
swriteln('Configuring Postfix'); |
|
198 |
$inst->configure_postfix('dont-create-certs'); |
|
199 |
|
|
200 |
//** Configure mailman |
|
201 |
swriteln('Configuring Mailman'); |
|
202 |
$inst->configure_mailman('update'); |
|
203 |
|
|
204 |
//* Configure Jailkit |
|
205 |
swriteln('Configuring Jailkit'); |
|
206 |
$inst->configure_jailkit(); |
|
207 |
|
|
208 |
if($conf['dovecot']['installed'] == true) { |
|
209 |
//* Configure dovecot |
|
210 |
swriteln('Configuring Dovecot'); |
|
211 |
$inst->configure_dovecot(); |
|
212 |
} else { |
|
213 |
//** Configure saslauthd |
|
214 |
swriteln('Configuring SASL'); |
|
215 |
$inst->configure_saslauthd(); |
|
216 |
|
|
217 |
//** Configure PAM |
|
218 |
swriteln('Configuring PAM'); |
|
219 |
$inst->configure_pam(); |
|
220 |
|
|
221 |
//* Configure courier |
|
222 |
swriteln('Configuring Courier'); |
|
223 |
$inst->configure_courier(); |
|
224 |
} |
|
225 |
|
|
226 |
//** Configure Spamasassin |
|
227 |
swriteln('Configuring Spamassassin'); |
|
228 |
$inst->configure_spamassassin(); |
|
229 |
|
|
230 |
//** Configure Amavis |
|
231 |
swriteln('Configuring Amavisd'); |
|
232 |
$inst->configure_amavis(); |
|
233 |
|
|
234 |
//** Configure Getmail |
|
235 |
swriteln('Configuring Getmail'); |
|
236 |
$inst->configure_getmail(); |
|
237 |
} |
|
238 |
|
|
239 |
if($conf['services']['web'] == true) { |
|
240 |
//** Configure Pureftpd |
|
241 |
swriteln('Configuring Pureftpd'); |
|
242 |
$inst->configure_pureftpd(); |
|
243 |
} |
|
244 |
|
|
245 |
if($conf['services']['dns'] == true) { |
|
246 |
//* Configure DNS |
|
247 |
if($conf['powerdns']['installed'] == true) { |
|
248 |
swriteln('Configuring PowerDNS'); |
|
249 |
$inst->configure_powerdns(); |
|
250 |
} elseif($conf['bind']['installed'] == true) { |
|
251 |
swriteln('Configuring BIND'); |
|
252 |
$inst->configure_bind(); |
|
253 |
} else { |
|
254 |
swriteln('Configuring MyDNS'); |
|
255 |
$inst->configure_mydns(); |
|
256 |
} |
|
257 |
} |
|
258 |
|
4ffb51
|
259 |
if($conf['services']['web']) { |
F |
260 |
if($conf['webserver']['server_type'] == 'apache'){ |
|
261 |
//** Configure Apache |
|
262 |
swriteln('Configuring Apache'); |
|
263 |
$inst->configure_apache(); |
|
264 |
|
|
265 |
//** Configure vlogger |
|
266 |
swriteln('Configuring vlogger'); |
|
267 |
$inst->configure_vlogger(); |
|
268 |
} else { |
|
269 |
//** Configure nginx |
|
270 |
swriteln('Configuring nginx'); |
|
271 |
$inst->configure_nginx(); |
|
272 |
} |
|
273 |
|
e28b0e
|
274 |
//** Configure apps vhost |
L |
275 |
swriteln('Configuring Apps vhost'); |
|
276 |
$inst->configure_apps_vhost(); |
|
277 |
} |
|
278 |
|
|
279 |
|
|
280 |
//* Configure DBServer |
|
281 |
swriteln('Configuring Database'); |
|
282 |
$inst->configure_dbserver(); |
|
283 |
|
|
284 |
|
|
285 |
//if(@is_dir('/etc/Bastille')) { |
|
286 |
//* Configure Firewall |
|
287 |
swriteln('Configuring Firewall'); |
|
288 |
$inst->configure_firewall(); |
|
289 |
//} |
|
290 |
|
|
291 |
//** Configure ISPConfig |
|
292 |
swriteln('Updating ISPConfig'); |
|
293 |
|
|
294 |
|
|
295 |
//** Customise the port ISPConfig runs on |
|
296 |
$conf['apache']['vhost_port'] = get_ispconfig_port_number(); |
|
297 |
|
|
298 |
$inst->install_ispconfig(); |
|
299 |
|
|
300 |
//** Configure Crontab |
|
301 |
swriteln('Updating Crontab'); |
|
302 |
$inst->install_crontab(); |
|
303 |
|
|
304 |
//** Restart services: |
|
305 |
swriteln('Restarting services ...'); |
|
306 |
if($conf['mysql']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['mysql']['init_script'])) system($conf['init_scripts'].'/'.$conf['mysql']['init_script'].' reload'); |
|
307 |
if($conf['services']['mail']) { |
|
308 |
if($conf['postfix']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['postfix']['init_script'])) system($conf['init_scripts'].'/'.$conf['postfix']['init_script'].' restart'); |
|
309 |
if($conf['saslauthd']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['saslauthd']['init_script'])) system($conf['init_scripts'].'/'.$conf['saslauthd']['init_script'].' restart'); |
|
310 |
if($conf['amavis']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['amavis']['init_script'])) system($conf['init_scripts'].'/'.$conf['amavis']['init_script'].' restart'); |
|
311 |
if($conf['clamav']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['clamav']['init_script'])) system($conf['init_scripts'].'/'.$conf['clamav']['init_script'].' restart'); |
|
312 |
if($conf['courier']['courier-authdaemon'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-authdaemon'])) system($conf['init_scripts'].'/'.$conf['courier']['courier-authdaemon'].' restart'); |
|
313 |
if($conf['courier']['courier-imap'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-imap'])) system($conf['init_scripts'].'/'.$conf['courier']['courier-imap'].' restart'); |
|
314 |
if($conf['courier']['courier-imap-ssl'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-imap-ssl'])) system($conf['init_scripts'].'/'.$conf['courier']['courier-imap-ssl'].' restart'); |
|
315 |
if($conf['courier']['courier-pop'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-pop'])) system($conf['init_scripts'].'/'.$conf['courier']['courier-pop'].' restart'); |
|
316 |
if($conf['courier']['courier-pop-ssl'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-pop-ssl'])) system($conf['init_scripts'].'/'.$conf['courier']['courier-pop-ssl'].' restart'); |
|
317 |
if($conf['dovecot']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['dovecot']['init_script'])) system($conf['init_scripts'].'/'.$conf['dovecot']['init_script'].' restart'); |
|
318 |
if($conf['mailman']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['mailman']['init_script'])) system($conf['init_scripts'].'/'.$conf['mailman']['init_script'].' restart'); |
|
319 |
} |
|
320 |
if($conf['services']['web']) { |
4ffb51
|
321 |
if($conf['webserver']['server_type'] == 'apache' && $conf['apache']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['apache']['init_script'])) system($conf['init_scripts'].'/'.$conf['apache']['init_script'].' restart'); |
F |
322 |
//* Reload is enough for nginx |
|
323 |
if($conf['webserver']['server_type'] == 'nginx' && $conf['nginx']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['nginx']['init_script'])) system($conf['init_scripts'].'/'.$conf['nginx']['init_script'].' reload'); |
e28b0e
|
324 |
if($conf['pureftpd']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['pureftpd']['init_script'])) system($conf['init_scripts'].'/'.$conf['pureftpd']['init_script'].' restart'); |
L |
325 |
} |
|
326 |
if($conf['services']['dns']) { |
|
327 |
if($conf['mydns']['installed'] == true && $conf['mydns']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['mydns']['init_script'])) system($conf['init_scripts'].'/'.$conf['mydns']['init_script'].' restart &> /dev/null'); |
|
328 |
if($conf['powerdns']['installed'] == true && $conf['powerdns']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['powerdns']['init_script'])) system($conf['init_scripts'].'/'.$conf['powerdns']['init_script'].' restart &> /dev/null'); |
|
329 |
if($conf['bind']['installed'] == true && $conf['bind']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['bind']['init_script'])) system($conf['init_scripts'].'/'.$conf['bind']['init_script'].' restart &> /dev/null'); |
|
330 |
} |
|
331 |
|
|
332 |
echo "Update finished.\n"; |
|
333 |
|
|
334 |
?> |