commit | author | age
|
9200ad
|
1 |
<?php |
T |
2 |
|
|
3 |
/* |
|
4 |
Copyright (c) 2007, 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 |
|
57706b
|
35 |
//** Check for existing installation |
ce9544
|
36 |
//if(is_dir("/usr/local/ispconfig")) die('We will stop here. There is already a ISPConfig installation, use the update script to update this installation.'); |
T |
37 |
|
c87c0a
|
38 |
error_reporting(E_ALL|E_STRICT); |
P |
39 |
|
dc7d8b
|
40 |
//** The banner on the command line |
P |
41 |
echo "\n\n".str_repeat('-',80)."\n"; |
|
42 |
echo " _____ ___________ _____ __ _ |
|
43 |
|_ _/ ___| ___ \ / __ \ / _(_) |
|
44 |
| | \ `--.| |_/ / | / \/ ___ _ __ | |_ _ __ _ |
|
45 |
| | `--. \ __/ | | / _ \| '_ \| _| |/ _` | |
|
46 |
_| |_/\__/ / | | \__/\ (_) | | | | | | | (_| | |
|
47 |
\___/\____/\_| \____/\___/|_| |_|_| |_|\__, | |
|
48 |
__/ | |
|
49 |
|___/ "; |
d5cf65
|
50 |
echo "\n".str_repeat('-',80)."\n"; |
P |
51 |
echo "\n\n>> Initial configuration \n\n"; |
ce9544
|
52 |
|
57706b
|
53 |
//** Include the library with the basic installer functions |
9200ad
|
54 |
require_once('lib/install.lib.php'); |
T |
55 |
|
57706b
|
56 |
//** Include the base class of the installer class |
9200ad
|
57 |
require_once('lib/installer_base.lib.php'); |
T |
58 |
|
cc3fb3
|
59 |
//** Get distribution identifier |
344393
|
60 |
$dist = get_distname(); |
9200ad
|
61 |
|
344393
|
62 |
if($dist['id'] == '') die('Linux Dustribution or Version not recognized.'); |
f629e2
|
63 |
|
cc3fb3
|
64 |
//** Include the distribution specific installer class library and configuration |
90511b
|
65 |
if(is_file('dist/lib/'.$dist['baseid'].'.lib.php')) include_once('dist/lib/'.$dist['baseid'].'.lib.php'); |
344393
|
66 |
include_once('dist/lib/'.$dist['id'].'.lib.php'); |
T |
67 |
include_once('dist/conf/'.$dist['id'].'.conf.php'); |
cc3fb3
|
68 |
|
O |
69 |
//** Install logfile |
66b4f9
|
70 |
define('ISPC_LOG_FILE', '/var/log/ispconfig_install.log'); |
P |
71 |
|
facccb
|
72 |
//**************************************************************************************************** |
P |
73 |
//** Installer Interface |
|
74 |
//**************************************************************************************************** |
9200ad
|
75 |
$inst = new installer(); |
d5cf65
|
76 |
swriteln($inst->lng(' Following will be a few questions for primary configuration so be careful.')); |
facccb
|
77 |
swriteln($inst->lng(' Default values are in [brackets] and can be accepted with <ENTER>.')); |
P |
78 |
swriteln($inst->lng(' Tap in "quit" (without the quotes) to stop the installer.'."\n\n")); |
9200ad
|
79 |
|
4fe86d
|
80 |
//** Check log file is writable (probably not root or sudo) |
cc3fb3
|
81 |
if(!is_writable(dirname(ISPC_LOG_FILE))){ |
O |
82 |
die("ERROR: Cannot write to the directory ".dirname(ISPC_LOG_FILE).". Are you root or sudo ?\n\n"); |
66b4f9
|
83 |
} |
P |
84 |
|
0c0d28
|
85 |
if(is_dir('/root/ispconfig') || is_dir('/home/admispconfig')) { |
T |
86 |
die('This software can not be installed on a server wich runs ISPConfig 2.x.'); |
|
87 |
} |
|
88 |
|
57706b
|
89 |
//** Select the language |
P |
90 |
$conf['language'] = $inst->simple_query('Select language', array('en','de'), 'en'); |
9200ad
|
91 |
|
57706b
|
92 |
//** Select installation mode |
P |
93 |
$install_mode = $inst->simple_query('Installation mode', array('Standard','Expert'), 'Standard'); |
9200ad
|
94 |
|
66b4f9
|
95 |
|
57706b
|
96 |
//** Get the hostname |
ce9544
|
97 |
$tmp_out = array(); |
57706b
|
98 |
exec('hostname -f', $tmp_out); |
cd972d
|
99 |
$conf['hostname'] = $inst->free_query('Full qualified hostname (FQDN) of the server, eg foo.example.com ', $tmp_out[0]); |
ce9544
|
100 |
unset($tmp_out); |
T |
101 |
|
57706b
|
102 |
//** Get MySQL root credentials |
ce9544
|
103 |
$finished = false; |
T |
104 |
do { |
dc7d8b
|
105 |
$tmp_mysql_server_host = $inst->free_query('MySQL server hostname', $conf['mysql']['host']); |
P |
106 |
$tmp_mysql_server_admin_user = $inst->free_query('MySQL root username', $conf['mysql']['admin_user']); |
|
107 |
$tmp_mysql_server_admin_password = $inst->free_query('MySQL root password', $conf['mysql']['admin_password']); |
b0a1cc
|
108 |
$tmp_mysql_server_database = $inst->free_query('MySQL database to create', $conf['mysql']['database']); |
239ce8
|
109 |
|
57706b
|
110 |
//* Initialize the MySQL server connection |
239ce8
|
111 |
if(@mysql_connect($tmp_mysql_server_host, $tmp_mysql_server_admin_user, $tmp_mysql_server_admin_password)) { |
57706b
|
112 |
$conf['mysql']['host'] = $tmp_mysql_server_host; |
P |
113 |
$conf['mysql']['admin_user'] = $tmp_mysql_server_admin_user; |
|
114 |
$conf['mysql']['admin_password'] = $tmp_mysql_server_admin_password; |
b0a1cc
|
115 |
$conf['mysql']['database'] = $tmp_mysql_server_database; |
ce9544
|
116 |
$finished = true; |
239ce8
|
117 |
} else { |
57706b
|
118 |
swriteln($inst->lng('Unable to connect to mysql server').' '.mysql_error()); |
ce9544
|
119 |
} |
T |
120 |
} while ($finished == false); |
239ce8
|
121 |
unset($finished); |
cd972d
|
122 |
|
T |
123 |
// Resolve the IP address of the mysql hostname. |
|
124 |
if(!$conf['mysql']['ip'] = gethostbyname($conf['mysql']['host'])) die('Unable to resolve hostname'.$conf['mysql']['host']); |
|
125 |
|
9200ad
|
126 |
|
57706b
|
127 |
//** initializing database connection |
239ce8
|
128 |
include_once('lib/mysql.lib.php'); |
T |
129 |
$inst->db = new db(); |
9200ad
|
130 |
|
57706b
|
131 |
//** Begin with standard or expert installation |
ce9544
|
132 |
if($install_mode == 'Standard') { |
T |
133 |
|
57706b
|
134 |
//* Create the mysql database |
ce9544
|
135 |
$inst->configure_database(); |
94411b
|
136 |
|
T |
137 |
//* Insert the Server record into the database |
|
138 |
$inst->add_database_server_record(); |
9200ad
|
139 |
|
57706b
|
140 |
//* Configure postfix |
ce9544
|
141 |
$inst->configure_postfix(); |
61d290
|
142 |
|
D |
143 |
//* Configure postfix |
|
144 |
swriteln('Configuring Jailkit'); |
|
145 |
$inst->configure_jailkit(); |
9200ad
|
146 |
|
57706b
|
147 |
//* Configure saslauthd |
ce9544
|
148 |
swriteln('Configuring SASL'); |
T |
149 |
$inst->configure_saslauthd(); |
9200ad
|
150 |
|
57706b
|
151 |
//* Configure PAM |
ce9544
|
152 |
swriteln('Configuring PAM'); |
T |
153 |
$inst->configure_pam(); |
ba747c
|
154 |
|
57706b
|
155 |
//* Configure courier |
ce9544
|
156 |
swriteln('Configuring Courier'); |
T |
157 |
$inst->configure_courier(); |
99d85e
|
158 |
|
57706b
|
159 |
//* Configure Spamasassin |
ce9544
|
160 |
swriteln('Configuring Spamassassin'); |
T |
161 |
$inst->configure_spamassassin(); |
b4c750
|
162 |
|
57706b
|
163 |
//* Configure Amavis |
ce9544
|
164 |
swriteln('Configuring Amavisd'); |
T |
165 |
$inst->configure_amavis(); |
9200ad
|
166 |
|
57706b
|
167 |
//* Configure Getmail |
ce9544
|
168 |
swriteln('Configuring Getmail'); |
T |
169 |
$inst->configure_getmail(); |
|
170 |
|
daff5c
|
171 |
|
57706b
|
172 |
//* Configure Pureftpd |
ce9544
|
173 |
swriteln('Configuring Pureftpd'); |
T |
174 |
$inst->configure_pureftpd(); |
9200ad
|
175 |
|
57706b
|
176 |
//* Configure MyDNS |
ce9544
|
177 |
swriteln('Configuring MyDNS'); |
T |
178 |
$inst->configure_mydns(); |
313e33
|
179 |
|
57706b
|
180 |
//* Configure Apache |
313e33
|
181 |
swriteln('Configuring Apache'); |
T |
182 |
$inst->configure_apache(); |
7c99ef
|
183 |
|
T |
184 |
//* Configure Firewall |
|
185 |
swriteln('Configuring Firewall'); |
|
186 |
$inst->configure_firewall(); |
9200ad
|
187 |
|
57706b
|
188 |
//* Configure ISPConfig |
ce9544
|
189 |
swriteln('Installing ISPConfig'); |
9b9ba4
|
190 |
|
D |
191 |
//** Customise the port ISPConfig runs on |
cd972d
|
192 |
$conf['apache']['vhost_port'] = $inst->free_query('ISPConfig Port', '8080'); |
9b9ba4
|
193 |
|
ce9544
|
194 |
$inst->install_ispconfig(); |
d83fcf
|
195 |
|
T |
196 |
//* Configure DBServer |
|
197 |
swriteln('Configuring DBServer'); |
|
198 |
$inst->configure_dbserver(); |
9200ad
|
199 |
|
57706b
|
200 |
//* Configure ISPConfig |
ce9544
|
201 |
swriteln('Installing Crontab'); |
T |
202 |
$inst->install_crontab(); |
|
203 |
|
|
204 |
swriteln('Restarting services ...'); |
cc3fb3
|
205 |
system($conf['init_scripts'].'/'.$conf['mysql']['init_script'].' restart'); |
O |
206 |
system($conf['init_scripts'].'/'.$conf['postfix']['init_script'].' restart'); |
|
207 |
system($conf['init_scripts'].'/'.$conf['saslauthd']['init_script'].' restart'); |
|
208 |
system($conf['init_scripts'].'/'.$conf['amavis']['init_script'].' restart'); |
|
209 |
system($conf['init_scripts'].'/'.$conf['clamav']['init_script'].' restart'); |
|
210 |
system($conf['init_scripts'].'/'.$conf['courier']['courier-authdaemon'].' restart'); |
|
211 |
system($conf['init_scripts'].'/'.$conf['courier']['courier-imap'].' restart'); |
|
212 |
system($conf['init_scripts'].'/'.$conf['courier']['courier-imap-ssl'].' restart'); |
|
213 |
system($conf['init_scripts'].'/'.$conf['courier']['courier-pop'].' restart'); |
|
214 |
system($conf['init_scripts'].'/'.$conf['courier']['courier-pop-ssl'].' restart'); |
|
215 |
system($conf['init_scripts'].'/'.$conf['apache']['init_script'].' restart'); |
|
216 |
system($conf['init_scripts'].'/'.$conf['pureftpd']['init_script'].' restart'); |
7d89f5
|
217 |
system($conf['init_scripts'].'/'.$conf['mydns']['init_script'].' restart &> /dev/null'); |
ce9544
|
218 |
|
57706b
|
219 |
}else{ |
P |
220 |
|
|
221 |
//** Get Server ID |
94411b
|
222 |
// $conf['server_id'] = $inst->free_query('Unique Numeric ID of the server','1'); |
T |
223 |
// Server ID is an autoInc value of the mysql database now |
ce9544
|
224 |
|
4cc3fc
|
225 |
if(strtolower($inst->simple_query('Create a new database? (We do not want to join a existing ISPConfig server setup)',array('y','n'),'y')) == 'y') { |
57706b
|
226 |
//* Create the mysql database |
ce9544
|
227 |
$inst->configure_database(); |
f1b989
|
228 |
//system('/etc/init.d/mysql restart'); |
ce9544
|
229 |
} |
ee0e1c
|
230 |
|
T |
231 |
//* Insert the Server record into the database |
a768b9
|
232 |
swriteln('Adding ISPConfig server record to database.'); |
81b5e2
|
233 |
swriteln(''); |
ee0e1c
|
234 |
$inst->add_database_server_record(); |
T |
235 |
|
ce9544
|
236 |
|
57706b
|
237 |
if(strtolower($inst->simple_query('Configure Mail', array('y','n') ,'y') ) == 'y') { |
ce9544
|
238 |
|
57706b
|
239 |
//* Configure Postfix |
ce9544
|
240 |
swriteln('Configuring Postfix'); |
T |
241 |
$inst->configure_postfix(); |
|
242 |
|
57706b
|
243 |
//* Configure PAM |
ce9544
|
244 |
swriteln('Configuring PAM'); |
T |
245 |
$inst->configure_pam(); |
|
246 |
|
57706b
|
247 |
//* Configure courier |
ce9544
|
248 |
swriteln('Configuring Courier'); |
T |
249 |
$inst->configure_courier(); |
|
250 |
|
57706b
|
251 |
//* Configure Spamasassin |
ce9544
|
252 |
swriteln('Configuring Spamassassin'); |
T |
253 |
$inst->configure_spamassassin(); |
|
254 |
|
57706b
|
255 |
//* Configure Amavis |
ce9544
|
256 |
swriteln('Configuring Amavisd'); |
T |
257 |
$inst->configure_amavis(); |
|
258 |
|
57706b
|
259 |
//* Configure Getmail |
ce9544
|
260 |
swriteln('Configuring Getmail'); |
T |
261 |
$inst->configure_getmail(); |
|
262 |
|
cc3fb3
|
263 |
system($conf['init_scripts'].'/'.$conf['postfix']['init_script'].' restart'); |
O |
264 |
system($conf['init_scripts'].'/'.$conf['saslauthd']['init_script'].' restart'); |
|
265 |
system($conf['init_scripts'].'/'.$conf['amavis']['init_script'].' restart'); |
|
266 |
system($conf['init_scripts'].'/'.$conf['clamav']['init_script'].' restart'); |
|
267 |
system($conf['init_scripts'].'/'.$conf['courier']['courier-authdaemon'].' restart'); |
|
268 |
system($conf['init_scripts'].'/'.$conf['courier']['courier-imap'].' restart'); |
|
269 |
system($conf['init_scripts'].'/'.$conf['courier']['courier-imap-ssl'].' restart'); |
|
270 |
system($conf['init_scripts'].'/'.$conf['courier']['courier-pop'].' restart'); |
|
271 |
system($conf['init_scripts'].'/'.$conf['courier']['courier-pop-ssl'].' restart'); |
ce9544
|
272 |
} |
T |
273 |
|
57706b
|
274 |
//** Configure Pureftpd |
P |
275 |
if(strtolower($inst->simple_query('Configure FTP Server', array('y','n'),'y') ) == 'y') { |
ce9544
|
276 |
swriteln('Configuring Pureftpd'); |
T |
277 |
$inst->configure_pureftpd(); |
cc3fb3
|
278 |
system($conf['init_scripts'].'/'.$conf['pureftpd']['init_script'].' restart'); |
ce9544
|
279 |
} |
T |
280 |
|
57706b
|
281 |
//** Configure MyDNS |
ce9544
|
282 |
if(strtolower($inst->simple_query('Configure DNS Server',array('y','n'),'y')) == 'y') { |
T |
283 |
swriteln('Configuring MyDNS'); |
|
284 |
$inst->configure_mydns(); |
cc3fb3
|
285 |
system($conf['init_scripts'].'/'.$conf['mydns']['init_script'].' restart'); |
ce9544
|
286 |
} |
T |
287 |
|
57706b
|
288 |
//** Configure Apache |
P |
289 |
if(strtolower($inst->simple_query('Configure Apache Server',array('y','n'),'y')) == 'y') { |
313e33
|
290 |
swriteln('Configuring Apache'); |
T |
291 |
$inst->configure_apache(); |
|
292 |
} |
|
293 |
|
7c99ef
|
294 |
//** Configure Firewall |
T |
295 |
if(strtolower($inst->simple_query('Configure Firewall Server',array('y','n'),'y')) == 'y') { |
|
296 |
swriteln('Configuring Firewall'); |
|
297 |
$inst->configure_firewall(); |
|
298 |
} |
|
299 |
|
57706b
|
300 |
//** Configure ISPConfig :-) |
ac4a37
|
301 |
if(strtolower($inst->simple_query('Install ISPConfig Web-Interface',array('y','n'),'y')) == 'y') { |
ce9544
|
302 |
swriteln('Installing ISPConfig'); |
54c0c3
|
303 |
|
T |
304 |
//** We want to check if the server is a module or cgi based php enabled server |
a768b9
|
305 |
//** TODO: Don't always ask for this somehow ? |
T |
306 |
/* |
54c0c3
|
307 |
$fast_cgi = $inst->simple_query('CGI PHP Enabled Server?', array('yes','no'),'no'); |
T |
308 |
|
|
309 |
if($fast_cgi == 'yes') { |
|
310 |
$alias = $inst->free_query('Script Alias', '/php/'); |
|
311 |
$path = $inst->free_query('Script Alias Path', '/path/to/cgi/bin'); |
cd972d
|
312 |
$conf['apache']['vhost_cgi_alias'] = sprintf('ScriptAlias %s %s', $alias, $path); |
54c0c3
|
313 |
} else { |
cd972d
|
314 |
$conf['apache']['vhost_cgi_alias'] = ""; |
54c0c3
|
315 |
} |
a768b9
|
316 |
*/ |
54c0c3
|
317 |
|
T |
318 |
//** Customise the port ISPConfig runs on |
cd972d
|
319 |
$conf['apache']['vhost_port'] = $inst->free_query('ISPConfig Port', '8080'); |
54c0c3
|
320 |
|
ac4a37
|
321 |
$inst->install_ispconfig_interface = true; |
T |
322 |
|
|
323 |
} else { |
|
324 |
$inst->install_ispconfig_interface = false; |
ce9544
|
325 |
} |
T |
326 |
|
ac4a37
|
327 |
$inst->install_ispconfig(); |
d83fcf
|
328 |
|
T |
329 |
//* Configure DBServer |
|
330 |
swriteln('Configuring DBServer'); |
|
331 |
$inst->configure_dbserver(); |
ac4a37
|
332 |
|
T |
333 |
//* Configure ISPConfig |
|
334 |
swriteln('Installing Crontab'); |
|
335 |
$inst->install_crontab(); |
|
336 |
system($conf['init_scripts'].'/'.$conf['apache']['init_script'].' restart'); |
|
337 |
|
|
338 |
|
|
339 |
|
57706b
|
340 |
} //* << $install_mode / 'Standard' or Genius |
ce9544
|
341 |
|
9200ad
|
342 |
|
57706b
|
343 |
echo "Installation completed.\n"; |
9200ad
|
344 |
|
T |
345 |
|
57706b
|
346 |
?> |