root/modules/branches/2.3/framework/install.php

Revision 4526, 2.9 kB (checked in by p_lindheimer, 6 years ago)

fix bug upgrading from some older versions of beta code that did not have version_compare_freepbx in them

  • Property svn:mime-type set to text/html
  • Property svn:eol-style set to native
Line 
1 <?php
2
3 include dirname(__FILE__)."/libfreepbx.install.php";
4
5 global $amp_conf;
6 global $asterisk_conf;
7
8 $debug = false;
9 $dryrun = false;
10
11 /** verison_compare that works with freePBX version numbers
12  *  included here because there are some older versions of functions.inc.php that do not have
13  *  it included as it was added during 2.3.0beta1
14  */
15 if (!function_exists('version_compare_freepbx')) {
16   function version_compare_freepbx($version1, $version2, $op = null) {
17     $version1 = str_replace("rc","RC", strtolower($version1));
18     $version2 = str_replace("rc","RC", strtolower($version2));
19     if (!is_null($op)) {
20       return version_compare($version1, $version2, $op);
21     } else {
22       return version_compare($version1, $version2);
23     }
24   }
25 }
26
27 /*
28  * Framework install script
29  */
30
31   $htdocs_source = dirname(__FILE__)."/htdocs/*";
32   $bin_source = dirname(__FILE__)."/bin/*";
33   $agibin_source = dirname(__FILE__)."/agi-bin/*";
34   $htdocs_panel_source = dirname(__FILE__)."/htdocs_panel/*";
35
36   // These are required by libfreepbx.install.php library for upgrade routines
37   //
38   define("UPGRADE_DIR", dirname(__FILE__)."/upgrades/");
39   define("MODULE_DIR",  $amp_conf['AMPWEBROOT'].'/modules/');
40
41   $htdocs_dest = $amp_conf['AMPWEBROOT'];
42   $bin_dest    = isset($amp_conf['AMPBIN']) ? $amp_conf['AMPBIN'] : '/var/lib/asterisk/bin';
43   $agibin_dest = isset($asterisk_conf['astagidir']) ? $asterisk_conf['astagidir']:'/var/lib/asterisk/agi-bin';
44
45   // There was a past bug where FOPWEBROOT was pointing to AMPWEBROOT so if that is the case then hardcode
46   // and force to panel here.
47   //
48   $htdocs_panel_dest = $amp_conf['FOPWEBROOT'];
49   if ($htdocs_panel_dest == $amp_conf['AMPWEBROOT']) {
50     $htdocs_panel_dest .= "/panel";
51   }
52
53   exec("cp -rf $htdocs_source $htdocs_dest 2>&1",$out,$ret);
54   if ($ret != 0) {
55     framework_print_errors($htdocs_source, $htdocs_dest, $out);
56   }
57
58   exec("cp -rf $bin_source $bin_dest 2>&1",$out,$ret);
59   if ($ret != 0) {
60     framework_print_errors($bin_source, $bin_dest, $out);
61   }
62
63   exec("cp -rf $agibin_source $agibin_dest 2>&1",$out,$ret);
64   if ($ret != 0) {
65     framework_print_errors($agibin_source, $agibin_dest, $out);
66   }
67
68   exec("cp -rf $htdocs_panel_source $htdocs_panel_dest 2>&1",$out,$ret);
69   if ($ret != 0) {
70     framework_print_errors($htdocs_panel_source, $htdocs_panel_dest, $out);
71   }
72
73   if (function_exists('upgrade_all')) {
74     upgrade_all(getversion());
75   } else {
76     echo ("[ERROR] Function: 'upgrade_all' not present, libfreepbx.inc.php must not be isntall<br>");
77   }
78
79
80 // HELPER FUNCTIONS:
81
82 function framework_print_errors($src, $dst, $errors) {
83   echo "error copying framework files:<br />'cp -rf' from src: '$src' to dst: '$dst'...details follow<br />";
84   foreach ($errors as $error) {
85     echo "$error<br />";
86   }
87 }
88
89 function out($text) {
90   echo $text."<br>";
91 }
92
93 function outn($text) {
94   echo $text;
95 }
96
97 function error($text) {
98   echo "[ERROR] ".$text."<br>";
99 }
100
101 function fatal($text) {
102   echo "[FATAL] ".$text."<br>";
103   exit(1);
104 }
105
106 function debug($text) {
107   global $debug;
108  
109   if ($debug) echo "[DEBUG-preDB] ".$text."<br>";
110 }
111 ?>
Note: See TracBrowser for help on using the browser.