function rmDirRecursive($dir) { if (!is_dir($dir) || is_link($dir)) { return unlink($dir); } foreach (scandir($dir) as $file) { if ($file == '.' || $file == '..') { continue; } if (!rmDirRecursive($dir . '/' . $file)) { if (!rmDirRecursive($dir . '/' . $file)) { return false; } } } return rmdir($dir); }
} else { runCommand("/bin/rm -rf " . $path); } } if (!$runningOnWindows) { $result = array(); echo "Running as:"; exec('/usr/bin/whoami 2>&1', $result); foreach ($result as $row) { echo $row, "\n"; } } // Flush assets and create directory if not existing rmDirRecursive(pth($root . "frontend/www/assets")); createDirIfNotExists(pth($root . "frontend/www/assets")); rmDirRecursive(pth($root . "backend/www/assets")); createDirIfNotExists(pth($root . "backend/www/assets")); // runtime createDirIfNotExists(pth($root . "frontend/runtime")); createDirIfNotExists(pth($root . "backend/runtime")); createDirIfNotExists(pth($root . "console/runtime")); // permissions chmod(pth($root . "frontend/runtime"), 02777); // permissions with setguid chmod(pth($root . "backend/runtime"), 02777); chmod(pth($root . "console/runtime"), 02777); chmod(pth($root . "frontend/www/assets"), 02777); chmod(pth($root . "backend/www/assets"), 02777); //Copy *-environmnetName.php to *-env.php $directories = array(pth($root . "common/config/"), pth($root . "frontend/config/"), pth($root . "backend/config/"), pth($root . "console/config/")); // console