Sven Ullmann
2 years ago
19 changed files with 265 additions and 366 deletions
-
5.gitignore
-
3README.md
-
15bin/commands/create-project
-
3bin/commands/install-plugin
-
30bin/commands/install-project-manager
-
2bin/commands/list-projects
-
3bin/commands/remove-project
-
16bin/includes/bash_header
-
165bin/includes/config
-
30bin/includes/main_functions
-
191bin/includes/project_manager
-
24bin/project-manager
-
25etc/.config_template
-
3etc/.customers_template
-
5etc/.project_manager_config_template
-
3etc/.projects_template
-
3etc/.shortnames_template
-
57plugins/db/etc/config
-
44plugins/db/etc/config.json
@ -0,0 +1,165 @@ |
|||
#!/usr/bin/php |
|||
<?php |
|||
|
|||
### DO NOT EDIT THIS FILE |
|||
|
|||
function usage() { |
|||
echo "\n"; |
|||
echo "Get and Set configuration parameters\n"; |
|||
echo "\n"; |
|||
echo "Usage:\n"; |
|||
echo "\n"; |
|||
echo "config get [configPath]\n"; |
|||
echo "config set [configPath] [value]\n"; |
|||
echo "config remove [configPath]\n"; |
|||
echo "\n"; |
|||
echo "configPath: The config path is in the format 'project_manager.workspaces_dir'\n"; |
|||
echo "\n"; |
|||
echo "--help Prints this message\n"; |
|||
echo "\n"; |
|||
exit; |
|||
} |
|||
|
|||
if ($_SERVER['argc'] < 3 || $_SERVER['argv'] == '--help') { |
|||
usage(); |
|||
} |
|||
|
|||
global $project_manager_dir, $shortname, $configuration; |
|||
$configuration = []; |
|||
$project_manager_dir = dirname(dirname(__DIR__)); |
|||
$command = $_SERVER['argv'][1]; |
|||
$configPath = $_SERVER['argv'][2]; |
|||
$value = $_SERVER['argv'][3] ?? null; |
|||
$shortname = substr($configPath, 0, strpos($configPath, '.')); |
|||
$configPath = substr($configPath, strpos($configPath, '.')+1); |
|||
|
|||
if (function_exists($command)) { |
|||
loadProjectManagerConfig($project_manager_dir); |
|||
if ($shortname !== 'project_manager') { |
|||
loadProjectConfig(); |
|||
} |
|||
$command(); |
|||
} |
|||
|
|||
function mergeConfig($file) |
|||
{ |
|||
global $configuration; |
|||
$configuration = array_replace_recursive( |
|||
$configuration, |
|||
json_decode(file_get_contents($file), true) |
|||
); |
|||
} |
|||
|
|||
function loadProjectManagerConfig() |
|||
{ |
|||
global $configuration, $project_manager_dir; |
|||
$config_file = $project_manager_dir . '/etc/config.json'; |
|||
mergeConfig($config_file); |
|||
} |
|||
|
|||
function loadProjectConfig() |
|||
{ |
|||
global $configuration, $project_manager_dir; |
|||
$customer = getCustomerFromShortname(); |
|||
$project = getProjectFromShortname(); |
|||
|
|||
$config_file = "$project_manager_dir/data/$customer/$project/etc/config.json"; |
|||
mergeConfig($config_file); |
|||
|
|||
$plugin_dir = dirname($config_file) . '/plugins'; |
|||
$dh = opendir($plugin_dir); |
|||
if ($dh) { |
|||
while (false !== ($file = readdir($dh))) { |
|||
if ('.' === $file || '..' === $file || !is_dir($plugin_dir/$file)) { |
|||
continue; |
|||
} |
|||
$config_file = "$plugin_dir/$file/etc/config.json"; |
|||
mergeConfig($config_file); |
|||
} |
|||
} |
|||
} |
|||
|
|||
function getCustomerFromShortname() |
|||
{ |
|||
global $configuration, $shortname; |
|||
return $configuration['project_manager']['projects'][$shortname]['customer'] ?? null; |
|||
} |
|||
|
|||
function getProjectFromShortname() |
|||
{ |
|||
global $configuration, $shortname; |
|||
return $configuration['project_manager']['projects'][$shortname]['project'] ?? null; |
|||
} |
|||
|
|||
function parsePath() |
|||
{ |
|||
global $configPath; |
|||
$parsedPath = ''; |
|||
foreach (explode('.', $configPath) as $part) { |
|||
$parsedPath .= "['$part']"; |
|||
} |
|||
return $parsedPath; |
|||
} |
|||
|
|||
function is() |
|||
{ |
|||
global $configuration, $shortname; |
|||
return eval("return isset(\$configuration['$shortname']".parsePath().");"); |
|||
} |
|||
|
|||
function get() |
|||
{ |
|||
global $configuration, $shortname; |
|||
if (!is()) { |
|||
exit(1); |
|||
} |
|||
$return = eval("return \$configuration['$shortname']".parsePath().";"); |
|||
if (is_array($return)) { |
|||
$echo = ''; |
|||
foreach (array_keys($return) as $value) { |
|||
$echo .= '"'.$value.'" '; |
|||
} |
|||
$echo = trim($echo, ' '); |
|||
echo $echo; |
|||
exit; |
|||
} |
|||
echo $return; |
|||
} |
|||
|
|||
function set() |
|||
{ |
|||
global $configuration, $shortname, $value; |
|||
if (!is()) { |
|||
exit(1); |
|||
} |
|||
eval("\$configuration['$shortname']".parsePath()." = '$value';"); |
|||
writeConfig(); |
|||
} |
|||
|
|||
function remove() |
|||
{ |
|||
global $configuration, $shortname; |
|||
if (!is()) { |
|||
exit(1); |
|||
} |
|||
eval("unset \$configuration['$shortname']".parsePath().";"); |
|||
writeConfig(); |
|||
} |
|||
|
|||
function writeConfig() |
|||
{ |
|||
global $configuration, $shortname, $project_manager_dir; |
|||
$customer = getCustomerFromShortname(); |
|||
$project = getProjectFromShortname(); |
|||
|
|||
foreach($configuration as $shortname => $data) { |
|||
if ('project_manager' === $shortname) { |
|||
$config_file = "$project_manager_dir/etc/config.json"; |
|||
} elseif ('project' === $shortname) { |
|||
$config_file = "$project_manager_dir/data/$customer/$project/etc/config"; |
|||
} else { |
|||
$config_file = "$project_manager_dir/data/$customer/$project/etc/plugins/$shortname/config"; |
|||
} |
|||
file_put_contents($config_file, json_encode([$shortname => $data], JSON_PRETTY_PRINT)); |
|||
} |
|||
} |
@ -1,25 +0,0 @@ |
|||
#!/bin/bash |
|||
|
|||
### LOCAL STAGE ENV |
|||
|
|||
# url to stage |
|||
local_stage_url='' |
|||
|
|||
# The httpdocs folder on your server |
|||
local_stage_httpdocs_path='' |
|||
|
|||
### LOCAL LIVE ENV |
|||
|
|||
# url to live |
|||
local_live_url='' |
|||
|
|||
# The httpdocs folder on your server |
|||
local_live_httpdocs_path='' |
|||
|
|||
### POSTSCRIPTS |
|||
|
|||
app_dir= |
|||
if [ -f '$app_dir/etc/post_config.sh' ] |
|||
then |
|||
source '$app_dir/etc/post_config.sh' |
|||
fi |
@ -1,3 +0,0 @@ |
|||
#!/bin/bash |
|||
|
|||
project_manager_customers=() |
@ -1,5 +0,0 @@ |
|||
#!/bin/bash |
|||
|
|||
project_manager_workspaces_dir='' |
|||
project_manager_local_apache_httpdocs='' # leave empty if you don't want to use |
|||
project_manager_sudo_password='' # leave empty to fetch on call |
@ -1,3 +0,0 @@ |
|||
#!/bin/bash |
|||
|
|||
project_manager_projects=() |
@ -1,3 +0,0 @@ |
|||
#!/bin/bash |
|||
|
|||
project_manager_shortnames=() |
@ -1,57 +0,0 @@ |
|||
#!/bin/bash |
|||
|
|||
### STAGE |
|||
|
|||
db_stage_socket='' |
|||
db_stage_host='' |
|||
db_stage_port='' |
|||
db_stage_database='' |
|||
db_stage_user='' |
|||
db_stage_password='' |
|||
|
|||
# the admmin user is used to create and drop databases |
|||
db_stage_admin_user='' |
|||
db_stage_admin_password='' |
|||
|
|||
### LIVE |
|||
|
|||
db_live_socket='' |
|||
db_live_host='' |
|||
db_live_port='' |
|||
db_live_database='' |
|||
db_live_user='' |
|||
db_live_password='' |
|||
|
|||
# the admmin user is used to create and drop databases |
|||
db_live_admin_user='' |
|||
db_live_admin_password='' |
|||
|
|||
### LOCAL_STAGE |
|||
|
|||
# you can drive you local installation with a copy of stage or live |
|||
|
|||
db_local_stage_socket='' |
|||
db_local_stage_host='' |
|||
db_local_stage_port='' |
|||
db_local_stage_database='' |
|||
db_local_stage_user='' |
|||
db_local_stage_password='' |
|||
|
|||
# the admmin user is used to create and drop databases |
|||
db_local_stage_admin_user='' |
|||
db_local_stage_admin_password='' |
|||
|
|||
### LOCAL_LIVE |
|||
|
|||
# you can drive you local installation with a copy of stage or live |
|||
|
|||
db_local_live_socket='' |
|||
db_local_live_host='' |
|||
db_local_live_port='' |
|||
db_local_live_database='' |
|||
db_local_live_user='' |
|||
db_local_live_password='' |
|||
|
|||
# the admmin user is used to create and drop databases |
|||
db_local_live_admin_user='' |
|||
db_local_live_admin_password='' |
@ -0,0 +1,44 @@ |
|||
{ |
|||
"db": { |
|||
"stage": { |
|||
"socket": "", |
|||
"host": "", |
|||
"port": "", |
|||
"database": "", |
|||
"user": "", |
|||
"password": "", |
|||
"admin_user": "", |
|||
"admin_password": "" |
|||
}, |
|||
"live": { |
|||
"socket": "", |
|||
"host": "", |
|||
"port": "", |
|||
"database": "", |
|||
"user": "", |
|||
"password": "", |
|||
"admin_user": "", |
|||
"admin_password": "" |
|||
}, |
|||
"local_stage": { |
|||
"socket": "", |
|||
"host": "", |
|||
"port": "", |
|||
"database": "", |
|||
"user": "", |
|||
"password": "", |
|||
"admin_user": "", |
|||
"admin_password": "" |
|||
}, |
|||
"local_live": { |
|||
"socket": "", |
|||
"host": "", |
|||
"port": "", |
|||
"database": "", |
|||
"user": "", |
|||
"password": "", |
|||
"admin_user": "", |
|||
"admin_password": "" |
|||
} |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue