Platform  3.1
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
pre_migration.php
Go to the documentation of this file.
1 #!/usr/bin/env php
2 <?php
3 /*
4  * @author Anakeen
5  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
6  * @package FDL
7 */
8 /**
9  * detect pre migration script
10  *
11  * @author Anakeen 2009
12  * @version $Id: $
13  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
14  * @package FDL
15  */
16 $WIFF_ROOT = getenv("WIFF_ROOT");
17 if ($WIFF_ROOT === false) {
18  print "WIFF_ROOT environment variable is not set!\n";
19  exit(1);
20 }
21 
22 $WIFF_CONTEXT_ROOT = getenv("WIFF_CONTEXT_ROOT");
23 if ($WIFF_CONTEXT_ROOT === false) {
24  print "WIFF_CONTEXT_ROOT environment variable not set!\n";
25  exit(1);
26 }
27 
28 set_include_path(get_include_path() . PATH_SEPARATOR . $WIFF_CONTEXT_ROOT . PATH_SEPARATOR . "$WIFF_ROOT/include");
29 
30 $prefix = $WIFF_CONTEXT_ROOT . "/WHAT/Lib.Prefix.php";
31 if (!include ($prefix)) {
32  print "cannot include file $prefix";
33  exit(1);
34 }
35 
36 include ("WHAT/Lib.Common.php");
37 include ("WHAT/Lib.WCheck.php");
38 
39 if ($argc != 2) {
40  printf("program %s need application parameter\n", $argv[0]);
41  exit(1);
42 }
43 $appname = $argv[1];
44 
46 if ($err) {
47  print $err;
48  exit(1);
49 }
50 
51 $app = $tapp[$appname];
52 if (!$app) {
53  printf("application %s not found\n", $argv[1]);
54  exit(1);
55 }
56 
57 require ('lib/Lib.Cli.php');
58 
59 $HTTPUSER = wiff_getParamValue('apacheuser');
60 $PGSERVICE_CORE = wiff_getParamValue('core_db');
61 $FREEDOM_CONTEXT = 'default';
62 
63 putenv(sprintf("wpub=%s", $WIFF_CONTEXT_ROOT));
64 putenv(sprintf("httpuser=%s", $HTTPUSER));
65 putenv(sprintf("pgservice_core=%s", $PGSERVICE_CORE));
66 putenv(sprintf("pgservice_freedom=%s", $PGSERVICE_CORE));
67 putenv(sprintf("freedom_context=%s", $FREEDOM_CONTEXT));
68 
70  $appname => $app
71 ) , $actions);
72 
73 $premigr = array_filter($actions, create_function('$x', "return preg_match('@/\\Q$appname\\E_(pre)?migr@', \$x);"));
74 
75 foreach ($premigr as $cmd) {
76  error_log(sprintf("Executing [%s]...", $cmd));
77  exec($cmd, $out, $ret);
78  print implode("\n", $out);
79  if ($ret != 0) {
80  error_log(sprintf("Failed!"));
81  exit($ret);
82  }
83  error_log(sprintf("Done."));
84 }
85 ?>
← centre documentaire © anakeen - published under CC License - Dynacase