Core  3.2
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  * @package FDL
6 */
7 /**
8  * detect pre migration script
9  *
10  * @author Anakeen
11  * @version $Id: $
12  * @package FDL
13  */
14 $WIFF_ROOT = getenv("WIFF_ROOT");
15 if ($WIFF_ROOT === false) {
16  print "WIFF_ROOT environment variable is not set!\n";
17  exit(1);
18 }
19 
20 $WIFF_CONTEXT_ROOT = getenv("WIFF_CONTEXT_ROOT");
21 if ($WIFF_CONTEXT_ROOT === false) {
22  print "WIFF_CONTEXT_ROOT environment variable not set!\n";
23  exit(1);
24 }
25 
26 set_include_path(get_include_path() . PATH_SEPARATOR . $WIFF_CONTEXT_ROOT . PATH_SEPARATOR . "$WIFF_ROOT/include");
27 
28 $prefix = $WIFF_CONTEXT_ROOT . "/WHAT/Lib.Prefix.php";
29 if (!include ($prefix)) {
30  print "cannot include file $prefix";
31  exit(1);
32 }
33 
34 include ("WHAT/Lib.Common.php");
35 include ("WHAT/Lib.WCheck.php");
36 
37 if ($argc != 2) {
38  printf("program %s need application parameter\n", $argv[0]);
39  exit(1);
40 }
41 $appname = $argv[1];
42 
44 if ($err) {
45  print $err;
46  exit(1);
47 }
48 
49 $app = $tapp[$appname];
50 if (!$app) {
51  printf("application %s not found\n", $argv[1]);
52  exit(1);
53 }
54 
55 require ('lib/Lib.Cli.php');
56 
57 $PGSERVICE_CORE = wiff_getParamValue('core_db');
58 $FREEDOM_CONTEXT = 'default';
59 
60 putenv(sprintf("wpub=%s", $WIFF_CONTEXT_ROOT));
61 putenv(sprintf("pgservice_core=%s", $PGSERVICE_CORE));
62 putenv(sprintf("pgservice_freedom=%s", $PGSERVICE_CORE));
63 putenv(sprintf("freedom_context=%s", $FREEDOM_CONTEXT));
64 
66  $appname => $app
67 ) , $actions);
68 
69 $appname_RE = preg_quote($appname, '@');
70 $premigr = array_filter($actions, function ($x) use ($appname_RE)
71 {
72  return preg_match("@/${appname_RE}_(pre)?migr@", $x);
73 });
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 ?>
$PGSERVICE_CORE
$appname_RE
global $pubdir
Definition: vault_init.php:18
getCheckActions($pubdir, $tapp, &$tact, $usePreviousVersion=false)
Definition: Lib.WCheck.php:198
if($err) $app
$ret
if($argc!=2) $appname
$prefix
$err
foreach($argv as $arg) $cmd
$WIFF_ROOT
if($WIFF_ROOT===false) $WIFF_CONTEXT_ROOT
print
Definition: checklist.php:49
$premigr
switch($command) exit
Definition: checkVault.php:46
getCheckApp($pubdir, &$tapp, $usePreviousVersion=false)
Definition: Lib.WCheck.php:146
$FREEDOM_CONTEXT
← centre documentaire © anakeen