-
Notifications
You must be signed in to change notification settings - Fork 0
/
aggregate-vars.php
91 lines (74 loc) · 2.79 KB
/
aggregate-vars.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
//$pipe_dir = __DIR__.DIRECTORY_SEPARATOR."build/ptbuild/pipes" ;
$pipe_dir = "build/ptbuild/pipes" ;
$pipe_files = getDirContents($pipe_dir) ;
$other_files = array(
"vars/configuration_devcloud.php",
"vars/configuration_local.php",
"vars/configuration_production.php",
"vars/configuration_staging.php",
// "vars/default.php", Intentionally leave this, update it manually
"vars/production.php",
"vars/staging.php",
"vars/vm.php",
) ;
$files_to_update = array_merge($pipe_files, $other_files) ;
if ( isset($argv[1]) && ($argv[1] != '' || $argv[1] != false) ) {
$var_files_string = $argv[1] ;
} else {
echo "Comma seperated php files containing an array named vars or variables must be the first parameter to this script\n" ;
exit (1) ;
}
$var_files_array = explode(',', $var_files_string) ;
$isophp_example_application_home = getcwd().DIRECTORY_SEPARATOR ;
$output_string = '<?php '."\n" ;
$output_string .= ''."\n" ;
$output_string .= ' $vars = '."\n" ;
$output_string = '<?php '."\n" ;
$output_string = '<?php '."\n" ;
foreach ($files_to_merge as $file_to_merge) {
if ($to_from === 'to') {
$dir = dirname($isophp_home.$file_to_update) ;
if (!is_dir($dir)) mkdir($dir, 0755, true) ;
$comm = "cp {$isophp_example_application_home}{$file_to_update} {$isophp_home}{$file_to_update}" ;
} else {
$dir = dirname($isophp_example_application_home.$file_to_update) ;
if (!is_dir($dir)) mkdir($dir, 0755, true) ;
$comm = "cp {$isophp_home}{$file_to_update} {$isophp_example_application_home}{$file_to_update}" ;
}
if ( isset($argv[3]) && ($argv[3] == 'run') ) {
echo "run parameter included, performing commands for real\n" ;
system($comm) ;
} else {
if (!isset($runny)) {
echo "run parameter not included, just echoing what I would have run...\n" ;
$runny = true ;
}
echo "{$comm}\n" ;
}
}
function getDirContents($path) {
$rii = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path));
$files = array();
foreach ($rii as $file)
if (!$file->isDir())
$files[] = $file->getPathname();
return $files;
}
//function recursive_copy($source, $dest) {
//// $source = "dir/dir/dir";
//// $dest= "dest/dir";
//
// mkdir($dest, 0755);
// foreach (
// $iterator = new \RecursiveIteratorIterator(
// new \RecursiveDirectoryIterator($source, \RecursiveDirectoryIterator::SKIP_DOTS),
// \RecursiveIteratorIterator::SELF_FIRST) as $item
// ) {
// if ($item->isDir()) {
// mkdir($dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
// } else {
// copy($item, $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
// }
// }
//}