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 |
438d9f
|
60 |
$distname = get_distname(); |
9200ad
|
61 |
|
f629e2
|
62 |
if($distname == '') die('Linux Dustribution or Version not recognized.'); |
T |
63 |
|
cc3fb3
|
64 |
//** Include the distribution specific installer class library and configuration |
O |
65 |
include_once('dist/lib/'.$distname.'.lib.php'); |
|
66 |
include_once('dist/conf/'.$distname.'.conf.php'); |
|
67 |
|
|
68 |
//** Install logfile |
66b4f9
|
69 |
define('ISPC_LOG_FILE', '/var/log/ispconfig_install.log'); |
P |
70 |
|
facccb
|
71 |
//**************************************************************************************************** |
P |
72 |
//** Installer Interface |
|
73 |
//**************************************************************************************************** |
9200ad
|
74 |
$inst = new installer(); |
d5cf65
|
75 |
swriteln($inst->lng(' Following will be a few questions for primary configuration so be careful.')); |
facccb
|
76 |
swriteln($inst->lng(' Default values are in [brackets] and can be accepted with <ENTER>.')); |
P |
77 |
swriteln($inst->lng(' Tap in "quit" (without the quotes) to stop the installer.'."\n\n")); |
9200ad
|
78 |
|
4fe86d
|
79 |
//** Check log file is writable (probably not root or sudo) |
cc3fb3
|
80 |
if(!is_writable(dirname(ISPC_LOG_FILE))){ |
O |
81 |
die("ERROR: Cannot write to the directory ".dirname(ISPC_LOG_FILE).". Are you root or sudo ?\n\n"); |
66b4f9
|
82 |
} |
P |
83 |
|
57706b
|
84 |
//** Select the language |
P |
85 |
$conf['language'] = $inst->simple_query('Select language', array('en','de'), 'en'); |
9200ad
|
86 |
|
57706b
|
87 |
//** Select installation mode |
P |
88 |
$install_mode = $inst->simple_query('Installation mode', array('Standard','Expert'), 'Standard'); |
9200ad
|
89 |
|
66b4f9
|
90 |
|
57706b
|
91 |
//** Get the hostname |
ce9544
|
92 |
$tmp_out = array(); |
57706b
|
93 |
exec('hostname -f', $tmp_out); |
cc3fb3
|
94 |
$inst->conf['hostname'] = $inst->free_query('Full qualified hostname (FQDN) of the server, eg foo.example.com ', $tmp_out[0]); |
ce9544
|
95 |
unset($tmp_out); |
T |
96 |
|
57706b
|
97 |
//** Get MySQL root credentials |
ce9544
|
98 |
$finished = false; |
T |
99 |
do { |
dc7d8b
|
100 |
$tmp_mysql_server_host = $inst->free_query('MySQL server hostname', $conf['mysql']['host']); |
P |
101 |
$tmp_mysql_server_admin_user = $inst->free_query('MySQL root username', $conf['mysql']['admin_user']); |
|
102 |
$tmp_mysql_server_admin_password = $inst->free_query('MySQL root password', $conf['mysql']['admin_password']); |
b0a1cc
|
103 |
$tmp_mysql_server_database = $inst->free_query('MySQL database to create', $conf['mysql']['database']); |
239ce8
|
104 |
|
57706b
|
105 |
//* Initialize the MySQL server connection |
239ce8
|
106 |
if(@mysql_connect($tmp_mysql_server_host, $tmp_mysql_server_admin_user, $tmp_mysql_server_admin_password)) { |
57706b
|
107 |
$conf['mysql']['host'] = $tmp_mysql_server_host; |
P |
108 |
$conf['mysql']['admin_user'] = $tmp_mysql_server_admin_user; |
|
109 |
$conf['mysql']['admin_password'] = $tmp_mysql_server_admin_password; |
b0a1cc
|
110 |
$conf['mysql']['database'] = $tmp_mysql_server_database; |
ce9544
|
111 |
$finished = true; |
239ce8
|
112 |
} else { |
57706b
|
113 |
swriteln($inst->lng('Unable to connect to mysql server').' '.mysql_error()); |
ce9544
|
114 |
} |
T |
115 |
} while ($finished == false); |
239ce8
|
116 |
unset($finished); |
9200ad
|
117 |
|
57706b
|
118 |
//** initializing database connection |
239ce8
|
119 |
include_once('lib/mysql.lib.php'); |
T |
120 |
$inst->db = new db(); |
9200ad
|
121 |
|
57706b
|
122 |
//** Begin with standard or expert installation |
ce9544
|
123 |
if($install_mode == 'Standard') { |
T |
124 |
|
57706b
|
125 |
//* Create the mysql database |
ce9544
|
126 |
$inst->configure_database(); |
9200ad
|
127 |
|
57706b
|
128 |
//* Configure postfix |
ce9544
|
129 |
$inst->configure_postfix(); |
9200ad
|
130 |
|
57706b
|
131 |
//* Configure saslauthd |
ce9544
|
132 |
swriteln('Configuring SASL'); |
T |
133 |
$inst->configure_saslauthd(); |
9200ad
|
134 |
|
57706b
|
135 |
//* Configure PAM |
ce9544
|
136 |
swriteln('Configuring PAM'); |
T |
137 |
$inst->configure_pam(); |
ba747c
|
138 |
|
57706b
|
139 |
//* Configure courier |
ce9544
|
140 |
swriteln('Configuring Courier'); |
T |
141 |
$inst->configure_courier(); |
99d85e
|
142 |
|
57706b
|
143 |
//* Configure Spamasassin |
ce9544
|
144 |
swriteln('Configuring Spamassassin'); |
T |
145 |
$inst->configure_spamassassin(); |
b4c750
|
146 |
|
57706b
|
147 |
//* Configure Amavis |
ce9544
|
148 |
swriteln('Configuring Amavisd'); |
T |
149 |
$inst->configure_amavis(); |
9200ad
|
150 |
|
57706b
|
151 |
//* Configure Getmail |
ce9544
|
152 |
swriteln('Configuring Getmail'); |
T |
153 |
$inst->configure_getmail(); |
|
154 |
|
daff5c
|
155 |
|
57706b
|
156 |
//* Configure Pureftpd |
ce9544
|
157 |
swriteln('Configuring Pureftpd'); |
T |
158 |
$inst->configure_pureftpd(); |
9200ad
|
159 |
|
57706b
|
160 |
//* Configure MyDNS |
ce9544
|
161 |
swriteln('Configuring MyDNS'); |
T |
162 |
$inst->configure_mydns(); |
313e33
|
163 |
|
57706b
|
164 |
//* Configure Apache |
313e33
|
165 |
swriteln('Configuring Apache'); |
T |
166 |
$inst->configure_apache(); |
9200ad
|
167 |
|
57706b
|
168 |
//* Configure ISPConfig |
ce9544
|
169 |
swriteln('Installing ISPConfig'); |
T |
170 |
$inst->install_ispconfig(); |
9200ad
|
171 |
|
57706b
|
172 |
//* Configure ISPConfig |
ce9544
|
173 |
swriteln('Installing Crontab'); |
T |
174 |
$inst->install_crontab(); |
|
175 |
|
|
176 |
swriteln('Restarting services ...'); |
cc3fb3
|
177 |
system($conf['init_scripts'].'/'.$conf['mysql']['init_script'].' restart'); |
O |
178 |
system($conf['init_scripts'].'/'.$conf['postfix']['init_script'].' restart'); |
|
179 |
system($conf['init_scripts'].'/'.$conf['saslauthd']['init_script'].' restart'); |
|
180 |
system($conf['init_scripts'].'/'.$conf['amavis']['init_script'].' restart'); |
|
181 |
system($conf['init_scripts'].'/'.$conf['clamav']['init_script'].' restart'); |
|
182 |
system($conf['init_scripts'].'/'.$conf['courier']['courier-authdaemon'].' restart'); |
|
183 |
system($conf['init_scripts'].'/'.$conf['courier']['courier-imap'].' restart'); |
|
184 |
system($conf['init_scripts'].'/'.$conf['courier']['courier-imap-ssl'].' restart'); |
|
185 |
system($conf['init_scripts'].'/'.$conf['courier']['courier-pop'].' restart'); |
|
186 |
system($conf['init_scripts'].'/'.$conf['courier']['courier-pop-ssl'].' restart'); |
|
187 |
system($conf['init_scripts'].'/'.$conf['apache']['init_script'].' restart'); |
|
188 |
system($conf['init_scripts'].'/'.$conf['pureftpd']['init_script'].' restart'); |
|
189 |
system($conf['init_scripts'].'/'.$conf['mydns']['init_script'].' restart'); |
ce9544
|
190 |
|
57706b
|
191 |
}else{ |
P |
192 |
|
|
193 |
//** Get Server ID |
|
194 |
$conf['server_id'] = $inst->free_query('Unique Numeric ID of the server','1'); |
ce9544
|
195 |
|
T |
196 |
if(strtolower($inst->simple_query('Create Database',array('y','n'),'y')) == 'y') { |
57706b
|
197 |
//* Create the mysql database |
ce9544
|
198 |
$inst->configure_database(); |
57706b
|
199 |
system('/etc/init.d/mysql restart'); |
ce9544
|
200 |
} |
T |
201 |
|
57706b
|
202 |
if(strtolower($inst->simple_query('Configure Mail', array('y','n') ,'y') ) == 'y') { |
ce9544
|
203 |
|
57706b
|
204 |
//* Configure Postfix |
ce9544
|
205 |
swriteln('Configuring Postfix'); |
T |
206 |
$inst->configure_postfix(); |
|
207 |
|
57706b
|
208 |
//* Configure PAM |
ce9544
|
209 |
swriteln('Configuring PAM'); |
T |
210 |
$inst->configure_pam(); |
|
211 |
|
57706b
|
212 |
//* Configure courier |
ce9544
|
213 |
swriteln('Configuring Courier'); |
T |
214 |
$inst->configure_courier(); |
|
215 |
|
57706b
|
216 |
//* Configure Spamasassin |
ce9544
|
217 |
swriteln('Configuring Spamassassin'); |
T |
218 |
$inst->configure_spamassassin(); |
|
219 |
|
57706b
|
220 |
//* Configure Amavis |
ce9544
|
221 |
swriteln('Configuring Amavisd'); |
T |
222 |
$inst->configure_amavis(); |
|
223 |
|
57706b
|
224 |
//* Configure Getmail |
ce9544
|
225 |
swriteln('Configuring Getmail'); |
T |
226 |
$inst->configure_getmail(); |
|
227 |
|
cc3fb3
|
228 |
system($conf['init_scripts'].'/'.$conf['postfix']['init_script'].' restart'); |
O |
229 |
system($conf['init_scripts'].'/'.$conf['saslauthd']['init_script'].' restart'); |
|
230 |
system($conf['init_scripts'].'/'.$conf['amavis']['init_script'].' restart'); |
|
231 |
system($conf['init_scripts'].'/'.$conf['clamav']['init_script'].' restart'); |
|
232 |
system($conf['init_scripts'].'/'.$conf['courier']['courier-authdaemon'].' restart'); |
|
233 |
system($conf['init_scripts'].'/'.$conf['courier']['courier-imap'].' restart'); |
|
234 |
system($conf['init_scripts'].'/'.$conf['courier']['courier-imap-ssl'].' restart'); |
|
235 |
system($conf['init_scripts'].'/'.$conf['courier']['courier-pop'].' restart'); |
|
236 |
system($conf['init_scripts'].'/'.$conf['courier']['courier-pop-ssl'].' restart'); |
ce9544
|
237 |
} |
T |
238 |
|
57706b
|
239 |
//** Configure Pureftpd |
P |
240 |
if(strtolower($inst->simple_query('Configure FTP Server', array('y','n'),'y') ) == 'y') { |
ce9544
|
241 |
swriteln('Configuring Pureftpd'); |
T |
242 |
$inst->configure_pureftpd(); |
cc3fb3
|
243 |
system($conf['init_scripts'].'/'.$conf['pureftpd']['init_script'].' restart'); |
ce9544
|
244 |
} |
T |
245 |
|
57706b
|
246 |
//** Configure MyDNS |
ce9544
|
247 |
if(strtolower($inst->simple_query('Configure DNS Server',array('y','n'),'y')) == 'y') { |
T |
248 |
swriteln('Configuring MyDNS'); |
|
249 |
$inst->configure_mydns(); |
cc3fb3
|
250 |
system($conf['init_scripts'].'/'.$conf['mydns']['init_script'].' restart'); |
ce9544
|
251 |
} |
T |
252 |
|
57706b
|
253 |
//** Configure Apache |
P |
254 |
if(strtolower($inst->simple_query('Configure Apache Server',array('y','n'),'y')) == 'y') { |
313e33
|
255 |
swriteln('Configuring Apache'); |
T |
256 |
$inst->configure_apache(); |
|
257 |
} |
|
258 |
|
57706b
|
259 |
//** Configure ISPConfig :-) |
ce9544
|
260 |
if(strtolower($inst->simple_query('Install ISPConfig',array('y','n'),'y')) == 'y') { |
T |
261 |
swriteln('Installing ISPConfig'); |
|
262 |
$inst->install_ispconfig(); |
57706b
|
263 |
|
P |
264 |
//* Configure ISPConfig |
ce9544
|
265 |
swriteln('Installing Crontab'); |
T |
266 |
$inst->install_crontab(); |
cc3fb3
|
267 |
system($conf['init_scripts'].'/'.$conf['apache']['init_script'].' restart'); |
ce9544
|
268 |
} |
T |
269 |
|
57706b
|
270 |
} //* << $install_mode / 'Standard' or Genius |
ce9544
|
271 |
|
9200ad
|
272 |
|
57706b
|
273 |
echo "Installation completed.\n"; |
9200ad
|
274 |
|
T |
275 |
|
57706b
|
276 |
?> |