Skip to content

Commit 465c9ed

Browse files
author
vogelor
committed
Changed the setup !important we have to check this if all works fine!
1 parent e5b3535 commit 465c9ed

File tree

9 files changed

+698
-176
lines changed

9 files changed

+698
-176
lines changed

install/autoupdate.php

Lines changed: 298 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,298 @@
1+
<?php
2+
/*
3+
Copyright (c) 2007-2010, Till Brehm, projektfarm Gmbh
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without modification,
7+
are permitted provided that the following conditions are met:
8+
9+
* Redistributions of source code must retain the above copyright notice,
10+
this list of conditions and the following disclaimer.
11+
* Redistributions in binary form must reproduce the above copyright notice,
12+
this list of conditions and the following disclaimer in the documentation
13+
and/or other materials provided with the distribution.
14+
* Neither the name of ISPConfig nor the names of its contributors
15+
may be used to endorse or promote products derived from this software without
16+
specific prior written permission.
17+
18+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21+
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22+
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
25+
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
27+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
*/
29+
30+
/*
31+
ISPConfig 3 updater.
32+
*/
33+
34+
error_reporting(E_ALL|E_STRICT);
35+
36+
/*
37+
* If the auto-updater flag is not on (the file does not exist) then cancel the auto-update!
38+
*/
39+
if (!file_exists('autoupdate')) {
40+
41+
//** The banner on the command line
42+
echo "\n\n".str_repeat('-',80)."\n";
43+
echo " _____ ___________ _____ __ _ ____
44+
|_ _/ ___| ___ \ / __ \ / _(_) /__ \
45+
| | \ `--.| |_/ / | / \/ ___ _ __ | |_ _ __ _ _/ /
46+
| | `--. \ __/ | | / _ \| '_ \| _| |/ _` | |_ |
47+
_| |_/\__/ / | | \__/\ (_) | | | | | | | (_| | ___\ \
48+
\___/\____/\_| \____/\___/|_| |_|_| |_|\__, | \____/
49+
__/ |
50+
|___/ ";
51+
echo "\n".str_repeat('-',80)."\n";
52+
echo "\n\n>>This script is for internal use only! Please use update.php! \n\n";
53+
exit;
54+
}
55+
56+
//** Include the library with the basic installer functions
57+
require_once('lib/install.lib.php');
58+
59+
//** Include the library with the basic updater functions
60+
require_once('lib/update.lib.php');
61+
62+
//** Include the base class of the installer class
63+
require_once('lib/installer_base.lib.php');
64+
65+
//** Ensure that current working directory is install directory
66+
$cur_dir = getcwd();
67+
if(realpath(dirname(__FILE__)) != $cur_dir) die("Please run installation/update from _inside_ the install directory!\n");
68+
69+
//** Install logfile
70+
define('ISPC_LOG_FILE', '/var/log/ispconfig_install.log');
71+
define('ISPC_INSTALL_ROOT', realpath(dirname(__FILE__).'/../'));
72+
73+
//** Get distribution identifier
74+
$dist = get_distname();
75+
76+
if($dist['id'] == '') die('Linux Dustribution 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+
include_once("/usr/local/ispconfig/server/lib/config.inc.php");
84+
$conf_old = $conf;
85+
unset($conf);
86+
87+
//** Get hostname
88+
exec('hostname -f', $tmp_out);
89+
$conf['hostname'] = $tmp_out[0];
90+
unset($tmp_out);
91+
92+
//** Set the mysql login information
93+
$conf["mysql"]["host"] = $conf_old["db_host"];
94+
$conf["mysql"]["database"] = $conf_old["db_database"];
95+
$conf['mysql']['charset'] = 'utf8';
96+
$conf["mysql"]["ispconfig_user"] = $conf_old["db_user"];
97+
$conf["mysql"]["ispconfig_password"] = $conf_old["db_password"];
98+
$conf['language'] = $conf_old['language'];
99+
if($conf['language'] == '{language}') $conf['language'] = 'en';
100+
101+
if(isset($conf_old["dbmaster_host"])) $conf["mysql"]["master_host"] = $conf_old["dbmaster_host"];
102+
if(isset($conf_old["dbmaster_database"])) $conf["mysql"]["master_database"] = $conf_old["dbmaster_database"];
103+
if(isset($conf_old["dbmaster_user"])) $conf["mysql"]["master_ispconfig_user"] = $conf_old["dbmaster_user"];
104+
if(isset($conf_old["dbmaster_password"])) $conf["mysql"]["master_ispconfig_password"] = $conf_old["dbmaster_password"];
105+
106+
//* Check if this is a master / slave setup
107+
$conf['mysql']['master_slave_setup'] = 'n';
108+
if($conf["mysql"]["master_host"] != '' && $conf["mysql"]["host"] != $conf["mysql"]["master_host"]) {
109+
$conf['mysql']['master_slave_setup'] = 'y';
110+
}
111+
112+
// Resolve the IP address of the mysql hostname.
113+
if(!$conf['mysql']['ip'] = gethostbyname($conf['mysql']['host'])) die('Unable to resolve hostname'.$conf['mysql']['host']);
114+
115+
$conf['server_id'] = intval($conf_old["server_id"]);
116+
$conf['ispconfig_log_priority'] = $conf_old["log_priority"];
117+
118+
$inst = new installer();
119+
$inst->is_update = true;
120+
121+
//** Detect the installed applications
122+
$inst->find_installed_apps();
123+
124+
//** Initialize the MySQL server connection
125+
include_once('lib/mysql.lib.php');
126+
127+
//** Database update is a bit brute force and should be rebuild later ;)
128+
129+
/*
130+
* Try to read the DB-admin settings
131+
*/
132+
$clientdb_host = '';
133+
$clientdb_user = '';
134+
$clientdb_password = '';
135+
include_once("/usr/local/ispconfig/server/lib/mysql_clientdb.conf");
136+
$conf["mysql"]["admin_user"] = $clientdb_user;
137+
$conf["mysql"]["admin_password"] = $clientdb_password;
138+
$clientdb_host = '';
139+
$clientdb_user = '';
140+
$clientdb_password = '';
141+
142+
//** There is a error if user for mysql admin_password if empty
143+
if( empty($conf["mysql"]["admin_password"]) ) {
144+
die("internal error - MYSQL-Root passord not known");
145+
}
146+
147+
/*
148+
* Prepare the dump of the database
149+
*/
150+
prepareDBDump();
151+
152+
//* initialize the database
153+
$inst->db = new db();
154+
155+
/*
156+
* If it is NOT a master-slave - Setup then we are at the Master-DB. So set all rights
157+
*/
158+
if($conf['mysql']['master_slave_setup'] != 'y') {
159+
$inst->dbmaster = $inst->db;
160+
$inst->grant_master_database_rights();
161+
echo "done rights";
162+
}
163+
164+
/*
165+
* dump the new Database and reconfigure the server.ini
166+
*/
167+
updateDbAndIni();
168+
169+
/*
170+
* Reconfigure all Services
171+
*/
172+
if($conf['services']['mail'] == true) {
173+
//** Configure postfix
174+
swriteln('Configuring Postfix');
175+
$inst->configure_postfix('dont-create-certs');
176+
177+
//* Configure Jailkit
178+
swriteln('Configuring Jailkit');
179+
$inst->configure_jailkit();
180+
181+
//** Configure saslauthd
182+
swriteln('Configuring SASL');
183+
$inst->configure_saslauthd();
184+
185+
//** Configure PAM
186+
swriteln('Configuring PAM');
187+
$inst->configure_pam();
188+
189+
if($conf['dovecot']['installed'] == true) {
190+
//* Configure dovecot
191+
swriteln('Configuring Dovecot');
192+
$inst->configure_dovecot();
193+
} else {
194+
//* Configure courier
195+
swriteln('Configuring Courier');
196+
$inst->configure_courier();
197+
}
198+
199+
//** Configure Spamasassin
200+
swriteln('Configuring Spamassassin');
201+
$inst->configure_spamassassin();
202+
203+
//** Configure Amavis
204+
swriteln('Configuring Amavisd');
205+
$inst->configure_amavis();
206+
207+
//** Configure Getmail
208+
swriteln('Configuring Getmail');
209+
$inst->configure_getmail();
210+
}
211+
212+
if($conf['services']['web'] == true) {
213+
//** Configure Pureftpd
214+
swriteln('Configuring Pureftpd');
215+
$inst->configure_pureftpd();
216+
}
217+
218+
if($conf['services']['dns'] == true) {
219+
//* Configure DNS
220+
if($conf['powerdns']['installed'] == true) {
221+
swriteln('Configuring PowerDNS');
222+
$inst->configure_powerdns();
223+
} elseif($conf['bind']['installed'] == true) {
224+
swriteln('Configuring BIND');
225+
$inst->configure_bind();
226+
} else {
227+
swriteln('Configuring MyDNS');
228+
$inst->configure_mydns();
229+
}
230+
}
231+
232+
if($conf['services']['web'] == true) {
233+
//** Configure Apache
234+
swriteln('Configuring Apache');
235+
$inst->configure_apache();
236+
237+
//** Configure vlogger
238+
swriteln('Configuring vlogger');
239+
$inst->configure_vlogger();
240+
241+
//** Configure apps vhost
242+
swriteln('Configuring Apps vhost');
243+
$inst->configure_apps_vhost();
244+
}
245+
246+
247+
//* Configure DBServer
248+
swriteln('Configuring Database');
249+
$inst->configure_dbserver();
250+
251+
252+
//if(@is_dir('/etc/Bastille')) {
253+
//* Configure Firewall
254+
swriteln('Configuring Firewall');
255+
$inst->configure_firewall();
256+
//}
257+
258+
//** Configure ISPConfig
259+
swriteln('Updating ISPConfig');
260+
261+
262+
//** Customise the port ISPConfig runs on
263+
$conf['apache']['vhost_port'] = '8080';
264+
265+
$inst->install_ispconfig();
266+
267+
//** Configure Crontab
268+
swriteln('Updating Crontab');
269+
$inst->install_crontab();
270+
271+
//** Restart services:
272+
swriteln('Restarting services ...');
273+
if($conf['mysql']['init_script'] != '' && is_file($conf['init_scripts'].'/'.$conf['mysql']['init_script'])) system($conf['init_scripts'].'/'.$conf['mysql']['init_script'].' restart');
274+
if($conf['services']['mail']) {
275+
if($conf['postfix']['init_script'] != '' && is_file($conf['init_scripts'].'/'.$conf['postfix']['init_script'])) system($conf['init_scripts'].'/'.$conf['postfix']['init_script'].' restart');
276+
if($conf['saslauthd']['init_script'] != '' && is_file($conf['init_scripts'].'/'.$conf['saslauthd']['init_script'])) system($conf['init_scripts'].'/'.$conf['saslauthd']['init_script'].' restart');
277+
if($conf['amavis']['init_script'] != '' && is_file($conf['init_scripts'].'/'.$conf['amavis']['init_script'])) system($conf['init_scripts'].'/'.$conf['amavis']['init_script'].' restart');
278+
if($conf['clamav']['init_script'] != '' && is_file($conf['init_scripts'].'/'.$conf['clamav']['init_script'])) system($conf['init_scripts'].'/'.$conf['clamav']['init_script'].' restart');
279+
if($conf['courier']['courier-authdaemon'] != '' && is_file($conf['init_scripts'].'/'.$conf['courier']['courier-authdaemon'])) system($conf['init_scripts'].'/'.$conf['courier']['courier-authdaemon'].' restart');
280+
if($conf['courier']['courier-imap'] != '' && is_file($conf['init_scripts'].'/'.$conf['courier']['courier-imap'])) system($conf['init_scripts'].'/'.$conf['courier']['courier-imap'].' restart');
281+
if($conf['courier']['courier-imap-ssl'] != '' && is_file($conf['init_scripts'].'/'.$conf['courier']['courier-imap-ssl'])) system($conf['init_scripts'].'/'.$conf['courier']['courier-imap-ssl'].' restart');
282+
if($conf['courier']['courier-pop'] != '' && is_file($conf['init_scripts'].'/'.$conf['courier']['courier-pop'])) system($conf['init_scripts'].'/'.$conf['courier']['courier-pop'].' restart');
283+
if($conf['courier']['courier-pop-ssl'] != '' && is_file($conf['init_scripts'].'/'.$conf['courier']['courier-pop-ssl'])) system($conf['init_scripts'].'/'.$conf['courier']['courier-pop-ssl'].' restart');
284+
if($conf['dovecot']['init_script'] != '' && is_file($conf['init_scripts'].'/'.$conf['dovecot']['init_script'])) system($conf['init_scripts'].'/'.$conf['dovecot']['init_script'].' restart');
285+
}
286+
if($conf['services']['web']) {
287+
if($conf['apache']['init_script'] != '' && is_file($conf['init_scripts'].'/'.$conf['apache']['init_script'])) system($conf['init_scripts'].'/'.$conf['apache']['init_script'].' restart');
288+
if($conf['pureftpd']['init_script'] != '' && is_file($conf['init_scripts'].'/'.$conf['pureftpd']['init_script'])) system($conf['init_scripts'].'/'.$conf['pureftpd']['init_script'].' restart');
289+
}
290+
if($conf['services']['dns']) {
291+
if($conf['mydns']['installed'] == true && $conf['mydns']['init_script'] != '' && is_file($conf['init_scripts'].'/'.$conf['mydns']['init_script'])) system($conf['init_scripts'].'/'.$conf['mydns']['init_script'].' restart &> /dev/null');
292+
if($conf['powerdns']['installed'] == true && $conf['powerdns']['init_script'] != '' && is_file($conf['init_scripts'].'/'.$conf['powerdns']['init_script'])) system($conf['init_scripts'].'/'.$conf['powerdns']['init_script'].' restart &> /dev/null');
293+
if($conf['bind']['installed'] == true && $conf['bind']['init_script'] != '' && is_file($conf['init_scripts'].'/'.$conf['bind']['init_script'])) system($conf['init_scripts'].'/'.$conf['bind']['init_script'].' restart &> /dev/null');
294+
}
295+
296+
echo "Update finished.\n";
297+
298+
?>

0 commit comments

Comments
 (0)