Koozali.org formerly Contribs.org

SAIL 4 Deb Build 67 Post Install Fixes

SAIL 4 Deb Build 67 Post Install Fixes
« on: April 29, 2013, 07:02:46 PM »
The latest SAIL for Debian v4.0.0-67 has been released.

Upgrade an existing sail4deb with:

Code: [Select]
cd /usr/src
wget http://sailpbx.com/sail/sail-4.0/debs/sail_4.0.0-67_all.deb
dpkg -i sail_4.0.0-67_all.deb

Fixes will need to be put in before it will work error free - the following patch does the job:
Code: [Select]
--- old/sark/php/greetings/list.php    Fri Jan 16 08:56:28 1970
+++ new/sark/php/greetings/list.php    Fri Jan 16 08:56:28 1970
@@ -6,7 +6,7 @@
         
     $dbh = DB::getInstance();
     $helper = new helper;
-    $helper->qDistro($distro);
+    $distro = $helper->qDistro();
     
     $helper->logit( "I'm sending greetings ",3 );
     
--- old/sark/php/sarkglobal/view.php    Fri Jan 16 08:56:28 1970
+++ new/sark/php/sarkglobal/view.php    Fri Jan 16 08:56:28 1970
@@ -39,7 +39,7 @@
     $this->myPanel = new page;
     $this->dbh = DB::getInstance();
     $this->helper = new helper;
-    $this->helper->qDistro($distro);
+    $this->distro = $this->helper->qDistro();
         
     echo '<body>';
     echo '<form id="sarkglobalForm" action="' . $_SERVER['PHP_SELF'] . '" method="post">' . PHP_EOL;
--- old/sark/php/sarkgreeting/view.php    Fri Jan 16 08:56:28 1970
+++ new/sark/php/sarkgreeting/view.php    Fri Jan 16 08:56:28 1970
@@ -39,11 +39,8 @@
     $this->myPanel = new page;
     $this->dbh = DB::getInstance();
     $this->helper = new helper;
-    $this->helper->qDistro($distro);
-   
-    if ( $distro['debian'] )  {
-        $this->soundir = '/usr/share/asterisk/sounds';
-    }   
+    $this->distro = $this->helper->qDistro();
+    $this->soundir = $this->distro['soundroot'] . 'asterisk/sounds';
     
     echo '<body>';
     echo '<form id="sarkgreetingForm" action="' . $_SERVER['PHP_SELF'] . '" method="post">' . PHP_EOL;
--- old/sark/php/sarkivr/view.php    Fri Jan 16 08:56:28 1970
+++ new/sark/php/sarkivr/view.php    Fri Jan 16 08:56:28 1970
@@ -39,7 +39,7 @@
     $this->myPanel = new page;
     $this->dbh = DB::getInstance();
     $this->helper = new helper;
-    $this->helper->qDistro($this->distro);
+    $this->distro = $this->helper->qDistro();
     $this->soundir = $this->distro['soundroot'] . 'asterisk/sounds';
             
     echo '<body>';
--- old/sark/php/sarksupt/view.php    Fri Jan 16 08:56:28 1970
+++ new/sark/php/sarksupt/view.php    Fri Jan 16 08:56:28 1970
@@ -38,7 +38,7 @@
     $this->myPanel = new page;
     $this->dbh = DB::getInstance();
     $this->helper = new helper;
-    $this->helper->qDistro($distro);
+    $this->distro = $this->helper->qDistro();
 
     
     echo '<body>';
--- old/sark/php/sarktrunk/view.php    Fri Jan 16 08:56:28 1970
+++ new/sark/php/sarktrunk/view.php    Fri Jan 16 08:56:28 1970
@@ -665,9 +665,9 @@
         $this->myPanel->selected = $tuple['openroute'];
         $this->myPanel->sysSelect('openroute',false,false,true) . PHP_EOL;
         
-        $this->myPanel->aLabelFor('closeroute',false,false,true);
+        $this->myPanel->aLabelFor('closeroute');
         $this->myPanel->selected = $tuple['closeroute'];
-        $this->myPanel->sysSelect('closeroute') . PHP_EOL;   
+        $this->myPanel->sysSelect('closeroute',false,false,true) . PHP_EOL;   
     }   
 
     echo '</div>' . PHP_EOL;
--- old/sark/php/srkHelperClass    Fri Jan 16 08:56:28 1970
+++ new/sark/php/srkHelperClass    Fri Jan 16 08:56:28 1970
@@ -951,33 +951,18 @@
     $this->setCluster($rec);
 }
 
-public function qDistro (&$distro=array()) {
+public function qDistro () {
 
-    $distro['rhel'] = false;
-    $distro['centos'] = false;
-    $distro['sme'] = false;
-    $distro['debian'] = false;
-    $distro['pika'] = false;   
-    $distro['soundroot'] = '/var/lib/';
+    $distro = Array();
+
+    $distro['rhel']      = file_exists('/etc/redhat-release');
+    $distro['centos']    = ($distro['rhel'] && ( `/bin/grep -i CentOS /etc/redhat-release` ));
+    $distro['sme']       = ($distro['rhel'] && ( `/bin/grep -i SME /etc/redhat-release` ));
+    $distro['debian']    = file_exists('/etc/debian_version');
+    $distro['pika']      = ( `/bin/uname -r | /bin/grep pika` );   
+    $distro['soundroot'] = ($distro['debian'] ? '/usr/share/' : '/var/lib/');
     
-    if (file_exists('/etc/redhat-release')) {
-        $distro['rhel'] = true;
-        if (`/bin/grep -i CentOS /etc/redhat-release` ) {
-            $distro['centos'] = true;
-        }
-        if (`/bin/grep -i SME /etc/redhat-release` ) {
-            $distro['sme'] = true;
-        }       
-    }       
-    if (file_exists('/etc/debian_version')) {
-        $distro['debian'] = true;
-        $distro['soundroot'] = '/usr/share/';
-    }
-    if ( `/bin/uname -r | /bin/grep pika` ) {
-        $distro['pika'] = true;
-        $distro['soundroot'] = '/var/lib/';
-    }       
-    return;
+    return $distro;
 }
 
 public function removeLrCr(&$str) {


The above code can be placed in a file in / named say: sail_fixes_4-62.patch
Code: [Select]
cd /opt
patch -p1 < sail_fixes_4-62.patch

If running SAIL in an OpenVZ Virtual machine (container), then avoid timing issues interfering with multiple system commands from php (needing two depressals of the Stop PBX button in the SARK Globals panel before SARK would stop) with editing the /opt/sark/php/sarkglobal/view.php by replacing:

Code: [Select]
private function sark_stop () {

       $ret = ($this->helper->request_syscmd ('/usr/bin/sv d sark'));
       $ret = ($this->helper->request_syscmd ('/usr/bin/sv k sark'));

    return ("Stop signal sent");

}

with

Code: [Select]
private function sark_stop () {

       $ret = ($this->helper->request_syscmd ('/usr/bin/sv d sark'));
       $ret = ($this->helper->request_syscmd ('/usr/bin/sv k sark'));
sleep(1);
    return ("Stop signal sent");

}

These fixes are available at:
http://www.apmuthu.com/bugfixes/SAIL_4_Deb_Build_67_PostInstallFixes.zip

« Last Edit: April 29, 2013, 07:18:04 PM by apmuthu »