ServerMigration: install.php

File install.php, 2.0 KB (added by steve.winter, 11 years ago)
Line 
1<?php
2
3error_reporting(E_ALL);
4ini_set("display_errors", 1);
5
6/**
7 * Installs a specific application into the folder in which this file is placed.
8 *
9*/
10
11// configuration - subversion server
12$svnUsername                                            = '** SVN Username **';
13$svnPassword                                            = '** SVN Password **';
14$version                                                        = '** Current version **';
15
16// repository information
17$svn                                                            = 'https://svn.msdev.co.uk/';
18$repo                                                           = 'blinc';
19$branch                                                         = '/release/'.$version.'/src';
20$libCode                                                        = 'msLib/trunk/src/assets/lib/';
21
22// the code is going into the folder this file is in
23$path                                                           = dirname(__FILE__);
24
25// use a try/catch block to handle any errors
26try {
27        // array to hold data
28        $output                                                 = array();
29
30        // check that we have write access to the folder
31        if(!is_writeable($path)) {
32                throw new Exception('Unable to write to the document root. Please ensure that the web server (Apache of IIS) has write access to the folder you have placed this install file in.');
33        }
34
35        // now check out the code into the folder we're in
36        $cmd                                                    = 'svn export "'.$svn.$repo.$branch.'" "'.$path.'"'." --force --username {$svnUsername} --password {$svnPassword} --config-dir /tmp/ --non-interactive --trust-server-cert 2>&1";
37        $output[]                                               = $cmd;
38        exec($cmd, $output, $value);
39
40        // and the library code
41        $cmd                                                    = 'svn export "'.$svn.$libCode.'" "'.$path.'/assets/lib/"'." --force --username {$svnUsername} --password {$svnPassword} --config-dir /tmp/ --non-interactive --trust-server-cert 2>&1";
42        $output[]                                               = $cmd;
43        exec($cmd, $output, $value);
44
45        // and a little reminder at the end
46        $output[]                                               = " ************ IMPORTANT *************";
47        $output[]                                               = "     Remember to delete install.php";
48
49        // add the output from the svn export
50        $html                                                   = '<h3>Output results</h3><pre>'.print_r($output, true).'</pre>';
51} catch (Exception $e) {
52    $html                                                       = "<h3>Fatal error</h3><p>The following fatal error occured: {$e->getMessage()}</p>";
53}
54
55?>
56<html>
57        <body>
58                <?php echo $html; ?>
59        </body>
60</html>