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