tbrehm
2008-04-14 c6d48b0fe5b79665bd11ad9fe2d181c642a965f9
commit | author | age
87a4a6 1 <?php
T 2
3 /*
00fad6 4 Copyright (c) 2007, Till Brehm, projektfarm Gmbh
87a4a6 5 All rights reserved.
T 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 require("lib/config.inc.php");
32 require("lib/app.inc.php");
33
34 set_time_limit(0);
35
36 // make sure server_id is always an int
37 $conf["server_id"] = intval($conf["server_id"]);
38
32b40d 39 /*
87a4a6 40 // Get server record, if updates where available for this server
32b40d 41 $server_db_record = $app->db->queryOneRecord("SELECT * FROM server WHERE update = 1 AND server_id = ".$conf["server_id"]);
87a4a6 42 if($server_db_record == false) {
T 43     $app->log("Nothing to update for server_id ".$conf["server_id"]);
44     die();
45 } else {
46     // Set update status to 0, so we dont start the update process twice
47     $app->db->query("UPDATE server SET update = 0 WHERE server_id = ".$conf["server_id"]);
48     $app->log("Begin update.");
49 }
32b40d 50 */
87a4a6 51
32b40d 52 /*
87a4a6 53 // Check if another process is running
T 54 if(is_file($conf["temppath"].$conf["fs_div"].".ispconfig_lock")){
55   clearstatcache();
56   for($i=0;$i<120;$i++){ // Wait max. 120 sec, then proceed
57     if(is_file($conf["temppath"].$conf["fs_div"].".ispconfig_lock")){
58       sleep(1);
59       clearstatcache();
60     }
61   }
62 }
63
64 // Set Lockfile
65 @touch($conf["temppath"].$conf["fs_div"].".ispconfig_lock");
32b40d 66 $app->log("Set Lock: ".$conf["temppath"].$conf["fs_div"].".ispconfig_lock", LOGLEVEL_DEBUG);
00fad6 67 */
87a4a6 68
32b40d 69 // Check if there is anything to update
T 70 $tmp_rec = $app->db->queryOneRecord("SELECT count(server_id) as number from sys_datalog WHERE server_id = ".$conf["server_id"]);
71 $tmp_num_records = $tmp_rec["number"];
72 unset($tmp_rec);
87a4a6 73
32b40d 74 if($tmp_num_records > 0) {
T 75     
76     $app->log("Found $tmp_num_records changes, starting update process.",LOGLEVEL_DEBUG);
77     
78     // Load required base-classes
e2d6ed 79     $app->uses('ini_parser,modules,plugins,file,services');
32b40d 80     
T 81     
82     // Get server configuration
83     $conf["serverconfig"] = $app->ini_parser->parse_ini_string(stripslashes($server_db_record["config"]));
84
85     /*
86      Load the modules that are im the mods-enabled folder
87     */
88
89     $app->modules->loadModules();
90
91     /*
92      Load the plugins that are in the plugins-enabled folder
93     */
94
95     $app->plugins->loadPlugins();
96
97     /*
98      Go trough the sys_datalog table and call the processing functions
99      in the modules that are hooked on to the table actions
100     */
101     $app->modules->processDatalog();
e2d6ed 102     
T 103     /*
104      Restart services that need to be restarted after configuration
105     */
106     $app->services->processDelayedActions();
107     
108     
32b40d 109 } else {
e2d6ed 110     $app->log('No Updated records found.',LOGLEVEL_DEBUG);
32b40d 111 }
87a4a6 112
00fad6 113 /*
87a4a6 114 // Remove lock
T 115 @unlink($conf["temppath"].$conf["fs_div"].".ispconfig_lock");
32b40d 116 $app->log("Remove Lock: ".$conf["temppath"].$conf["fs_div"].".ispconfig_lock",LOGLEVEL_DEBUG);
T 117 */
118
ba747c 119 die("finished.\n");
87a4a6 120 ?>