Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
post_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 post 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 
43 $err = getCheckApp($pubdir, $tapp, true);
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, true);
68 
69 $appname_RE = preg_quote($appname, '@');
70 $postmigr = array_filter($actions, function ($x) use ($appname_RE)
71 {
72  return preg_match("@/${appname_RE}_(p|post)migr@", $x);
73 });
74 
75 foreach ($postmigr 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 ?>
if($err) $app
global $pubdir
Definition: vault_init.php:18
getCheckActions($pubdir, $tapp, &$tact, $usePreviousVersion=false)
Definition: Lib.WCheck.php:198
$PGSERVICE_CORE
$ret
$err
if($argc!=2) $appname
foreach($argv as $arg) $cmd
$postmigr
print
Definition: checklist.php:49
switch($command) exit
Definition: checkVault.php:46
$FREEDOM_CONTEXT
if($WIFF_ROOT===false) $WIFF_CONTEXT_ROOT
getCheckApp($pubdir, &$tapp, $usePreviousVersion=false)
Definition: Lib.WCheck.php:146
$WIFF_ROOT
$prefix
$appname_RE
← centre documentaire © anakeen