diff options
author | Aleksander Machniak <alec@alec.pl> | 2016-12-23 14:52:50 +0300 |
---|---|---|
committer | Aleksander Machniak <alec@alec.pl> | 2016-12-23 14:52:50 +0300 |
commit | ab429dbef2bbd426aacf5436f7dcb78866193f2a (patch) | |
tree | 0f2dcd2ad86f88c082f22cd5fc4ba5f5ae5c6904 /bin | |
parent | 68c9b669e43be1d735122ac4059e2377ad95dc0a (diff) |
Fix rsync error handling in installto.sh script (#5562)
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/installto.sh | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/bin/installto.sh b/bin/installto.sh index 2cc1b2558..27594b639 100755 --- a/bin/installto.sh +++ b/bin/installto.sh @@ -42,7 +42,6 @@ echo "Upgrading from $oldversion. Do you want to continue? (y/N)\n"; $input = trim(fgets(STDIN)); if (strtolower($input) == 'y') { - $err = false; echo "Copying files to target location..."; // Save a copy of original .htaccess file (#1490623) @@ -56,16 +55,16 @@ if (strtolower($input) == 'y') { } foreach ($dirs as $dir) { // @FIXME: should we use --delete for all directories? - $delete = in_array($dir, array('program', 'installer')) ? '--delete ' : ''; - if (!system("rsync -avC " . $delete . INSTALL_PATH . "$dir/* $target_dir/$dir/")) { - $err = true; - break; + $delete = in_array($dir, array('program', 'installer')) ? '--delete ' : ''; + $command = "rsync -aC --out-format \"%n\" " . $delete . INSTALL_PATH . "$dir/* $target_dir/$dir/"; + if (!system($command, $ret) || $ret > 0) { + rcube::raise_error("Failed to execute command: $command", false, true); } } foreach (array('index.php','.htaccess','config/defaults.inc.php','composer.json-dist','CHANGELOG','README.md','UPGRADING','LICENSE','INSTALL') as $file) { - if (!system("rsync -av " . INSTALL_PATH . "$file $target_dir/$file")) { - $err = true; - break; + $command = "rsync -a --out-format \"%n\" " . INSTALL_PATH . "$file $target_dir/$file"; + if (file_exists(INSTALL_PATH . $file) && (!system($command, $ret) || $ret > 0)) { + rcube::raise_error("Failed to execute command: $command", false, true); } } @@ -96,13 +95,12 @@ if (strtolower($input) == 'y') { echo "done.\n\n"; } - if (!$err) { - echo "Running update script at target...\n"; - system("cd $target_dir && php bin/update.sh --version=$oldversion"); - echo "All done.\n"; - } + echo "Running update script at target...\n"; + system("cd $target_dir && php bin/update.sh --version=$oldversion"); + echo "All done.\n"; } -else +else { echo "Update cancelled. See ya!\n"; +} ?> |