Marius Cramer
2014-08-13 42539643c396f9d8865dcf9a51b13dc869709d16
commit | author | age
66768a 1 <?php
T 2
3 /*
4 Copyright (c) 2009, Till Brehm, projektfarm Gmbh
5 All rights reserved.
6
7 Redistribution and use in source and binary forms, with or without modification,
8 are permitted provided that the following conditions are met:
9
10     * Redistributions of source code must retain the above copyright notice,
11       this list of conditions and the following disclaimer.
12     * Redistributions in binary form must reproduce the above copyright notice,
13       this list of conditions and the following disclaimer in the documentation
14       and/or other materials provided with the distribution.
15     * Neither the name of ISPConfig nor the names of its contributors
16       may be used to endorse or promote products derived from this software without
17       specific prior written permission.
18
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26 OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
02c5c1 31 function sread() {
7fe908 32     $input = fgets(STDIN);
MC 33     return rtrim($input);
02c5c1 34 }
T 35
36 function swrite($text = '') {
37     echo $text;
38 }
39
40 function swriteln($text = '') {
41     echo $text."\n";
42 }
43
66768a 44 function simple_query($query, $answers, $default)
7fe908 45 {
MC 46     $finished = false;
47     do {
48         $answers_str = implode(',', $answers);
49         swrite($query.' ('.$answers_str.') ['.$default.']: ');
50         $input = sread();
51
52         //* Stop the installation
53         if($input == 'quit') {
54             swriteln("Installation terminated by user.\n");
55             die();
56         }
57
58         //* Select the default
59         if($input == '') {
60             $answer = $default;
61             $finished = true;
62         }
63
64         //* Set answer id valid
65         if(in_array($input, $answers)) {
66             $answer = $input;
67             $finished = true;
68         }
69
70     } while ($finished == false);
71     swriteln();
72     return $answer;
66768a 73 }
T 74
7fe908 75 require_once '/usr/local/ispconfig/server/lib/config.inc.php';
66768a 76
T 77
7fe908 78 echo "\n\n".str_repeat('-', 80)."\n";
MC 79 echo " _____ ___________   _____              __ _
80 |_   _/  ___| ___ \ /  __ \            / _(_)
81   | | \ `--.| |_/ / | /  \/ ___  _ __ | |_ _  __ _
66768a 82   | |  `--. \  __/  | |    / _ \| '_ \|  _| |/ _` |
T 83  _| |_/\__/ / |     | \__/\ (_) | | | | | | | (_| |
84  \___/\____/\_|      \____/\___/|_| |_|_| |_|\__, |
85                                               __/ |
86                                              |___/ ";
7fe908 87 echo "\n".str_repeat('-', 80)."\n";
66768a 88 echo "\n\n>> Update  \n\n";
d5b5d4 89 echo "Please choose the update method. For production systems select 'stable'. \nWARNING: The update from GIT is only for development systems and may break your current setup. Do not use the GIT version on servers that host any live websites!\nNote: Update all slave server, before you update master server.\n\n";
66768a 90
d5b5d4 91 $method = simple_query('Select update method', array('stable', 'git'), 'stable');
66768a 92
T 93 if($method == 'stable') {
d1a659 94     $new_version = @file_get_contents('http://www.ispconfig.org/downloads/ispconfig3_version.txt') or die('Unable to retrieve version file.');
66768a 95     $new_version = trim($new_version);
1df8fd 96     if(version_compare($new_version, ISPC_APP_VERSION, '>')) {
1ff812 97         passthru('/usr/local/ispconfig/server/scripts/update_from_tgz.sh');
f99160 98         exit;
66768a 99     } else {
67cae4 100         echo "There are no updates available for ISPConfig ".ISPC_APP_VERSION."\n";
66768a 101     }
T 102 } else {
b34f99 103     passthru('/usr/local/ispconfig/server/scripts/update_from_dev.sh');
f99160 104     exit;
66768a 105 }
T 106
107
108
7fe908 109 ?>