commit | author | age
|
e6bb83
|
1 |
#!/usr/bin/env php |
T |
2 |
<?php |
|
3 |
/* |
|
4 |
+-----------------------------------------------------------------------+ |
|
5 |
| bin/installto.sh | |
|
6 |
| | |
|
7 |
| This file is part of the Roundcube Webmail client | |
|
8 |
| Copyright (C) 2011, The Roundcube Dev Team | |
|
9 |
| Licensed under the GNU GPL | |
|
10 |
| | |
|
11 |
| PURPOSE: | |
|
12 |
| Update an existing Roundcube installation with files from | |
|
13 |
| this version | |
|
14 |
+-----------------------------------------------------------------------+ |
|
15 |
| Author: Thomas Bruederli <roundcube@gmail.com> | |
|
16 |
+-----------------------------------------------------------------------+ |
|
17 |
|
|
18 |
$Id$ |
|
19 |
|
|
20 |
*/ |
|
21 |
|
|
22 |
define('INSTALL_PATH', realpath(dirname(__FILE__) . '/..') . '/' ); |
|
23 |
|
6cc3f5
|
24 |
require_once INSTALL_PATH . 'program/include/clisetup.php'; |
e6bb83
|
25 |
|
T |
26 |
$target_dir = unslashify($_SERVER['argv'][1]); |
|
27 |
|
|
28 |
if (empty($target_dir) || !is_dir(realpath($target_dir))) |
|
29 |
die("Invalid target: not a directory\nUsage: installto.sh <TARGET>\n"); |
|
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 |
die("No valid Roundcube installation found at $target_dir\n"); |
|
35 |
|
|
36 |
$oldversion = $m[1]; |
|
37 |
|
|
38 |
if (version_compare($oldversion, RCMAIL_VERSION, '>=')) |
|
39 |
die("Installation at target location is up-to-date!\n"); |
|
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 |
foreach (array('program','installer','bin','SQL','plugins','skins/default') as $dir) { |
373b11
|
48 |
if (!system("rsync -avC " . INSTALL_PATH . "$dir/* $target_dir/$dir/")) { |
e6bb83
|
49 |
$err = true; |
T |
50 |
break; |
|
51 |
} |
|
52 |
} |
|
53 |
foreach (array('index.php','.htaccess','config/main.inc.php.dist','config/db.inc.php.dist','CHANGELOG','README','UPGRADING') as $file) { |
373b11
|
54 |
if (!system("rsync -av " . INSTALL_PATH . "$file $target_dir/$file")) { |
e6bb83
|
55 |
$err = true; |
T |
56 |
break; |
|
57 |
} |
|
58 |
} |
|
59 |
echo "done.\n\n"; |
|
60 |
|
|
61 |
if (!$err) { |
|
62 |
echo "Running update script at target...\n"; |
|
63 |
system("cd $target_dir && bin/update.sh --version=$oldversion"); |
|
64 |
echo "All done.\n"; |
|
65 |
} |
|
66 |
} |
|
67 |
else |
|
68 |
echo "Update cancelled. See ya!\n"; |
|
69 |
|
|
70 |
?> |