Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

installto.sh 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #!/usr/bin/env php
  2. <?php
  3. /*
  4. +-----------------------------------------------------------------------+
  5. | bin/installto.sh |
  6. | |
  7. | This file is part of the Roundcube Webmail client |
  8. | Copyright (C) 2014-2016, The Roundcube Dev Team |
  9. | |
  10. | Licensed under the GNU General Public License version 3 or |
  11. | any later version with exceptions for skins & plugins. |
  12. | See the README file for a full license statement. |
  13. | |
  14. | PURPOSE: |
  15. | Update an existing Roundcube installation with files from |
  16. | this version |
  17. +-----------------------------------------------------------------------+
  18. | Author: Thomas Bruederli <roundcube@gmail.com> |
  19. +-----------------------------------------------------------------------+
  20. */
  21. define('INSTALL_PATH', realpath(__DIR__ . '/..') . '/' );
  22. require_once INSTALL_PATH . 'program/include/clisetup.php';
  23. $target_dir = unslashify($_SERVER['argv'][1]);
  24. if (empty($target_dir) || !is_dir(realpath($target_dir)))
  25. rcube::raise_error("Invalid target: not a directory\nUsage: installto.sh <TARGET>", false, true);
  26. // read version from iniset.php
  27. $iniset = @file_get_contents($target_dir . '/program/include/iniset.php');
  28. if (!preg_match('/define\(.RCMAIL_VERSION.,\s*.([0-9.]+[a-z-]*)/', $iniset, $m))
  29. rcube::raise_error("No valid Roundcube installation found at $target_dir", false, true);
  30. $oldversion = $m[1];
  31. if (version_compare(version_parse($oldversion), version_parse(RCMAIL_VERSION), '>='))
  32. rcube::raise_error("Installation at target location is up-to-date!", false, true);
  33. echo "Upgrading from $oldversion. Do you want to continue? (y/N)\n";
  34. $input = trim(fgets(STDIN));
  35. if (strtolower($input) == 'y') {
  36. $err = false;
  37. echo "Copying files to target location...";
  38. // Save a copy of original .htaccess file (#1490623)
  39. if (file_exists("$target_dir/.htaccess")) {
  40. $htaccess_copied = copy("$target_dir/.htaccess", "$target_dir/.htaccess.orig");
  41. }
  42. $dirs = array('program','installer','bin','SQL','plugins','skins');
  43. if (is_dir(INSTALL_PATH . 'vendor') && !is_file(INSTALL_PATH . 'composer.json')) {
  44. $dirs[] = 'vendor';
  45. }
  46. foreach ($dirs as $dir) {
  47. // @FIXME: should we use --delete for all directories?
  48. $delete = in_array($dir, array('program', 'installer')) ? '--delete ' : '';
  49. if (!system("rsync -avC " . $delete . INSTALL_PATH . "$dir/* $target_dir/$dir/")) {
  50. $err = true;
  51. break;
  52. }
  53. }
  54. foreach (array('index.php','.htaccess','config/defaults.inc.php','composer.json-dist','CHANGELOG','README.md','UPGRADING','LICENSE','INSTALL') as $file) {
  55. if (!system("rsync -av " . INSTALL_PATH . "$file $target_dir/$file")) {
  56. $err = true;
  57. break;
  58. }
  59. }
  60. // remove old (<1.0) .htaccess file
  61. @unlink("$target_dir/program/.htaccess");
  62. echo "done.";
  63. // Inform the user about .htaccess change
  64. if (!empty($htaccess_copied)) {
  65. if (file_get_contents("$target_dir/.htaccess") != file_get_contents("$target_dir/.htaccess.orig")) {
  66. echo "\n!! Old .htaccess file saved as .htaccess.orig !!";
  67. }
  68. else {
  69. @unlink("$target_dir/.htaccess.orig");
  70. }
  71. }
  72. echo "\n\n";
  73. if (is_dir("$target_dir/skins/default")) {
  74. echo "Removing old default skin...";
  75. system("rm -rf $target_dir/skins/default $target_dir/plugins/jqueryui/themes/default");
  76. foreach (glob(INSTALL_PATH . "plugins/*/skins") as $plugin_skin_dir) {
  77. $plugin_skin_dir = preg_replace('!^.*' . INSTALL_PATH . '!', '', $plugin_skin_dir);
  78. if (is_dir("$target_dir/$plugin_skin_dir/classic"))
  79. system("rm -rf $target_dir/$plugin_skin_dir/default");
  80. }
  81. echo "done.\n\n";
  82. }
  83. if (!$err) {
  84. echo "Running update script at target...\n";
  85. system("cd $target_dir && php bin/update.sh --version=$oldversion");
  86. echo "All done.\n";
  87. }
  88. }
  89. else
  90. echo "Update cancelled. See ya!\n";
  91. ?>