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

Revision 5590, 3.1 kB (checked in by p_lindheimer, 4 years ago)

move helper functions up to top of install script now that they are in if function_exists() condition

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