Current File : //root/panel/modules/rainloop/deploy/install.run
<?php

function CopyDir($src, $dest) {
	$path = realpath($src);
	$objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::SELF_FIRST);

	foreach($objects as $name => $object)
	{
		$startsAt = substr(dirname($name), strlen($src));
		NewDir($dest.$startsAt);
		if(is_writable($dest.$startsAt) and $object->isFile())
		{
			copy((string)$name, $dest.$startsAt.DIRECTORY_SEPARATOR.basename($name));
			chmod($dest.$startsAt.DIRECTORY_SEPARATOR.basename($name), 0777);
		}
	}
}

function NewDir($folder) {
	if(!is_dir($folder)) {
		mkdir($folder, 0777);
		chmod($folder, 0777);
	}
}

function RemoveDir($dir) {

  $files = array_diff(scandir($dir), array('.','..'));
  foreach ($files as $file) {
    (is_dir("$dir/$file")) ? RemoveDir("$dir/$file") : unlink("$dir/$file");
  }
  return rmdir($dir);
}

// determine Sentora root directory
$currentDir = rtrim(dirname(__FILE__), '/\\');
$folders = explode('/', $currentDir);
$sentoraRoot = '';
$i = 0;
while ($folders[$i] != 'modules') {
	$sentoraRoot .= $folders[$i].'/';
	$i++;
}

// Windows?
if (sys_versions::ShowOSPlatformVersion() == "Windows")
{
	$l = '\\';
}
else
{
	$l = '/';	
}

// set the source and destination
$src = $sentoraRoot.'modules'.$l.'rainloop'.$l.'app'.$l;
$dst = $sentoraRoot.'etc'.$l.'apps'.$l.'rainloop'.$l;

// create the destination folder
error_log('Creating '.$dst);
mkdir($dst, 0777);
chmod($dst, 0777);
chmod($src, 0777);

// copy the src files to /modules/module_name/path
CopyDir($src, $dst);
// remove the App files that were just copied
RemoveDir($src);

?>