commit | author | age
|
532ae5
|
1 |
<?php |
L |
2 |
|
|
3 |
/* |
|
4 |
Copyright (c) 2007-2010, Till Brehm, projektfarm Gmbh |
|
5 |
All rights reserved. |
|
6 |
|
|
7 |
Redistribution and use in source and binary forms, with or without modification, |
|
8 |
are permitted provided that the following conditions are met: |
|
9 |
|
|
10 |
* Redistributions of source code must retain the above copyright notice, |
|
11 |
this list of conditions and the following disclaimer. |
|
12 |
* Redistributions in binary form must reproduce the above copyright notice, |
|
13 |
this list of conditions and the following disclaimer in the documentation |
|
14 |
and/or other materials provided with the distribution. |
|
15 |
* Neither the name of ISPConfig nor the names of its contributors |
|
16 |
may be used to endorse or promote products derived from this software without |
|
17 |
specific prior written permission. |
|
18 |
|
|
19 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
|
20 |
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
|
21 |
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
|
22 |
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, |
|
23 |
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
|
24 |
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
25 |
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
|
26 |
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
|
27 |
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
|
28 |
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
29 |
*/ |
|
30 |
|
|
31 |
/* |
|
32 |
ISPConfig 3 installer. |
|
33 |
*/ |
|
34 |
|
|
35 |
error_reporting(E_ALL|E_STRICT); |
|
36 |
|
eac72c
|
37 |
define('INSTALLER_RUN', true); |
T |
38 |
|
532ae5
|
39 |
//** The banner on the command line |
L |
40 |
echo "\n\n".str_repeat('-',80)."\n"; |
|
41 |
echo " _____ ___________ _____ __ _ ____ |
|
42 |
|_ _/ ___| ___ \ / __ \ / _(_) /__ \ |
|
43 |
| | \ `--.| |_/ / | / \/ ___ _ __ | |_ _ __ _ _/ / |
|
44 |
| | `--. \ __/ | | / _ \| '_ \| _| |/ _` | |_ | |
|
45 |
_| |_/\__/ / | | \__/\ (_) | | | | | | | (_| | ___\ \ |
|
46 |
\___/\____/\_| \____/\___/|_| |_|_| |_|\__, | \____/ |
|
47 |
__/ | |
|
48 |
|___/ "; |
|
49 |
echo "\n".str_repeat('-',80)."\n"; |
|
50 |
echo "\n\n>> Initial configuration \n\n"; |
|
51 |
|
|
52 |
//** Include the library with the basic installer functions |
|
53 |
require_once('lib/install.lib.php'); |
|
54 |
|
|
55 |
//** Include the base class of the installer class |
|
56 |
require_once('lib/installer_base.lib.php'); |
|
57 |
|
|
58 |
//** Ensure that current working directory is install directory |
|
59 |
$cur_dir = getcwd(); |
|
60 |
if(realpath(dirname(__FILE__)) != $cur_dir) { |
|
61 |
chdir( realpath(dirname(__FILE__)) ); |
|
62 |
} |
|
63 |
|
|
64 |
//** Install logfile |
|
65 |
define('ISPC_LOG_FILE', '/var/log/ispconfig_install.log'); |
|
66 |
define('ISPC_INSTALL_ROOT', realpath(dirname(__FILE__).'/../')); |
|
67 |
|
|
68 |
//** Check for existing installation |
|
69 |
/*if(is_dir("/usr/local/ispconfig")) { |
|
70 |
die('We will stop here. There is already a ISPConfig installation, use the update script to update this installation.'); |
|
71 |
}*/ |
|
72 |
|
|
73 |
//** Get distribution identifier |
|
74 |
$dist = get_distname(); |
|
75 |
|
|
76 |
if($dist['id'] == '') die('Linux distribution or version not recognized.'); |
|
77 |
|
|
78 |
//** Include the distribution-specific installer class library and configuration |
|
79 |
if(is_file('dist/lib/'.$dist['baseid'].'.lib.php')) include_once('dist/lib/'.$dist['baseid'].'.lib.php'); |
|
80 |
include_once('dist/lib/'.$dist['id'].'.lib.php'); |
|
81 |
include_once('dist/conf/'.$dist['id'].'.conf.php'); |
|
82 |
|
|
83 |
//**************************************************************************************************** |
|
84 |
//** Installer Interface |
|
85 |
//**************************************************************************************************** |
|
86 |
$inst = new installer(); |
|
87 |
swriteln($inst->lng(' Following will be a few questions for primary configuration so be careful.')); |
|
88 |
swriteln($inst->lng(' Default values are in [brackets] and can be accepted with <ENTER>.')); |
|
89 |
swriteln($inst->lng(' Tap in "quit" (without the quotes) to stop the installer.'."\n\n")); |
|
90 |
|
|
91 |
//** Check log file is writable (probably not root or sudo) |
|
92 |
if(!is_writable(dirname(ISPC_LOG_FILE))){ |
|
93 |
die("ERROR: Cannot write to the ".dirname(ISPC_LOG_FILE)." directory. Are you root or sudo ?\n\n"); |
|
94 |
} |
|
95 |
|
|
96 |
if(is_dir('/root/ispconfig') || is_dir('/home/admispconfig')) { |
|
97 |
die('This software cannot be installed on a server wich runs ISPConfig 2.x.'); |
|
98 |
} |
|
99 |
|
|
100 |
if(is_dir('/usr/local/ispconfig')) { |
|
101 |
die('ISPConfig 3 installation found. Please use update.php instead if install.php to update the installation.'); |
|
102 |
} |
|
103 |
|
|
104 |
//** Detect the installed applications |
|
105 |
$inst->find_installed_apps(); |
|
106 |
|
8cf78b
|
107 |
//** Select the language and set default timezone |
532ae5
|
108 |
$conf['language'] = $inst->simple_query('Select language', array('en','de'), 'en'); |
3898c9
|
109 |
$conf['timezone'] = get_system_timezone(); |
532ae5
|
110 |
|
f2a9b2
|
111 |
//* Set default theme |
f598b0
|
112 |
$conf['theme'] = 'default'; |
f2a9b2
|
113 |
$conf['language_file_import_enabled'] = true; |
f598b0
|
114 |
|
532ae5
|
115 |
//** Select installation mode |
L |
116 |
$install_mode = $inst->simple_query('Installation mode', array('standard','expert'), 'standard'); |
|
117 |
|
|
118 |
|
|
119 |
//** Get the hostname |
|
120 |
$tmp_out = array(); |
|
121 |
exec('hostname -f', $tmp_out); |
b67344
|
122 |
$conf['hostname'] = $inst->free_query('Full qualified hostname (FQDN) of the server, eg server1.domain.tld ', @$tmp_out[0]); |
532ae5
|
123 |
unset($tmp_out); |
L |
124 |
|
|
125 |
// Check if the mysql functions are loaded in PHP |
|
126 |
if(!function_exists('mysql_connect')) die('No PHP MySQL functions available. Please ensure that the PHP MySQL module is loaded.'); |
|
127 |
|
|
128 |
//** Get MySQL root credentials |
|
129 |
$finished = false; |
|
130 |
do { |
|
131 |
$tmp_mysql_server_host = $inst->free_query('MySQL server hostname', $conf['mysql']['host']); |
|
132 |
$tmp_mysql_server_admin_user = $inst->free_query('MySQL root username', $conf['mysql']['admin_user']); |
|
133 |
$tmp_mysql_server_admin_password = $inst->free_query('MySQL root password', $conf['mysql']['admin_password']); |
|
134 |
$tmp_mysql_server_database = $inst->free_query('MySQL database to create', $conf['mysql']['database']); |
|
135 |
$tmp_mysql_server_charset = $inst->free_query('MySQL charset', $conf['mysql']['charset']); |
|
136 |
|
8cf78b
|
137 |
if($install_mode == 'expert') { |
T |
138 |
swriteln("The next two questions are about the internal ISPConfig database user and password.\nIt is recommended to accept the defaults which are 'ispconfig' as username and a random password.\nIf you use a different password, use only numbers and chars for the password.\n"); |
|
139 |
$conf['mysql']['ispconfig_user'] = $inst->free_query('ISPConfig mysql database username', $conf['mysql']['ispconfig_user']); |
|
140 |
$conf['mysql']['ispconfig_password'] = $inst->free_query('ISPConfig mysql database password', $conf['mysql']['ispconfig_password']); |
|
141 |
} |
|
142 |
|
532ae5
|
143 |
//* Initialize the MySQL server connection |
L |
144 |
if(@mysql_connect($tmp_mysql_server_host, $tmp_mysql_server_admin_user, $tmp_mysql_server_admin_password)) { |
|
145 |
$conf['mysql']['host'] = $tmp_mysql_server_host; |
|
146 |
$conf['mysql']['admin_user'] = $tmp_mysql_server_admin_user; |
|
147 |
$conf['mysql']['admin_password'] = $tmp_mysql_server_admin_password; |
|
148 |
$conf['mysql']['database'] = $tmp_mysql_server_database; |
|
149 |
$conf['mysql']['charset'] = $tmp_mysql_server_charset; |
|
150 |
$finished = true; |
|
151 |
} else { |
|
152 |
swriteln($inst->lng('Unable to connect to the specified MySQL server').' '.mysql_error()); |
|
153 |
} |
|
154 |
} while ($finished == false); |
|
155 |
unset($finished); |
|
156 |
|
|
157 |
// Resolve the IP address of the MySQL hostname. |
|
158 |
$tmp = explode(':',$conf['mysql']['host']); |
|
159 |
if(!$conf['mysql']['ip'] = gethostbyname($tmp[0])) die('Unable to resolve hostname'.$tmp[0]); |
|
160 |
unset($tmp); |
|
161 |
|
|
162 |
|
|
163 |
//** Initializing database connection |
|
164 |
include_once('lib/mysql.lib.php'); |
|
165 |
$inst->db = new db(); |
|
166 |
|
|
167 |
//** Begin with standard or expert installation |
|
168 |
if($install_mode == 'standard') { |
|
169 |
|
|
170 |
//* Create the MySQL database |
|
171 |
$inst->configure_database(); |
|
172 |
|
4ffb51
|
173 |
//* Configure Webserver - Apache or nginx |
F |
174 |
if($conf['apache']['installed'] == true && $conf['nginx']['installed'] == true) { |
|
175 |
$http_server_to_use = $inst->simple_query('Apache and nginx detected. Select server to use for ISPConfig:', array('apache','nginx'), 'apache'); |
|
176 |
if($http_server_to_use == 'apache'){ |
|
177 |
$conf['nginx']['installed'] = false; |
|
178 |
} else { |
|
179 |
$conf['apache']['installed'] = false; |
|
180 |
} |
|
181 |
} |
|
182 |
|
532ae5
|
183 |
//* Insert the Server record into the database |
L |
184 |
$inst->add_database_server_record(); |
|
185 |
|
|
186 |
//* Configure Postfix |
|
187 |
$inst->configure_postfix(); |
|
188 |
|
|
189 |
//* Configure Mailman |
|
190 |
$inst->configure_mailman('install'); |
|
191 |
|
|
192 |
//* Configure jailkit |
|
193 |
swriteln('Configuring Jailkit'); |
|
194 |
$inst->configure_jailkit(); |
|
195 |
|
|
196 |
if($conf['dovecot']['installed'] == true) { |
|
197 |
//* Configure Dovecot |
|
198 |
swriteln('Configuring Dovecot'); |
|
199 |
$inst->configure_dovecot(); |
|
200 |
} else { |
|
201 |
//* Configure saslauthd |
|
202 |
swriteln('Configuring SASL'); |
|
203 |
$inst->configure_saslauthd(); |
|
204 |
|
|
205 |
//* Configure PAM |
|
206 |
swriteln('Configuring PAM'); |
|
207 |
$inst->configure_pam(); |
|
208 |
|
|
209 |
//* Configure Courier |
|
210 |
swriteln('Configuring Courier'); |
|
211 |
$inst->configure_courier(); |
|
212 |
} |
|
213 |
|
|
214 |
//* Configure Spamasassin |
|
215 |
swriteln('Configuring Spamassassin'); |
|
216 |
$inst->configure_spamassassin(); |
|
217 |
|
|
218 |
//* Configure Amavis |
|
219 |
swriteln('Configuring Amavisd'); |
|
220 |
$inst->configure_amavis(); |
|
221 |
|
|
222 |
//* Configure Getmail |
|
223 |
swriteln('Configuring Getmail'); |
|
224 |
$inst->configure_getmail(); |
|
225 |
|
|
226 |
//* Configure Pureftpd |
|
227 |
swriteln('Configuring Pureftpd'); |
|
228 |
$inst->configure_pureftpd(); |
|
229 |
|
|
230 |
//* Configure DNS |
|
231 |
if($conf['powerdns']['installed'] == true) { |
|
232 |
swriteln('Configuring PowerDNS'); |
|
233 |
$inst->configure_powerdns(); |
|
234 |
} elseif($conf['bind']['installed'] == true) { |
|
235 |
swriteln('Configuring BIND'); |
|
236 |
$inst->configure_bind(); |
|
237 |
} else { |
|
238 |
swriteln('Configuring MyDNS'); |
|
239 |
$inst->configure_mydns(); |
|
240 |
} |
|
241 |
|
|
242 |
//* Configure Apache |
4ffb51
|
243 |
if($conf['apache']['installed'] == true){ |
F |
244 |
swriteln('Configuring Apache'); |
|
245 |
$inst->configure_apache(); |
|
246 |
} |
|
247 |
|
|
248 |
//* Configure nginx |
|
249 |
if($conf['nginx']['installed'] == true){ |
|
250 |
swriteln('Configuring nginx'); |
|
251 |
$inst->configure_nginx(); |
|
252 |
} |
532ae5
|
253 |
|
L |
254 |
//** Configure Vlogger |
|
255 |
swriteln('Configuring Vlogger'); |
|
256 |
$inst->configure_vlogger(); |
|
257 |
|
|
258 |
//** Configure apps vhost |
|
259 |
swriteln('Configuring Apps vhost'); |
|
260 |
$inst->configure_apps_vhost(); |
|
261 |
|
|
262 |
//* Configure Firewall |
0ee22c
|
263 |
//* Configure Bastille Firewall |
F |
264 |
$conf['services']['firewall'] = true; |
|
265 |
swriteln('Configuring Bastille Firewall'); |
|
266 |
$inst->configure_firewall(); |
c12af9
|
267 |
|
L |
268 |
//* Configure Fail2ban |
|
269 |
if($conf['fail2ban']['installed'] == true) { |
|
270 |
swriteln('Configuring Fail2ban'); |
|
271 |
$inst->configure_fail2ban(); |
94cb90
|
272 |
} |
80e3c9
|
273 |
|
4ffb51
|
274 |
/* |
80e3c9
|
275 |
if($conf['squid']['installed'] == true) { |
T |
276 |
$conf['services']['proxy'] = true; |
|
277 |
swriteln('Configuring Squid'); |
|
278 |
$inst->configure_squid(); |
|
279 |
} else if($conf['nginx']['installed'] == true) { |
|
280 |
$conf['services']['proxy'] = true; |
|
281 |
swriteln('Configuring Nginx'); |
|
282 |
$inst->configure_nginx(); |
|
283 |
} |
4ffb51
|
284 |
*/ |
80e3c9
|
285 |
|
532ae5
|
286 |
//* Configure ISPConfig |
L |
287 |
swriteln('Installing ISPConfig'); |
|
288 |
|
|
289 |
//** Customize the port ISPConfig runs on |
dec0df
|
290 |
$ispconfig_vhost_port = $inst->free_query('ISPConfig Port', '8080'); |
T |
291 |
if($conf['apache']['installed'] == true) $conf['apache']['vhost_port'] = $ispconfig_vhost_port; |
|
292 |
if($conf['nginx']['installed'] == true) $conf['nginx']['vhost_port'] = $ispconfig_vhost_port; |
|
293 |
unset($ispconfig_vhost_port); |
532ae5
|
294 |
|
939b92
|
295 |
if(strtolower($inst->simple_query('Do you want a secure (SSL) connection to the ISPConfig web interface',array('y','n'),'y')) == 'y') { |
M |
296 |
$inst->make_ispconfig_ssl_cert(); |
|
297 |
} |
|
298 |
|
532ae5
|
299 |
$inst->install_ispconfig(); |
L |
300 |
|
|
301 |
//* Configure DBServer |
|
302 |
swriteln('Configuring DBServer'); |
|
303 |
$inst->configure_dbserver(); |
|
304 |
|
|
305 |
//* Configure ISPConfig |
|
306 |
swriteln('Installing ISPConfig crontab'); |
|
307 |
$inst->install_crontab(); |
|
308 |
|
|
309 |
swriteln('Restarting services ...'); |
|
310 |
if($conf['mysql']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['mysql']['init_script'])) system($conf['init_scripts'].'/'.$conf['mysql']['init_script'].' restart'); |
|
311 |
if($conf['postfix']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['postfix']['init_script'])) system($conf['init_scripts'].'/'.$conf['postfix']['init_script'].' restart'); |
|
312 |
if($conf['saslauthd']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['saslauthd']['init_script'])) system($conf['init_scripts'].'/'.$conf['saslauthd']['init_script'].' restart'); |
|
313 |
if($conf['amavis']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['amavis']['init_script'])) system($conf['init_scripts'].'/'.$conf['amavis']['init_script'].' restart'); |
|
314 |
if($conf['clamav']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['clamav']['init_script'])) system($conf['init_scripts'].'/'.$conf['clamav']['init_script'].' restart'); |
|
315 |
if($conf['courier']['courier-authdaemon'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-authdaemon'])) system($conf['init_scripts'].'/'.$conf['courier']['courier-authdaemon'].' restart'); |
|
316 |
if($conf['courier']['courier-imap'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-imap'])) system($conf['init_scripts'].'/'.$conf['courier']['courier-imap'].' restart'); |
|
317 |
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'); |
|
318 |
if($conf['courier']['courier-pop'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-pop'])) system($conf['init_scripts'].'/'.$conf['courier']['courier-pop'].' restart'); |
|
319 |
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'); |
|
320 |
if($conf['dovecot']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['dovecot']['init_script'])) system($conf['init_scripts'].'/'.$conf['dovecot']['init_script'].' restart'); |
26c0fc
|
321 |
if($conf['mailman']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['mailman']['init_script'])) system('nohup '.$conf['init_scripts'].'/'.$conf['mailman']['init_script'].' restart >/dev/null 2>&1 &'); |
4ffb51
|
322 |
if($conf['apache']['installed'] == true && $conf['apache']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['apache']['init_script'])) system($conf['init_scripts'].'/'.$conf['apache']['init_script'].' restart'); |
F |
323 |
//* Reload is enough for nginx |
|
324 |
if($conf['nginx']['installed'] == true){ |
|
325 |
if($conf['nginx']['php_fpm_init_script'] != '' && @is_file($conf['init_scripts'].'/'.$conf['nginx']['php_fpm_init_script'])) system($conf['init_scripts'].'/'.$conf['nginx']['php_fpm_init_script'].' reload'); |
|
326 |
if($conf['nginx']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['nginx']['init_script'])) system($conf['init_scripts'].'/'.$conf['nginx']['init_script'].' reload'); |
|
327 |
} |
532ae5
|
328 |
if($conf['pureftpd']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['pureftpd']['init_script'])) system($conf['init_scripts'].'/'.$conf['pureftpd']['init_script'].' restart'); |
L |
329 |
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'); |
|
330 |
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'); |
|
331 |
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'); |
c91bdc
|
332 |
//if($conf['squid']['installed'] == true && $conf['squid']['init_script'] != '' && is_file($conf['init_scripts'].'/'.$conf['squid']['init_script'])) system($conf['init_scripts'].'/'.$conf['squid']['init_script'].' restart &> /dev/null'); |
80e3c9
|
333 |
if($conf['nginx']['installed'] == true && $conf['nginx']['init_script'] != '' && is_file($conf['init_scripts'].'/'.$conf['nginx']['init_script'])) system($conf['init_scripts'].'/'.$conf['nginx']['init_script'].' restart &> /dev/null'); |
c91bdc
|
334 |
//if($conf['ufw']['installed'] == true && $conf['ufw']['init_script'] != '' && is_file($conf['init_scripts'].'/'.$conf['ufw']['init_script'])) system($conf['init_scripts'].'/'.$conf['ufw']['init_script'].' restart &> /dev/null'); |
532ae5
|
335 |
}else{ |
L |
336 |
|
|
337 |
//* In expert mode, we select the services in the following steps, only db is always available |
|
338 |
$conf['services']['mail'] = false; |
|
339 |
$conf['services']['web'] = false; |
|
340 |
$conf['services']['dns'] = false; |
|
341 |
$conf['services']['db'] = true; |
80e3c9
|
342 |
$conf['services']['firewall'] = false; |
T |
343 |
$conf['services']['proxy'] = false; |
532ae5
|
344 |
|
L |
345 |
|
|
346 |
//** Get Server ID |
|
347 |
// $conf['server_id'] = $inst->free_query('Unique Numeric ID of the server','1'); |
|
348 |
// Server ID is an autoInc value of the mysql database now |
|
349 |
|
|
350 |
if(strtolower($inst->simple_query('Shall this server join an existing ISPConfig multiserver setup',array('y','n'),'n')) == 'y') { |
|
351 |
$conf['mysql']['master_slave_setup'] = 'y'; |
|
352 |
|
|
353 |
//** Get MySQL root credentials |
|
354 |
$finished = false; |
|
355 |
do { |
|
356 |
$tmp_mysql_server_host = $inst->free_query('MySQL master server hostname', $conf['mysql']['master_host']); |
|
357 |
$tmp_mysql_server_admin_user = $inst->free_query('MySQL master server root username', $conf['mysql']['master_admin_user']); |
|
358 |
$tmp_mysql_server_admin_password = $inst->free_query('MySQL master server root password', $conf['mysql']['master_admin_password']); |
|
359 |
$tmp_mysql_server_database = $inst->free_query('MySQL master server database name', $conf['mysql']['master_database']); |
|
360 |
|
|
361 |
//* Initialize the MySQL server connection |
|
362 |
if(@mysql_connect($tmp_mysql_server_host, $tmp_mysql_server_admin_user, $tmp_mysql_server_admin_password)) { |
|
363 |
$conf['mysql']['master_host'] = $tmp_mysql_server_host; |
|
364 |
$conf['mysql']['master_admin_user'] = $tmp_mysql_server_admin_user; |
|
365 |
$conf['mysql']['master_admin_password'] = $tmp_mysql_server_admin_password; |
|
366 |
$conf['mysql']['master_database'] = $tmp_mysql_server_database; |
|
367 |
$finished = true; |
|
368 |
} else { |
|
369 |
swriteln($inst->lng('Unable to connect to mysql server').' '.mysql_error()); |
|
370 |
} |
|
371 |
} while ($finished == false); |
|
372 |
unset($finished); |
|
373 |
|
|
374 |
// initialize the connection to the master database |
|
375 |
$inst->dbmaster = new db(); |
|
376 |
if($inst->dbmaster->linkId) $inst->dbmaster->closeConn(); |
|
377 |
$inst->dbmaster->dbHost = $conf['mysql']["master_host"]; |
|
378 |
$inst->dbmaster->dbName = $conf['mysql']["master_database"]; |
|
379 |
$inst->dbmaster->dbUser = $conf['mysql']["master_admin_user"]; |
|
380 |
$inst->dbmaster->dbPass = $conf['mysql']["master_admin_password"]; |
|
381 |
|
|
382 |
} else { |
|
383 |
// the master DB is the same then the slave DB |
|
384 |
$inst->dbmaster = $inst->db; |
|
385 |
} |
|
386 |
|
|
387 |
//* Create the mysql database |
|
388 |
$inst->configure_database(); |
4ffb51
|
389 |
|
F |
390 |
//* Configure Webserver - Apache or nginx |
|
391 |
if($conf['apache']['installed'] == true && $conf['nginx']['installed'] == true) { |
|
392 |
$http_server_to_use = $inst->simple_query('Apache and nginx detected. Select server to use for ISPConfig:', array('apache','nginx'), 'apache'); |
|
393 |
if($http_server_to_use == 'apache'){ |
|
394 |
$conf['nginx']['installed'] = false; |
|
395 |
} else { |
|
396 |
$conf['apache']['installed'] = false; |
|
397 |
} |
|
398 |
} |
532ae5
|
399 |
|
L |
400 |
//* Insert the Server record into the database |
|
401 |
swriteln('Adding ISPConfig server record to database.'); |
|
402 |
swriteln(''); |
|
403 |
$inst->add_database_server_record(); |
|
404 |
|
|
405 |
|
|
406 |
if(strtolower($inst->simple_query('Configure Mail', array('y','n') ,'y') ) == 'y') { |
|
407 |
|
|
408 |
$conf['services']['mail'] = true; |
|
409 |
|
|
410 |
//* Configure Postfix |
|
411 |
swriteln('Configuring Postfix'); |
|
412 |
$inst->configure_postfix(); |
|
413 |
|
|
414 |
//* Configure Mailman |
|
415 |
swriteln('Configuring Mailman'); |
|
416 |
$inst->configure_mailman(); |
|
417 |
|
|
418 |
if($conf['dovecot']['installed'] == true) { |
|
419 |
//* Configure dovecot |
|
420 |
swriteln('Configuring Dovecot'); |
|
421 |
$inst->configure_dovecot(); |
|
422 |
} else { |
|
423 |
|
|
424 |
//* Configure saslauthd |
|
425 |
swriteln('Configuring SASL'); |
|
426 |
$inst->configure_saslauthd(); |
|
427 |
|
|
428 |
//* Configure PAM |
|
429 |
swriteln('Configuring PAM'); |
|
430 |
$inst->configure_pam(); |
|
431 |
|
|
432 |
//* Configure courier |
|
433 |
swriteln('Configuring Courier'); |
|
434 |
$inst->configure_courier(); |
|
435 |
} |
|
436 |
|
|
437 |
//* Configure Spamasassin |
|
438 |
swriteln('Configuring Spamassassin'); |
|
439 |
$inst->configure_spamassassin(); |
|
440 |
|
|
441 |
//* Configure Amavis |
|
442 |
swriteln('Configuring Amavisd'); |
|
443 |
$inst->configure_amavis(); |
|
444 |
|
|
445 |
//* Configure Getmail |
|
446 |
swriteln('Configuring Getmail'); |
|
447 |
$inst->configure_getmail(); |
|
448 |
|
|
449 |
if($conf['postfix']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['postfix']['init_script'])) system($conf['init_scripts'].'/'.$conf['postfix']['init_script'].' restart'); |
|
450 |
if($conf['saslauthd']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['saslauthd']['init_script'])) system($conf['init_scripts'].'/'.$conf['saslauthd']['init_script'].' restart'); |
|
451 |
if($conf['amavis']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['amavis']['init_script'])) system($conf['init_scripts'].'/'.$conf['amavis']['init_script'].' restart'); |
|
452 |
if($conf['clamav']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['clamav']['init_script'])) system($conf['init_scripts'].'/'.$conf['clamav']['init_script'].' restart'); |
|
453 |
if($conf['courier']['courier-authdaemon'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-authdaemon'])) system($conf['init_scripts'].'/'.$conf['courier']['courier-authdaemon'].' restart'); |
|
454 |
if($conf['courier']['courier-imap'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-imap'])) system($conf['init_scripts'].'/'.$conf['courier']['courier-imap'].' restart'); |
|
455 |
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'); |
|
456 |
if($conf['courier']['courier-pop'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-pop'])) system($conf['init_scripts'].'/'.$conf['courier']['courier-pop'].' restart'); |
|
457 |
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'); |
|
458 |
if($conf['dovecot']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['dovecot']['init_script'])) system($conf['init_scripts'].'/'.$conf['dovecot']['init_script'].' restart'); |
26c0fc
|
459 |
if($conf['mailman']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['mailman']['init_script'])) system('nohup '.$conf['init_scripts'].'/'.$conf['mailman']['init_script'].' restart >/dev/null 2>&1 &'); |
532ae5
|
460 |
} |
L |
461 |
|
|
462 |
//** Configure Jailkit |
|
463 |
if(strtolower($inst->simple_query('Configure Jailkit', array('y','n'),'y') ) == 'y') { |
|
464 |
swriteln('Configuring Jailkit'); |
|
465 |
$inst->configure_jailkit(); |
|
466 |
} |
|
467 |
|
|
468 |
//** Configure Pureftpd |
|
469 |
if(strtolower($inst->simple_query('Configure FTP Server', array('y','n'),'y') ) == 'y') { |
|
470 |
swriteln('Configuring Pureftpd'); |
|
471 |
$inst->configure_pureftpd(); |
|
472 |
if($conf['pureftpd']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['pureftpd']['init_script'])) system($conf['init_scripts'].'/'.$conf['pureftpd']['init_script'].' restart'); |
|
473 |
} |
|
474 |
|
|
475 |
//** Configure DNS |
|
476 |
if(strtolower($inst->simple_query('Configure DNS Server',array('y','n'),'y')) == 'y') { |
|
477 |
$conf['services']['dns'] = true; |
|
478 |
//* Configure DNS |
|
479 |
if($conf['powerdns']['installed'] == true) { |
|
480 |
swriteln('Configuring PowerDNS'); |
|
481 |
$inst->configure_powerdns(); |
|
482 |
if($conf['powerdns']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['powerdns']['init_script'])) system($conf['init_scripts'].'/'.$conf['powerdns']['init_script'].' restart &> /dev/null'); |
|
483 |
} elseif($conf['bind']['installed'] == true) { |
|
484 |
swriteln('Configuring BIND'); |
|
485 |
$inst->configure_bind(); |
|
486 |
if($conf['bind']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['bind']['init_script'])) system($conf['init_scripts'].'/'.$conf['bind']['init_script'].' restart &> /dev/null'); |
|
487 |
} else { |
|
488 |
swriteln('Configuring MyDNS'); |
|
489 |
$inst->configure_mydns(); |
|
490 |
if($conf['mydns']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['mydns']['init_script'])) system($conf['init_scripts'].'/'.$conf['mydns']['init_script'].' restart &> /dev/null'); |
|
491 |
} |
|
492 |
|
|
493 |
} |
|
494 |
|
4ffb51
|
495 |
/* |
80e3c9
|
496 |
//** Configure Squid |
T |
497 |
if(strtolower($inst->simple_query('Configure Proxy Server', array('y','n'),'y') ) == 'y') { |
|
498 |
if($conf['squid']['installed'] == true) { |
|
499 |
$conf['services']['proxy'] = true; |
|
500 |
swriteln('Configuring Squid'); |
|
501 |
$inst->configure_squid(); |
|
502 |
if($conf['squid']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['squid']['init_script']))system($conf['init_scripts'].'/'.$conf['squid']['init_script'].' restart &> /dev/null'); |
|
503 |
} else if($conf['nginx']['installed'] == true) { |
|
504 |
$conf['services']['proxy'] = true; |
|
505 |
swriteln('Configuring Nginx'); |
|
506 |
$inst->configure_nginx(); |
|
507 |
if($conf['nginx']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['nginx']['init_script']))system($conf['init_scripts'].'/'.$conf['nginx']['init_script'].' restart &> /dev/null'); |
|
508 |
} |
|
509 |
} |
4ffb51
|
510 |
*/ |
80e3c9
|
511 |
|
532ae5
|
512 |
//** Configure Apache |
4ffb51
|
513 |
if($conf['apache']['installed'] == true){ |
F |
514 |
swriteln("\nHint: If this server shall run the ISPConfig interface, select 'y' in the 'Configure Apache Server' option.\n"); |
|
515 |
if(strtolower($inst->simple_query('Configure Apache Server',array('y','n'),'y')) == 'y') { |
|
516 |
$conf['services']['web'] = true; |
|
517 |
swriteln('Configuring Apache'); |
|
518 |
$inst->configure_apache(); |
|
519 |
|
|
520 |
//** Configure Vlogger |
|
521 |
swriteln('Configuring Vlogger'); |
|
522 |
$inst->configure_vlogger(); |
|
523 |
|
|
524 |
//** Configure apps vhost |
|
525 |
swriteln('Configuring Apps vhost'); |
|
526 |
$inst->configure_apps_vhost(); |
|
527 |
} |
|
528 |
} |
|
529 |
|
|
530 |
//** Configure nginx |
|
531 |
if($conf['nginx']['installed'] == true){ |
|
532 |
swriteln("\nHint: If this server shall run the ISPConfig interface, select 'y' in the 'Configure nginx Server' option.\n"); |
|
533 |
if(strtolower($inst->simple_query('Configure nginx Server',array('y','n'),'y')) == 'y') { |
|
534 |
$conf['services']['web'] = true; |
|
535 |
swriteln('Configuring nginx'); |
|
536 |
$inst->configure_nginx(); |
|
537 |
|
|
538 |
//** Configure Vlogger |
|
539 |
//swriteln('Configuring Vlogger'); |
|
540 |
//$inst->configure_vlogger(); |
|
541 |
|
|
542 |
//** Configure apps vhost |
|
543 |
swriteln('Configuring Apps vhost'); |
|
544 |
$inst->configure_apps_vhost(); |
|
545 |
} |
532ae5
|
546 |
} |
L |
547 |
|
|
548 |
//** Configure Firewall |
|
549 |
if(strtolower($inst->simple_query('Configure Firewall Server',array('y','n'),'y')) == 'y') { |
8cf955
|
550 |
//if($conf['bastille']['installed'] == true) { |
80e3c9
|
551 |
//* Configure Bastille Firewall |
T |
552 |
$conf['services']['firewall'] = true; |
|
553 |
swriteln('Configuring Bastille Firewall'); |
|
554 |
$inst->configure_firewall(); |
8cf955
|
555 |
/*} elseif($conf['ufw']['installed'] == true) { |
80e3c9
|
556 |
//* Configure Ubuntu Firewall |
T |
557 |
$conf['services']['firewall'] = true; |
|
558 |
swriteln('Configuring Ubuntu Firewall'); |
|
559 |
$inst->configure_ufw_firewall(); |
|
560 |
} |
8cf955
|
561 |
*/ |
80e3c9
|
562 |
} |
T |
563 |
|
|
564 |
//** Configure Firewall |
|
565 |
/*if(strtolower($inst->simple_query('Configure Firewall Server',array('y','n'),'y')) == 'y') { |
532ae5
|
566 |
swriteln('Configuring Firewall'); |
L |
567 |
$inst->configure_firewall(); |
80e3c9
|
568 |
}*/ |
T |
569 |
|
532ae5
|
570 |
//** Configure ISPConfig :-) |
cc434c
|
571 |
$install_ispconfig_interface_default = ($conf['mysql']['master_slave_setup'] == 'y')?'n':'y'; |
T |
572 |
if(strtolower($inst->simple_query('Install ISPConfig Web Interface',array('y','n'),$install_ispconfig_interface_default)) == 'y') { |
532ae5
|
573 |
swriteln('Installing ISPConfig'); |
L |
574 |
|
|
575 |
//** We want to check if the server is a module or cgi based php enabled server |
|
576 |
//** TODO: Don't always ask for this somehow ? |
|
577 |
/* |
|
578 |
$fast_cgi = $inst->simple_query('CGI PHP Enabled Server?', array('yes','no'),'no'); |
|
579 |
|
|
580 |
if($fast_cgi == 'yes') { |
|
581 |
$alias = $inst->free_query('Script Alias', '/php/'); |
|
582 |
$path = $inst->free_query('Script Alias Path', '/path/to/cgi/bin'); |
|
583 |
$conf['apache']['vhost_cgi_alias'] = sprintf('ScriptAlias %s %s', $alias, $path); |
|
584 |
} else { |
|
585 |
$conf['apache']['vhost_cgi_alias'] = ""; |
|
586 |
} |
|
587 |
*/ |
|
588 |
|
|
589 |
//** Customise the port ISPConfig runs on |
4ffb51
|
590 |
$ispconfig_vhost_port = $inst->free_query('ISPConfig Port', '8080'); |
F |
591 |
if($conf['apache']['installed'] == true) $conf['apache']['vhost_port'] = $ispconfig_vhost_port; |
|
592 |
if($conf['nginx']['installed'] == true) $conf['nginx']['vhost_port'] = $ispconfig_vhost_port; |
|
593 |
unset($ispconfig_vhost_port); |
532ae5
|
594 |
|
L |
595 |
if(strtolower($inst->simple_query('Enable SSL for the ISPConfig web interface',array('y','n'),'y')) == 'y') { |
|
596 |
$inst->make_ispconfig_ssl_cert(); |
|
597 |
} |
|
598 |
|
|
599 |
$inst->install_ispconfig_interface = true; |
|
600 |
|
|
601 |
} else { |
|
602 |
$inst->install_ispconfig_interface = false; |
|
603 |
} |
|
604 |
|
|
605 |
$inst->install_ispconfig(); |
|
606 |
|
|
607 |
//* Configure DBServer |
|
608 |
swriteln('Configuring DBServer'); |
|
609 |
$inst->configure_dbserver(); |
|
610 |
|
|
611 |
//* Configure ISPConfig |
|
612 |
swriteln('Installing ISPConfig crontab'); |
|
613 |
$inst->install_crontab(); |
4ffb51
|
614 |
if($conf['apache']['installed'] == true && $conf['apache']['init_script'] != '' && @is_file($conf['init_scripts'].'/'.$conf['apache']['init_script'])) system($conf['init_scripts'].'/'.$conf['apache']['init_script'].' restart'); |
F |
615 |
//* Reload is enough for nginx |
|
616 |
if($conf['nginx']['installed'] == true){ |
|
617 |
if($conf['nginx']['php_fpm_init_script'] != '' && @is_file($conf['init_scripts'].'/'.$conf['nginx']['php_fpm_init_script'])) system($conf['init_scripts'].'/'.$conf['nginx']['php_fpm_init_script'].' reload'); |
|
618 |
if($conf['nginx']['init_script'] != '' && @is_file($conf['init_scripts'].'/'.$conf['nginx']['init_script'])) system($conf['init_scripts'].'/'.$conf['nginx']['init_script'].' reload'); |
|
619 |
} |
532ae5
|
620 |
|
L |
621 |
|
|
622 |
|
|
623 |
} //* << $install_mode / 'Standard' or Genius |
|
624 |
|
|
625 |
|
|
626 |
echo "Installation completed.\n"; |
|
627 |
|
|
628 |
|
c12af9
|
629 |
?> |