From b92cbaca8fac93c03c53e325334ad8133423a638 Mon Sep 17 00:00:00 2001 From: Mark Crane Date: Fri, 18 Jul 2014 20:30:36 +0000 Subject: [PATCH] Update the freeswitch conf directory --- resources/classes/install.php | 19 ++++++++----------- resources/install.php | 2 +- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/resources/classes/install.php b/resources/classes/install.php index 30d18267fc..bebe94155a 100644 --- a/resources/classes/install.php +++ b/resources/classes/install.php @@ -38,7 +38,7 @@ include "root.php"; //$option '-n' --no-clobber function recursive_copy($src, $dst, $option = '') { if (file_exists('/bin/cp')) { - exec ('cp -R '.$option.' '.$src.'/* '.$dst); + exec ('cp -RLp '.$option.' '.$src.'/* '.$dst); } else { $dir = opendir($src); @@ -76,7 +76,10 @@ include "root.php"; } function recursive_delete($dir) { - if (strlen($dir) > 0) { + if (file_exists('/bin/rm')) { + exec ('rm -Rf '.$dir.'/*'); + } + else { foreach (glob($dir) as $file) { if (is_dir($file)) { $this->recursive_delete("$file/*"); @@ -103,15 +106,9 @@ include "root.php"; $src_dir = $this->switch_conf_dir; $dst_dir = $this->switch_conf_dir.'.orig'; if (is_readable($src_dir)) { - if (substr(strtoupper(PHP_OS), 0, 3) == "WIN") { - $this->recursive_copy($src_dir, $dst_dir); - $this->recursive_delete($this->switch_conf_dir); - } - else { - exec ('mv '.$src_dir.' '.$dst_dir); - //exec ('cp -RLp '.$src_dir.' '.$dst_dir); - } - } + $this->recursive_copy($src_dir, $dst_dir); + $this->recursive_delete($src_dir); + } else { if ($src_dir != "/conf") { mkdir($src_dir, 0774, true); diff --git a/resources/install.php b/resources/install.php index c02dedf47e..2fe0d26bb5 100644 --- a/resources/install.php +++ b/resources/install.php @@ -1263,7 +1263,7 @@ if ($_POST["install_step"] == "3" && count($_POST) > 0 && strlen($_POST["persist unset($menu); //setup the switch config directory if it exists - if ($switch_conf_dir != "/conf") { + if (file_exists($switch_conf_dir) && $switch_conf_dir != "/conf") { if ($v_debug) { fwrite($fp, "switch_base_dir: ".$install_switch_base_dir."\n"); fwrite($fp, "switch_conf_dir: ".$switch_conf_dir."\n");