1+ <?php
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+
35+ // Include the library with the basic installer functions
36+ require_once('lib/install.lib.php');
37+
38+ // Include the base class of the installer class
39+ require_once('lib/installer_base.lib.php');
40+
41+ $distname = get_distname();
42+
43+ include_once("/usr/local/ispconfig/server/lib/config.inc.php");
44+ $conf_old = $conf;
45+ unset $conf;
46+
47+ // Include the distribution specific installer class library
48+ // and configuration
49+ include_once('dist/lib/'.$distname.'.lib.php');
50+ include_once('dist/conf/'.$distname.'.conf.php');
51+
52+ // Set the mysql login information
53+ $conf["mysql_server_host"] = $conf_old["db_host"];
54+ $conf["mysql_server_database"] = $conf_old["db_database"];
55+ $conf["mysql_server_ispconfig_user"] = $conf_old["db_user"];
56+ $conf["mysql_server_ispconfig_password"] = $conf_old["db_password"];
57+
58+ $inst = new installer();
59+
60+
61+ echo "This application will update ISPConfig 3 on your server.\n";
62+
63+ // $conf["language"] = $inst->request_language();
64+
65+ // TODO: all other queries, for testing I will setup everything in $conf
66+
67+ // Initialize the MySQL server connection
68+ include_once('lib/mysql.lib.php');
69+ $inst->db = new db();
70+
71+ // Database update is a bit brute force and should be rebuild later ;)
72+
73+ // export the current database data
74+ exec("mysqldump -h $conf[mysql_server_host] -u $conf[mysql_server_ispconfig_user] -p$conf[mysql_server_ispconfig_password] -c -t --add-drop-table --add-locks --all --quick --lock-tables $conf[mysql_server_database] > existing_db.sql &> /dev/null");
75+
76+ // Delete the old database
77+ exec("/etc/init.d/mysql stop");
78+ exec("rm -rf /var/lib/mysql/".$conf["db_database"]);
79+ exec("/etc/init.d/mysql start");
80+
81+ // Create the mysql database
82+ $inst->configure_database();
83+
84+ // empty all databases
85+ $db_tables = $inst->db->getTables();
86+ foreach($db_tables as $table) {
87+ $inst->db->query("TRUNCATE $table");
88+ }
89+
90+ // load old data back into database
91+ exec("mysql -h $conf[mysql_server_host] -u $conf[mysql_server_ispconfig_user] -p$conf[mysql_server_ispconfig_password] $conf[mysql_server_database] < existing_db.sql &> /dev/null");
92+
93+ // Configure postfix
94+ $inst->configure_postfix();
95+
96+ // Configure saslauthd
97+ swriteln('Configuring SASL');
98+ $inst->configure_saslauthd();
99+
100+
101+ // Configure PAM
102+ swriteln('Configuring PAM');
103+ $inst->configure_pam();
104+
105+ // Configure courier
106+ swriteln('Configuring Courier');
107+ $inst->configure_courier();
108+
109+ // Configure Spamasassin
110+ swriteln('Configuring Spamassassin');
111+ $inst->configure_spamassassin();
112+
113+ // Configure Amavis
114+ swriteln('Configuring Amavisd');
115+ $inst->configure_amavis();
116+
117+ // Configure Getmail
118+ swriteln('Configuring Getmail');
119+ $inst->configure_getmail();
120+
121+ // Configure Getmail
122+ swriteln('Configuring Pureftpd');
123+ $inst->configure_pureftpd();
124+
125+ // Configure ISPConfig
126+ swriteln('Installing ISPConfig');
127+ $inst->install_ispconfig();
128+
129+ // Configure ISPConfig
130+ swriteln('Installing Crontab');
131+ $inst->install_crontab();
132+
133+
134+ /*
135+ Restart services:
136+ */
137+
138+ swriteln('Restarting services ...');
139+ system("/etc/init.d/mysql restart");
140+ system("/etc/init.d/postfix restart");
141+ system("/etc/init.d/saslauthd restart");
142+ system("/etc/init.d/amavis restart");
143+ system("/etc/init.d/clamav-daemon restart");
144+ system("/etc/init.d/courier-authdaemon restart");
145+ system("/etc/init.d/courier-imap restart");
146+ system("/etc/init.d/courier-imap-ssl restart");
147+ system("/etc/init.d/courier-pop restart");
148+ system("/etc/init.d/courier-pop-ssl restart");
149+ system("/etc/init.d/apache2 restart");
150+ system("/etc/init.d/pure-ftpd-mysql restart");
151+
152+ echo "Update finished.\n";
153+
154+
155+ ?>
0 commit comments