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 |
|
6882ab
|
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 |
7fe908
|
44 |
echo "\n\n".str_repeat('-', 80)."\n"; |
e28b0e
|
45 |
echo " _____ ___________ _____ __ _ ____ |
L |
46 |
|_ _/ ___| ___ \ / __ \ / _(_) /__ \ |
|
47 |
| | \ `--.| |_/ / | / \/ ___ _ __ | |_ _ __ _ _/ / |
|
48 |
| | `--. \ __/ | | / _ \| '_ \| _| |/ _` | |_ | |
|
49 |
_| |_/\__/ / | | \__/\ (_) | | | | | | | (_| | ___\ \ |
|
50 |
\___/\____/\_| \____/\___/|_| |_|_| |_|\__, | \____/ |
|
51 |
__/ | |
|
52 |
|___/ "; |
7fe908
|
53 |
echo "\n".str_repeat('-', 80)."\n"; |
e28b0e
|
54 |
echo "\n\n>>This script is for internal use only! Please use update.php! \n\n"; |
L |
55 |
exit; |
|
56 |
} |
|
57 |
|
|
58 |
//** Include the library with the basic installer functions |
7fe908
|
59 |
require_once 'lib/install.lib.php'; |
e28b0e
|
60 |
|
L |
61 |
//** Include the library with the basic updater functions |
7fe908
|
62 |
require_once 'lib/update.lib.php'; |
e28b0e
|
63 |
|
L |
64 |
//** Include the base class of the installer class |
7fe908
|
65 |
require_once 'lib/installer_base.lib.php'; |
e28b0e
|
66 |
|
L |
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 |
|
7fe908
|
78 |
include_once "/usr/local/ispconfig/server/lib/config.inc.php"; |
e28b0e
|
79 |
$conf_old = $conf; |
L |
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 |
7fe908
|
85 |
if(is_file('dist/lib/'.$dist['baseid'].'.lib.php')) include_once 'dist/lib/'.$dist['baseid'].'.lib.php'; |
MC |
86 |
include_once 'dist/lib/'.$dist['id'].'.lib.php'; |
|
87 |
include_once 'dist/conf/'.$dist['id'].'.conf.php'; |
e28b0e
|
88 |
|
L |
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 |
7fe908
|
127 |
include_once 'lib/mysql.lib.php'; |
e28b0e
|
128 |
|
L |
129 |
//** Database update is a bit brute force and should be rebuild later ;) |
|
130 |
|
|
131 |
/* |
|
132 |
* Try to read the DB-admin settings |
|
133 |
*/ |
7fe908
|
134 |
$clientdb_host = ''; |
MC |
135 |
$clientdb_user = ''; |
|
136 |
$clientdb_password = ''; |
|
137 |
include_once "/usr/local/ispconfig/server/lib/mysql_clientdb.conf"; |
e28b0e
|
138 |
$conf["mysql"]["admin_user"] = $clientdb_user; |
L |
139 |
$conf["mysql"]["admin_password"] = $clientdb_password; |
7fe908
|
140 |
$clientdb_host = ''; |
MC |
141 |
$clientdb_user = ''; |
|
142 |
$clientdb_password = ''; |
e28b0e
|
143 |
|
L |
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 |
|
edf806
|
149 |
//** Test mysql root connection |
7fe908
|
150 |
if(!@mysql_connect($conf["mysql"]["host"], $conf["mysql"]["admin_user"], $conf["mysql"]["admin_password"])) { |
edf806
|
151 |
die("internal error - MYSQL-Root passord wrong"); |
T |
152 |
} |
|
153 |
|
e28b0e
|
154 |
/* |
L |
155 |
* Check all tables |
|
156 |
*/ |
|
157 |
checkDbHealth(); |
|
158 |
|
|
159 |
/* |
7fe908
|
160 |
* Prepare the dump of the database |
e28b0e
|
161 |
*/ |
L |
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'); |
7fe908
|
199 |
|
e28b0e
|
200 |
//** Configure mailman |
f9d95c
|
201 |
if($conf['mailman']['installed'] == true) { |
CS |
202 |
swriteln('Configuring Mailman'); |
|
203 |
$inst->configure_mailman('update'); |
|
204 |
} |
e28b0e
|
205 |
|
L |
206 |
//* Configure Jailkit |
|
207 |
swriteln('Configuring Jailkit'); |
|
208 |
$inst->configure_jailkit(); |
|
209 |
|
|
210 |
if($conf['dovecot']['installed'] == true) { |
|
211 |
//* Configure dovecot |
|
212 |
swriteln('Configuring Dovecot'); |
|
213 |
$inst->configure_dovecot(); |
|
214 |
} else { |
|
215 |
//** Configure saslauthd |
|
216 |
swriteln('Configuring SASL'); |
|
217 |
$inst->configure_saslauthd(); |
|
218 |
|
|
219 |
//** Configure PAM |
|
220 |
swriteln('Configuring PAM'); |
|
221 |
$inst->configure_pam(); |
7fe908
|
222 |
|
e28b0e
|
223 |
//* Configure courier |
L |
224 |
swriteln('Configuring Courier'); |
|
225 |
$inst->configure_courier(); |
|
226 |
} |
|
227 |
|
|
228 |
//** Configure Spamasassin |
|
229 |
swriteln('Configuring Spamassassin'); |
|
230 |
$inst->configure_spamassassin(); |
|
231 |
|
|
232 |
//** Configure Amavis |
|
233 |
swriteln('Configuring Amavisd'); |
|
234 |
$inst->configure_amavis(); |
|
235 |
|
|
236 |
//** Configure Getmail |
|
237 |
swriteln('Configuring Getmail'); |
|
238 |
$inst->configure_getmail(); |
|
239 |
} |
|
240 |
|
|
241 |
if($conf['services']['web'] == true) { |
|
242 |
//** Configure Pureftpd |
|
243 |
swriteln('Configuring Pureftpd'); |
|
244 |
$inst->configure_pureftpd(); |
|
245 |
} |
|
246 |
|
|
247 |
if($conf['services']['dns'] == true) { |
|
248 |
//* Configure DNS |
|
249 |
if($conf['powerdns']['installed'] == true) { |
|
250 |
swriteln('Configuring PowerDNS'); |
|
251 |
$inst->configure_powerdns(); |
|
252 |
} elseif($conf['bind']['installed'] == true) { |
|
253 |
swriteln('Configuring BIND'); |
|
254 |
$inst->configure_bind(); |
|
255 |
} else { |
|
256 |
swriteln('Configuring MyDNS'); |
|
257 |
$inst->configure_mydns(); |
|
258 |
} |
|
259 |
} |
|
260 |
|
4ffb51
|
261 |
if($conf['services']['web']) { |
F |
262 |
if($conf['webserver']['server_type'] == 'apache'){ |
|
263 |
//** Configure Apache |
|
264 |
swriteln('Configuring Apache'); |
|
265 |
$inst->configure_apache(); |
7fe908
|
266 |
|
4ffb51
|
267 |
//** Configure vlogger |
F |
268 |
swriteln('Configuring vlogger'); |
|
269 |
$inst->configure_vlogger(); |
|
270 |
} else { |
|
271 |
//** Configure nginx |
|
272 |
swriteln('Configuring nginx'); |
|
273 |
$inst->configure_nginx(); |
|
274 |
} |
7fe908
|
275 |
|
e28b0e
|
276 |
//** Configure apps vhost |
L |
277 |
swriteln('Configuring Apps vhost'); |
|
278 |
$inst->configure_apps_vhost(); |
|
279 |
} |
|
280 |
|
|
281 |
|
|
282 |
//* Configure DBServer |
|
283 |
swriteln('Configuring Database'); |
|
284 |
$inst->configure_dbserver(); |
|
285 |
|
|
286 |
|
|
287 |
//if(@is_dir('/etc/Bastille')) { |
|
288 |
//* Configure Firewall |
|
289 |
swriteln('Configuring Firewall'); |
992797
|
290 |
$inst->configure_firewall(); |
e28b0e
|
291 |
//} |
L |
292 |
|
|
293 |
//** Configure ISPConfig |
|
294 |
swriteln('Updating ISPConfig'); |
|
295 |
|
|
296 |
|
|
297 |
//** Customise the port ISPConfig runs on |
|
298 |
$conf['apache']['vhost_port'] = get_ispconfig_port_number(); |
|
299 |
|
|
300 |
$inst->install_ispconfig(); |
|
301 |
|
|
302 |
//** Configure Crontab |
|
303 |
swriteln('Updating Crontab'); |
|
304 |
$inst->install_crontab(); |
|
305 |
|
|
306 |
//** Restart services: |
|
307 |
swriteln('Restarting services ...'); |
3327ed
|
308 |
if($conf['mysql']['installed'] == true && $conf['mysql']['init_script'] != '') system($inst->getinitcommand($conf['mysql']['init_script'], 'reload')); |
e28b0e
|
309 |
if($conf['services']['mail']) { |
3327ed
|
310 |
if($conf['postfix']['installed'] == true && $conf['postfix']['init_script'] != '') system($inst->getinitcommand($conf['postfix']['init_script'], 'restart')); |
FT |
311 |
if($conf['saslauthd']['installed'] == true && $conf['saslauthd']['init_script'] != '') system($inst->getinitcommand($conf['saslauthd']['init_script'], 'restart')); |
|
312 |
if($conf['amavis']['installed'] == true && $conf['amavis']['init_script'] != '') system($inst->getinitcommand($conf['amavis']['init_script'], 'restart')); |
|
313 |
if($conf['clamav']['installed'] == true && $conf['clamav']['init_script'] != '') system($inst->getinitcommand($conf['clamav']['init_script'], 'restart')); |
|
314 |
if($conf['courier']['installed'] == true){ |
|
315 |
if($conf['courier']['courier-authdaemon'] != '') system($inst->getinitcommand($conf['courier']['courier-authdaemon'], 'restart')); |
|
316 |
if($conf['courier']['courier-imap'] != '') system($inst->getinitcommand($conf['courier']['courier-imap'], 'restart')); |
|
317 |
if($conf['courier']['courier-imap-ssl'] != '') system($inst->getinitcommand($conf['courier']['courier-imap-ssl'], 'restart')); |
|
318 |
if($conf['courier']['courier-pop'] != '') system($inst->getinitcommand($conf['courier']['courier-pop'], 'restart')); |
|
319 |
if($conf['courier']['courier-pop-ssl'] != '') system($inst->getinitcommand($conf['courier']['courier-pop-ssl'], 'restart')); |
|
320 |
} |
|
321 |
if($conf['dovecot']['installed'] == true && $conf['dovecot']['init_script'] != '') system($inst->getinitcommand($conf['dovecot']['init_script'], 'restart')); |
|
322 |
if($conf['mailman']['installed'] == true && $conf['mailman']['init_script'] != '') system($inst->getinitcommand($conf['mailman']['init_script'], 'restart')); |
e28b0e
|
323 |
} |
L |
324 |
if($conf['services']['web']) { |
33bcd0
|
325 |
if($conf['webserver']['server_type'] == 'apache' && $conf['apache']['init_script'] != '') system($inst->getinitcommand($conf['apache']['init_script'], 'restart')); |
4ffb51
|
326 |
//* Reload is enough for nginx |
33bcd0
|
327 |
if($conf['webserver']['server_type'] == 'nginx' && $conf['nginx']['init_script'] != '') system($inst->getinitcommand($conf['nginx']['init_script'], 'reload')); |
3327ed
|
328 |
if($conf['pureftpd']['installed'] == true && $conf['pureftpd']['init_script'] != '') system($inst->getinitcommand($conf['pureftpd']['init_script'], 'restart')); |
e28b0e
|
329 |
} |
L |
330 |
if($conf['services']['dns']) { |
33bcd0
|
331 |
if($conf['mydns']['installed'] == true && $conf['mydns']['init_script'] != '') system($inst->getinitcommand($conf['mydns']['init_script'], 'restart').' &> /dev/null'); |
FT |
332 |
if($conf['powerdns']['installed'] == true && $conf['powerdns']['init_script'] != '') system($inst->getinitcommand($conf['powerdns']['init_script'], 'restart').' &> /dev/null'); |
|
333 |
if($conf['bind']['installed'] == true && $conf['bind']['init_script'] != '') system($inst->getinitcommand($conf['bind']['init_script'], 'restart').' &> /dev/null'); |
e28b0e
|
334 |
} |
L |
335 |
|
|
336 |
echo "Update finished.\n"; |
|
337 |
|
|
338 |
?> |