Upgrade: Using Advanced > Upgrade > Source Code now automatically updates switch /scripts/ folder contents (on by default), keeping switch scripts up to date with each system upgrade. Option to opt out of auto script updates is available via a Default Setting (switch > scripts_update > boolean > false).

This commit is contained in:
Nate Jones
2015-05-12 22:42:20 +00:00
parent e00f3ce583
commit 9d2a16a4f7
2 changed files with 37 additions and 7 deletions

View File

@@ -69,7 +69,29 @@ if (sizeof($_POST) > 0) {
$response_message = $text['message-upgrade_svn_failed'];
}
else {
$response_message = $text['message-upgrade_svn'];
//update scripts folder, if allowed (default)
if ($_SESSION['switch']['scripts_update']['boolean'] != 'false' && $_SESSION['switch']['scripts']['dir'] != '') {
$scripts_dir_target = $_SESSION['switch']['scripts']['dir'];
$scripts_dir_source = realpath($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/install/scripts');
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($scripts_dir_source)) as $file_path_source) {
if (
substr_count($file_path_source, '/..') == 0 &&
substr_count($file_path_source, '/.') == 0 &&
substr_count($file_path_source, '/.svn') == 0
) {
$file_path_target = str_replace($scripts_dir_source, $scripts_dir_target, $file_path_source);
if ($file_path_target != $scripts_dir_target.'/resources/config.lua') {
//echo $file_path_source.' ---> '.$file_path_target.'<br>';
copy($file_path_source, $file_path_target);
chmod($file_path_target, 0755);
}
}
}
$response_message = $text['message-upgrade_svn_scripts'];
}
else {
$response_message = $text['message-upgrade_svn'];
}
}
}