Mercurial > hg > rc2
comparison bin/installto.sh @ 0:4681f974d28b
vanilla 1.3.3 distro, I hope
author | Charlie Root |
---|---|
date | Thu, 04 Jan 2018 15:52:31 -0500 |
parents | |
children | bf99236cc5cd |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4681f974d28b |
---|---|
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, 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 | |
22 define('INSTALL_PATH', realpath(__DIR__ . '/..') . '/' ); | |
23 | |
24 require_once INSTALL_PATH . 'program/include/clisetup.php'; | |
25 | |
26 $target_dir = unslashify($_SERVER['argv'][1]); | |
27 | |
28 if (empty($target_dir) || !is_dir(realpath($target_dir))) | |
29 rcube::raise_error("Invalid target: not a directory\nUsage: installto.sh <TARGET>", false, true); | |
30 | |
31 // read version from iniset.php | |
32 $iniset = @file_get_contents($target_dir . '/program/include/iniset.php'); | |
33 if (!preg_match('/define\(.RCMAIL_VERSION.,\s*.([0-9.]+[a-z-]*)/', $iniset, $m)) | |
34 rcube::raise_error("No valid Roundcube installation found at $target_dir", false, true); | |
35 | |
36 $oldversion = $m[1]; | |
37 | |
38 if (version_compare(version_parse($oldversion), version_parse(RCMAIL_VERSION), '>=')) | |
39 rcube::raise_error("Installation at target location is up-to-date!", false, true); | |
40 | |
41 echo "Upgrading from $oldversion. Do you want to continue? (y/N)\n"; | |
42 $input = trim(fgets(STDIN)); | |
43 | |
44 if (strtolower($input) == 'y') { | |
45 $err = false; | |
46 echo "Copying files to target location..."; | |
47 $dirs = array('program','installer','bin','SQL','plugins','skins'); | |
48 if (is_dir(INSTALL_PATH . 'vendor') && !is_file(INSTALL_PATH . 'composer.json')) { | |
49 $dirs[] = 'vendor'; | |
50 } | |
51 foreach ($dirs as $dir) { | |
52 if (!system("rsync -avC " . INSTALL_PATH . "$dir/* $target_dir/$dir/")) { | |
53 $err = true; | |
54 break; | |
55 } | |
56 } | |
57 foreach (array('index.php','.htaccess','config/defaults.inc.php','composer.json-dist','CHANGELOG','README.md','UPGRADING','LICENSE','INSTALL') as $file) { | |
58 if (!system("rsync -av " . INSTALL_PATH . "$file $target_dir/$file")) { | |
59 $err = true; | |
60 break; | |
61 } | |
62 } | |
63 // remove old (<1.0) .htaccess file | |
64 @unlink("$target_dir/program/.htaccess"); | |
65 echo "done.\n\n"; | |
66 | |
67 if (is_dir("$target_dir/skins/default")) { | |
68 echo "Removing old default skin..."; | |
69 system("rm -rf $target_dir/skins/default $target_dir/plugins/jqueryui/themes/default"); | |
70 foreach (glob(INSTALL_PATH . "plugins/*/skins") as $plugin_skin_dir) { | |
71 $plugin_skin_dir = preg_replace('!^.*' . INSTALL_PATH . '!', '', $plugin_skin_dir); | |
72 if (is_dir("$target_dir/$plugin_skin_dir/classic")) | |
73 system("rm -rf $target_dir/$plugin_skin_dir/default"); | |
74 } | |
75 echo "done.\n\n"; | |
76 } | |
77 | |
78 if (!$err) { | |
79 echo "Running update script at target...\n"; | |
80 system("cd $target_dir && php bin/update.sh --version=$oldversion"); | |
81 echo "All done.\n"; | |
82 } | |
83 } | |
84 else | |
85 echo "Update cancelled. See ya!\n"; | |
86 | |
87 ?> |