Sven Ullmann
1 year ago
37 changed files with 862 additions and 514 deletions
-
2.gitignore
-
2README.md
-
64plugins/db/etc/config.json
-
22plugins/db/etc/live.my.cnf
-
22plugins/db/etc/stage.my.cnf
-
39plugins/db/src/commands/backup
-
140plugins/db/src/commands/create-config
-
17plugins/db/src/includes/bash_header
-
85plugins/db/src/includes/db
-
64plugins/db/src/includes/db_my
-
73plugins/db/src/includes/includes
-
77plugins/db/src/includes/includes.sh
-
12plugins/git/etc/config
-
9plugins/git/etc/config.json
-
10plugins/plesk/etc/config
-
11plugins/plesk/etc/config.json
-
70plugins/shopware5/etc/config
-
56plugins/shopware5/etc/config.json
-
86plugins/shopware6/etc/config
-
67plugins/shopware6/etc/config.json
-
0plugins/ssh/bin/commands/add-key
-
9plugins/ssh/bin/includes/bash_header
-
5plugins/ssh/bin/includes/includes
-
0plugins/ssh/bin/includes/includes.sh
-
108plugins/ssh/bin/includes/ssh
-
15plugins/ssh/etc/config
-
20plugins/ssh/etc/config.json
-
3src/commands/create-project
-
4src/commands/install-plugin
-
8src/commands/install-project-manager
-
2src/includes/config.php
-
35src/includes/json
-
78src/includes/json.php
-
146src/includes/main_functions
-
15src/includes/project_manager
-
0var/.keep
-
0var/tmp/.keep
@ -1,44 +1,44 @@ |
|||||
{ |
{ |
||||
"db": { |
"db": { |
||||
"stage": { |
"stage": { |
||||
"socket": "", |
|
||||
"host": "", |
|
||||
"port": "", |
|
||||
"database": "", |
|
||||
"user": "", |
|
||||
"password": "", |
|
||||
"admin_user": "", |
|
||||
"admin_password": "" |
|
||||
|
"socket": null, |
||||
|
"host": null, |
||||
|
"port": null, |
||||
|
"database": null, |
||||
|
"user": null, |
||||
|
"password": null, |
||||
|
"admin_user": null, |
||||
|
"admin_password": null |
||||
}, |
}, |
||||
"live": { |
"live": { |
||||
"socket": "", |
|
||||
"host": "", |
|
||||
"port": "", |
|
||||
"database": "", |
|
||||
"user": "", |
|
||||
"password": "", |
|
||||
"admin_user": "", |
|
||||
"admin_password": "" |
|
||||
|
"socket": null, |
||||
|
"host": null, |
||||
|
"port": null, |
||||
|
"database": null, |
||||
|
"user": null, |
||||
|
"password": null, |
||||
|
"admin_user": null, |
||||
|
"admin_password": null |
||||
}, |
}, |
||||
"local_stage": { |
"local_stage": { |
||||
"socket": "", |
|
||||
"host": "", |
|
||||
"port": "", |
|
||||
"database": "", |
|
||||
"user": "", |
|
||||
"password": "", |
|
||||
"admin_user": "", |
|
||||
"admin_password": "" |
|
||||
|
"socket": null, |
||||
|
"host": null, |
||||
|
"port": null, |
||||
|
"database": null, |
||||
|
"user": null, |
||||
|
"password": null, |
||||
|
"admin_user": null, |
||||
|
"admin_password": null |
||||
}, |
}, |
||||
"local_live": { |
"local_live": { |
||||
"socket": "", |
|
||||
"host": "", |
|
||||
"port": "", |
|
||||
"database": "", |
|
||||
"user": "", |
|
||||
"password": "", |
|
||||
"admin_user": "", |
|
||||
"admin_password": "" |
|
||||
|
"socket": null, |
||||
|
"host": null, |
||||
|
"port": null, |
||||
|
"database": null, |
||||
|
"user": null, |
||||
|
"password": null, |
||||
|
"admin_user": null, |
||||
|
"admin_password": null |
||||
} |
} |
||||
} |
} |
||||
} |
} |
@ -1,22 +0,0 @@ |
|||||
|
|
||||
### DO NOT EDIT THIS FILE |
|
||||
|
|
||||
[mysqldump] |
|
||||
max_allowed_packet=500M |
|
||||
socket= |
|
||||
host= |
|
||||
port= |
|
||||
|
|
||||
[mysql] |
|
||||
max_allowed_packet=500M |
|
||||
socket= |
|
||||
host= |
|
||||
port= |
|
||||
|
|
||||
[client] |
|
||||
user= |
|
||||
password= |
|
||||
|
|
||||
[clientadmin] |
|
||||
user= |
|
||||
password= |
|
@ -1,22 +0,0 @@ |
|||||
|
|
||||
### DO NOT EDIT THIS FILE |
|
||||
|
|
||||
[mysqldump] |
|
||||
max_allowed_packet=500M |
|
||||
socket= |
|
||||
host= |
|
||||
port= |
|
||||
|
|
||||
[mysql] |
|
||||
max_allowed_packet=500M |
|
||||
socket= |
|
||||
host= |
|
||||
port= |
|
||||
|
|
||||
[client] |
|
||||
user= |
|
||||
password= |
|
||||
|
|
||||
[clientadmin] |
|
||||
user= |
|
||||
password= |
|
@ -1,140 +0,0 @@ |
|||||
#!/bin/bash |
|
||||
|
|
||||
### DO NOT EDIT THIS FILE |
|
||||
|
|
||||
function usage { |
|
||||
echo |
|
||||
echoMainTitle "Create configuration files" |
|
||||
echo |
|
||||
echoSubTitle "Usage:" |
|
||||
echo |
|
||||
echo "project-manager db:create-config [project-shortname]" |
|
||||
echo |
|
||||
echo "--help Prints this message" |
|
||||
echo |
|
||||
} |
|
||||
|
|
||||
help="$(getParameter "--help" false "$*")" |
|
||||
if [ "$help" == true ] || [ "$1" == "" ] |
|
||||
then |
|
||||
usage |
|
||||
exit |
|
||||
fi |
|
||||
|
|
||||
source "$project_manager_dir/bin/includes/project_header" |
|
||||
dbValidate |
|
||||
|
|
||||
echo |
|
||||
echoMainTitle "Creating db configuration" |
|
||||
echo |
|
||||
echoSubTitle "Please verify data" |
|
||||
echo |
|
||||
echo "Stage Socket: $db_stage_socket" |
|
||||
echo "Stage Host: $db_stage_host" |
|
||||
echo "Stage Port: $db_stage_port" |
|
||||
echo "Stage Database: $db_stage_database" |
|
||||
echo "Stage Admin User: $db_stage_admin_user" |
|
||||
echo |
|
||||
echo "Live Socket: $db_live_socket" |
|
||||
echo "Live Host: $db_live_host" |
|
||||
echo "Live Port: $db_live_port" |
|
||||
echo "Live Database: $db_live_database" |
|
||||
echo "Live Admin User: $db_live_admin_user" |
|
||||
echo |
|
||||
echo "Local Stage Socket: $db_local_stage_socket" |
|
||||
echo "Local Stage Host: $db_local_stage_host" |
|
||||
echo "Local Stage Port: $db_local_stage_port" |
|
||||
echo "Local Stage Database: $db_local_stage_database" |
|
||||
echo "Local Stage Admin User: $db_local_stage_admin_user" |
|
||||
echo |
|
||||
echo "Local Live Socket: $db_local_live_socket" |
|
||||
echo "Local Live Host: $db_local_live_host" |
|
||||
echo "Local Live Port: $db_local_live_port" |
|
||||
echo "Local Live Database: $db_local_live_database" |
|
||||
echo "Local Live Admin User: $db_local_live_admin_user" |
|
||||
echo |
|
||||
confirm |
|
||||
|
|
||||
template_file="$project_manager_dir/plugins/db/etc/.my.cnf_template" |
|
||||
path="$project_manager_dir/data/$customer/$project" |
|
||||
|
|
||||
quoted_socket="$(sedEscape "$db_stage_socket")" |
|
||||
quoted_password="$(sedEscape "$db_stage_password")" |
|
||||
quoted_admin_password="$(sedEscape "$db_stage_admin_password")" |
|
||||
if [ "$quoted_socket" == "" ] |
|
||||
then |
|
||||
file_string="$(cat "$template_file" | sed "s/socket=//")" |
|
||||
else |
|
||||
file_string="$(cat "$template_file")" |
|
||||
fi |
|
||||
echo "$file_string" | \ |
|
||||
sed "s/socket=/socket=$quoted_socket/" | \ |
|
||||
sed "s/host=/host=$db_stage_host/" | \ |
|
||||
sed "s/port=/port=$db_stage_port/" | \ |
|
||||
sed "s/database=/database=$db_stage_database/" | \ |
|
||||
sed "s/\[client\]/\[client\]\nuser=$db_stage_user\npassword=$quoted_password/" | \ |
|
||||
sed "s/\[clientadmin\]/\[clientadmin\]\nuser=$db_stage_admin_user\npassword=$quoted_admin_password/" \ |
|
||||
> "$path/etc/stage.my.cnf" |
|
||||
|
|
||||
quoted_socket="$(sedEscape "$db_live_socket")" |
|
||||
quoted_password="$(sedEscape "$db_live_password")" |
|
||||
quoted_admin_password="$(sedEscape "$db_live_admin_password")" |
|
||||
if [ "$quoted_socket" == "" ] |
|
||||
then |
|
||||
file_string="$(cat "$template_file" | sed "s/socket=//")" |
|
||||
else |
|
||||
file_string="$(cat "$template_file")" |
|
||||
fi |
|
||||
echo "$file_string" | \ |
|
||||
sed "s/socket=/socket=$quoted_socket/" | \ |
|
||||
sed "s/host=/host=$db_live_host/" | \ |
|
||||
sed "s/port=/port=$db_live_port/" | \ |
|
||||
sed "s/database=/database=$db_live_database/" | \ |
|
||||
sed "s/\[client\]/\[client\]\nuser=$db_live_user\npassword=$quoted_password/" | \ |
|
||||
sed "s/\[clientadmin\]/\[clientadmin\]\nuser=$db_live_admin_user\npassword=$quoted_admin_password/" \ |
|
||||
> "$path/etc/live.my.cnf" |
|
||||
|
|
||||
quoted_socket="$(sedEscape "$db_local_stage_socket")" |
|
||||
quoted_password="$(sedEscape "$db_local_stage_password")" |
|
||||
quoted_admin_password="$(sedEscape "$db_local_stage_admin_password")" |
|
||||
if [ "$quoted_socket" == "" ] |
|
||||
then |
|
||||
file_string="$(cat "$template_file" | sed "s/socket=//")" |
|
||||
else |
|
||||
file_string="$(cat "$template_file")" |
|
||||
fi |
|
||||
echo "$file_string" | \ |
|
||||
sed "s/socket=/socket=$quoted_socket/" | \ |
|
||||
sed "s/host=/host=$db_local_stage_host/" | \ |
|
||||
sed "s/port=/port=$db_local_stage_port/" | \ |
|
||||
sed "s/database=/database=$db_local_stage_database/" | \ |
|
||||
sed "s/\[client\]/\[client\]\nuser=$db_local_stage_user\npassword=$quoted_password/" | \ |
|
||||
sed "s/\[clientadmin\]/\[clientadmin\]\nuser=$db_local_stage_admin_user\npassword=$quoted_admin_password/" \ |
|
||||
> "$path/etc/local_stage.my.cnf" |
|
||||
|
|
||||
quoted_socket="$(sedEscape "$db_local_live_socket")" |
|
||||
quoted_password="$(sedEscape "$db_local_live_password")" |
|
||||
quoted_admin_password="$(sedEscape "$db_local_live_admin_password")" |
|
||||
if [ "$quoted_socket" == "" ] |
|
||||
then |
|
||||
file_string="$(cat "$template_file" | sed "s/socket=//")" |
|
||||
else |
|
||||
file_string="$(cat "$template_file")" |
|
||||
fi |
|
||||
echo "$file_string" | \ |
|
||||
sed "s/socket=/socket=$quoted_socket/" | \ |
|
||||
sed "s/host=/host=$db_local_live_host/" | \ |
|
||||
sed "s/port=/port=$db_local_live_port/" | \ |
|
||||
sed "s/database=/database=$db_local_live_database/" | \ |
|
||||
sed "s/\[client\]/\[client\]\nuser=$db_local_live_user\npassword=$quoted_password/" | \ |
|
||||
sed "s/\[clientadmin\]/\[clientadmin\]\nuser=$db_local_live_admin_user\npassword=$quoted_admin_password/" \ |
|
||||
> "$path/etc/local_live.my.cnf" |
|
||||
|
|
||||
echo |
|
||||
echoSubTitle "Running postscripts ..." |
|
||||
postScript "$path/bin/postscripts/plugins/db/commands/create-config" |
|
||||
postScript "$workspaces_dir/$customer/$project/bin/postscripts/plugins/db/commands/create-config" |
|
||||
|
|
||||
echo |
|
||||
echoSuccess "Database configuration files created" |
|
||||
echo |
|
@ -0,0 +1,17 @@ |
|||||
|
#!/bin/bash |
||||
|
|
||||
|
### DO NOT EDIT THIS FILE |
||||
|
|
||||
|
source "$project_manager_dir/src/includes/bash_header" |
||||
|
|
||||
|
shortname="$(getArgument "$1" "shortname required" true)" |
||||
|
|
||||
|
if [ "$(isPluginEnabled "$shortname" "ssh")" == false ] |
||||
|
then |
||||
|
echo |
||||
|
echoError "Plugin 'db' depends on plugin 'ssh'" |
||||
|
echo |
||||
|
exit |
||||
|
fi |
||||
|
|
||||
|
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd)/includes" |
@ -0,0 +1,85 @@ |
|||||
|
#!/bin/bash |
||||
|
|
||||
|
### DO NOT EDIT THIS FILE |
||||
|
|
||||
|
if [ true != ${includes_db:-false} ] |
||||
|
then |
||||
|
includes_db=true |
||||
|
|
||||
|
function dbDump { |
||||
|
shortname="$(getArgument "$1" "shortname required" true)" |
||||
|
env="$(getArgument "$2" "env required" true)" |
||||
|
mode="$(getArgument "$3" "mode [structure|data|all]" "structure data all")" |
||||
|
skippedTables="$(getArgument "$4")" |
||||
|
mysqldumpParameters="$(getArgument "$5")" |
||||
|
|
||||
|
customer="$(getConfig false "project_manager.projects.$shortname.customer")" |
||||
|
project="$(getConfig false "project_manager.projects.$shortname.project")" |
||||
|
|
||||
|
if [ "$mode" == "all" ]; then mode=""; fi |
||||
|
if [ "$mode" == "data" ]; then mode="--no-create-info"; fi |
||||
|
if [ "$mode" == "structure" ]; then mode="--no-data"; fi |
||||
|
|
||||
|
if [[ "$env" == *"local_"* ]] |
||||
|
then |
||||
|
local=true |
||||
|
else |
||||
|
local=false |
||||
|
prepareSSHConnection "$shortname" "$env" |
||||
|
fi |
||||
|
|
||||
|
if [ "$local" == false ] |
||||
|
then |
||||
|
sshUser="$(getConfig "$shortname" "ssh.$env.user")" |
||||
|
sshDomain="$(getConfig "$shortname" "ssh.$env.domain")" |
||||
|
sshPort="$(getConfig "$shortname" "ssh.$env.port")" |
||||
|
fi |
||||
|
|
||||
|
socket="$(getConfig "$shortname" "db.$env.socket")" |
||||
|
host="$(getConfig "$shortname" "db.$env.host")" |
||||
|
database="$(getConfig "$shortname" "db.$env.database")" |
||||
|
user="$(getConfig "$shortname" "db.$env.user")" |
||||
|
port="$(getConfig "$shortname" "db.$env.port")" |
||||
|
password="$(getCryptedConfig "$shortname" "db.$env.password")" |
||||
|
admin_user="$(getConfig "$shortname" "db.$env.admin_user")" |
||||
|
admin_password="$(getConfig "$shortname" "db.$env.admin_password")" |
||||
|
|
||||
|
date="$(date +"%Y.%m.%d-%H:%M:%S")" |
||||
|
filenamePrefix="$shortname-$env.$date." |
||||
|
|
||||
|
local ignoreTables=""; |
||||
|
for table in "${skippedTables[@]}" |
||||
|
do |
||||
|
ignoredTables="$ignoredTables --ignore-table=\"$database.$table\"" |
||||
|
done |
||||
|
|
||||
|
local tempdir="$project_manager_dir/var/tmp/$customer/$project/dbdump" |
||||
|
if [ ! -d "$tempdir" ] |
||||
|
then |
||||
|
mkdir -p "$tempdir" |
||||
|
fi |
||||
|
|
||||
|
if [ "$local" == false ] |
||||
|
then |
||||
|
|
||||
|
|
||||
|
ssh -p "$sshPort" "$sshUser"@"$sshDomain" "cat \"$(generateMy "$shortname" "$env")\" > ~/$env.my.cnf" |
||||
|
ssh "$sshUser"@"$sshDomain" "mysqldump --defaults-extra-file=~/$env.my.cnf --no-tablespaces \ |
||||
|
$ignoredTables ${mysqldumpParameters[*]} $mode $database | \ |
||||
|
LANG=C LC_CTYPE=C LC_ALL=C sed -e 's/DEFINER[ ]*=[ ]*[^*]*\*/\*/' | \ |
||||
|
sed -e 's/,NO_AUTO_CREATE_USER//' | gzip -9 > ~/$filenamePrefix.sql.gz" |
||||
|
scp -P "$sshPort" "$sshUser"@"$sshDomain":"~/$filenamePrefix.sql.gz" "$tempdir/$filenamePrefix.sql.gz" |
||||
|
ssh -p "$sshPort" "$sshUser"@"$sshDomain" "unlink ~/$filenamePrefix.sql.gz" |
||||
|
else |
||||
|
cat "$(generateMy "$shortname" "$env")" > "$tempdir/$env.my.cnf" |
||||
|
mysqldump --defaults-extra-file="$tempdir/$env.my.cnf" --no-tablespaces \ |
||||
|
$ignoredTables ${mysqldumpParameters[*]} $mode $database | \ |
||||
|
LANG=C LC_CTYPE=C LC_ALL=C sed -e 's/DEFINER[ ]*=[ ]*[^*]*\*/\*/' | \ |
||||
|
sed -e 's/,NO_AUTO_CREATE_USER//' | gzip -9 > "$tempdir/$filenamePrefix.sql.gz" |
||||
|
rm "$tempdir/$env.my.cnf" |
||||
|
fi |
||||
|
|
||||
|
echo "$tempdir/$filenamePrefix.sql.gz" |
||||
|
} |
||||
|
|
||||
|
fi |
@ -0,0 +1,64 @@ |
|||||
|
#!/bin/bash |
||||
|
|
||||
|
### DO NOT EDIT THIS FILE |
||||
|
|
||||
|
if [ true != ${includes_db_my:-false} ] |
||||
|
then |
||||
|
includes_db_my=true |
||||
|
|
||||
|
myContainer=null |
||||
|
|
||||
|
function initMy { |
||||
|
if [ "$myContainer" != null ] |
||||
|
then |
||||
|
exit |
||||
|
fi |
||||
|
|
||||
|
local shortname="$(getArgument "$1" "shortname required" true)" |
||||
|
local env="$(getArgument "$2" "env required" true)" |
||||
|
|
||||
|
local socket="$(getConfig "$shortname" "db.$env.socket")" |
||||
|
local host="$(getConfig "$shortname" "db.$env.host")" |
||||
|
local database="$(getConfig "$shortname" "db.$env.database")" |
||||
|
local user="$(getConfig "$shortname" "db.$env.user")" |
||||
|
local port="$(getConfig "$shortname" "db.$env.port")" |
||||
|
local password="$(getCryptedConfig "$shortname" "db.$env.password")" |
||||
|
local admin_user="$(getConfig "$shortname" "db.$env.admin_user")" |
||||
|
local admin_password="$(getConfig "$shortname" "db.$env.admin_password")" |
||||
|
|
||||
|
jsonSet "$myContainer" "$shortname.$env.mysqldump.max_allowed_packet" "500M" |
||||
|
jsonSet "$myContainer" "$shortname.$env.mysqldump.socket" "$socket" |
||||
|
jsonSet "$myContainer" "$shortname.$env.mysqldump.host" "$host" |
||||
|
jsonSet "$myContainer" "$shortname.$env.mysqldump.port" "$port" |
||||
|
jsonSet "$myContainer" "$shortname.$env.mysql.max_allowed_packet" "500M" |
||||
|
jsonSet "$myContainer" "$shortname.$env.mysql.socket" "$socket" |
||||
|
jsonSet "$myContainer" "$shortname.$env.mysql.host" "$host" |
||||
|
jsonSet "$myContainer" "$shortname.$env.mysql.port" "$port" |
||||
|
jsonSet "$myContainer" "$shortname.$env.client.user" "$user" |
||||
|
jsonSet "$myContainer" "$shortname.$env.client.password" "$password" |
||||
|
jsonSet "$myContainer" "$shortname.$env.clientadmin.user" "$admin_user" |
||||
|
jsonSet "$myContainer" "$shortname.$env.clientadmin.password" "$admin_password" |
||||
|
} |
||||
|
|
||||
|
function generateMy { |
||||
|
local shortname="$(getArgument "$1" "shortname required" true)" |
||||
|
local env="$(getArgument "$2" "env required" true)" |
||||
|
local my="" |
||||
|
|
||||
|
local segments="$(jsonGet "$myContainer" "$shortname.$env")"; |
||||
|
for segmentName in "${segments[@]}" |
||||
|
do |
||||
|
my="\n$my"; |
||||
|
local parameters="$(jsonGet "$myContainer" "$shortname.$env.$segmentName")" |
||||
|
for parameterName in "$(parameters[@])" |
||||
|
do |
||||
|
local parameterValue="$(jsonGet "$myContainer" "$shortname.$env.$segmentName.$parameterName")" |
||||
|
my="$my\n$parameterName = $parameterValue" |
||||
|
done |
||||
|
my "$my\n" |
||||
|
done |
||||
|
|
||||
|
echo "$my" |
||||
|
} |
||||
|
|
||||
|
fi |
@ -0,0 +1,77 @@ |
|||||
|
#!/bin/bash |
||||
|
|
||||
|
### DO NOT EDIT THIS FILE |
||||
|
|
||||
|
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd)/db" |
||||
|
|
||||
|
db_included=true |
||||
|
|
||||
|
function dbValidate { |
||||
|
if ([ "$db_local_stage_user" == "" ] && [ "$db_local_live_user" == "" ]) |
||||
|
then |
||||
|
echo >&2 |
||||
|
echoError "Please configure $project_manager_dir/data/$customer/$project/etc/plugins/db/config" >&2 |
||||
|
echo >&2 |
||||
|
exit |
||||
|
fi |
||||
|
|
||||
|
if [ "$ssh_included" == "" ] |
||||
|
then |
||||
|
echo >&2 |
||||
|
echoError "Plugin \"ssh\" has to be included" >&2 |
||||
|
echo >&2 |
||||
|
exit |
||||
|
fi |
||||
|
} |
||||
|
|
||||
|
function dbGetConfig { |
||||
|
local env=$(getArgument "$1" "Usage dbGetConfig [live|stage|local_live|local_stage] var" "live stage local_live local_stage") |
||||
|
local suffix=$(getArgument "$2" "Usage dbGetConfig [live|stage|local_live|local_stage] var" true) |
||||
|
|
||||
|
echo "$(eval "echo \"\$db_${env}_$suffix\"")" |
||||
|
} |
||||
|
|
||||
|
function dbDump { |
||||
|
local env=$(getArgument "$1" "Usage: dbDump [env] [filename] [mysqldump-parameters] [database] [tables]" true) |
||||
|
local name=$(getArgument "$2" "Usage: dbDump [env] [filename] [mysqldump-parameters] [database] [tables]" true) |
||||
|
local parameters=$(getArgument "$3" "Usage: dbDump [env] [filename] [mysqldump-parameters] [database] [tables]") |
||||
|
local database=$(getArgument "$4" "Usage: dbDump [env] [filename] [mysqldump-parameters] [database] [tables]" true) |
||||
|
local tables=$(getArgument "$5" "Usage: dbDump [env] [filename] [mysqldump-parameters] [database] [tables]") |
||||
|
|
||||
|
local currentDate=$(date '+%Y-%m-%d_%H:%M:%S') |
||||
|
local is_remote="$(if [ "$env" == "live" ] || [ "$env" == "stage" ]; then echo 1; else echo 0; fi)" |
||||
|
|
||||
|
if [ "$is_remote" == 1 ] |
||||
|
then |
||||
|
local ssh_user="$(sshGetConfig "$env" "user")" |
||||
|
local ssh_domain="$(sshGetConfig "$env" "domain")" |
||||
|
sshAddKey "$env" |
||||
|
|
||||
|
scp "$app_dir/etc/plugins/db/$env.my.cnf" "$ssh_user"@"$ssh_domain":"~/$env.my.cnf" |
||||
|
ssh "$ssh_user"@"$ssh_domain" "mysqldump --defaults-extra-file=~/$env.my.cnf --no-tablespaces ${parameters[*]} $database $tables | \ |
||||
|
LANG=C LC_CTYPE=C LC_ALL=C sed -e 's/DEFINER[ ]*=[ ]*[^*]*\*/\*/' | \ |
||||
|
sed -e 's/,NO_AUTO_CREATE_USER//' | gzip -9 > ~/${env}_$name.sql.gz" |
||||
|
scp "$ssh_user"@"$ssh_domain":"~/${env}_$name.sql.gz" "$app_dir/var/tmp/$currentDate-${env}_$name.sql.gz" |
||||
|
ssh "$ssh_user"@"$ssh_domain" "unlink ~/${env}_$name.sql.gz" |
||||
|
|
||||
|
gunzip "$app_dir/var/tmp/$currentDate-${env}_$name.sql.gz" |
||||
|
else |
||||
|
mysqldump --defaults-extra-file="$app_dir/plugins/db/etc/${env}.my.cnf" --no-tablespaces ${parameters[*]} $database $tables | \ |
||||
|
LANG=C LC_CTYPE=C LC_ALL=C sed -e 's/DEFINER[ ]*=[ ]*[^*]*\*/\*/' | sed -e 's/,NO_AUTO_CREATE_USER//' \ |
||||
|
> "$app_dir/var/tmp/${currentDate}-${env}_$name.sql" |
||||
|
fi |
||||
|
|
||||
|
if [[ "$(tail -n 2 "$app_dir/var/tmp/$currentDate-${env}_$name.sql" )" != *"-- Dump completed"* ]] |
||||
|
then |
||||
|
rm "$app_dir/var/tmp/$currentDate-${env}_$name.sql" |
||||
|
echo |
||||
|
echoError "File was corrupted, deleting" |
||||
|
echo |
||||
|
exit |
||||
|
fi |
||||
|
|
||||
|
gzip -c "$app_dir/var/tmp/${currentDate}-${env}_$name.sql.gz" > "$app_dir/backup/database/${currentDate}-${env}_$name.sql.gz" |
||||
|
rm "$app_dir/var/tmp/$currentDate-${env}_$name.sql" |
||||
|
|
||||
|
echo "$app_dir/backup/database/$currentDate-${env}_$name.sql.gz" |
||||
|
} |
@ -1,12 +0,0 @@ |
|||||
#!/bin/bash |
|
||||
|
|
||||
### GIT |
|
||||
|
|
||||
# where is your project located in git |
|
||||
git_url='' |
|
||||
|
|
||||
# optionaly you can let empty and use https with password |
|
||||
git_ssh_user='' |
|
||||
git_ssh_domain='' |
|
||||
git_ssh_private_key='' |
|
||||
git_ssh_public_key='' |
|
@ -0,0 +1,9 @@ |
|||||
|
{ |
||||
|
"git": { |
||||
|
"git_url": null, |
||||
|
"git_ssh_user": null, |
||||
|
"git_ssh_domain": null, |
||||
|
"git_ssh_private_key": null, |
||||
|
"git_ssh_public_key": null |
||||
|
} |
||||
|
} |
@ -1,10 +0,0 @@ |
|||||
#!/bin/bash |
|
||||
|
|
||||
plesk_host='' |
|
||||
plesk_user='' |
|
||||
plesk_private_key='' |
|
||||
plesk_public_key='' |
|
||||
|
|
||||
plesk_db_type='mysql' |
|
||||
|
|
||||
plesk_binary='plesk' |
|
@ -0,0 +1,11 @@ |
|||||
|
{ |
||||
|
"plesk": { |
||||
|
"plesk_host": null, |
||||
|
"plesk_user": null, |
||||
|
"plesk_private_key": null, |
||||
|
"plesk_private_key_passphrase": null, |
||||
|
"plesk_public_key": null, |
||||
|
"plesk_db_type": null, |
||||
|
"plesk_binary": "plesk" |
||||
|
} |
||||
|
} |
@ -1,70 +0,0 @@ |
|||||
#!/bin/bash |
|
||||
|
|
||||
### GENERAL |
|
||||
|
|
||||
shopware5_httpdocs_subpath='' |
|
||||
|
|
||||
shopware5_local_user='' |
|
||||
shopware5_local_email='' |
|
||||
shopware5_local_firstname='' |
|
||||
shopware5_local_lastname='' |
|
||||
|
|
||||
shopware5_install_name='' |
|
||||
shopware5_install_email='' |
|
||||
shopware5_install_locale='' |
|
||||
shopware5_install_currency='' |
|
||||
shopware5_install_storefront_name='' |
|
||||
shopware5_install_storefront_url='' |
|
||||
|
|
||||
### URL MAPPING |
|
||||
|
|
||||
shopware5_live_urls=() |
|
||||
shopware5_stage_urls=() |
|
||||
shopware5_local_urls=() |
|
||||
|
|
||||
### GDPR SHOPWARE 6 TABLES |
|
||||
|
|
||||
shopware5_gdpr_tables=( |
|
||||
s_user |
|
||||
s_user_addresses |
|
||||
s_user_addresses_attributes |
|
||||
s_user_attributes |
|
||||
s_user_billingaddress |
|
||||
s_user_billingaddress_attributes |
|
||||
s_user_shippingaddress |
|
||||
s_user_shippingaddress_attributes |
|
||||
s_customer_search_index |
|
||||
s_customer_streams |
|
||||
s_customer_streams_attributes |
|
||||
s_customer_streams_mapping |
|
||||
s_mail_log |
|
||||
s_mail_log_contact |
|
||||
s_mail_log_document |
|
||||
s_mail_log_recipient |
|
||||
s_order_attributes |
|
||||
s_order_basket |
|
||||
s_order_basket_attributes |
|
||||
s_order_billingaddress |
|
||||
s_order_billingaddress_attributes |
|
||||
s_order_comparisons |
|
||||
s_order_details |
|
||||
s_order_details_attributes |
|
||||
s_order_documents |
|
||||
s_order_documents_attributes |
|
||||
s_order_esd |
|
||||
s_order_history |
|
||||
s_order_notes |
|
||||
s_order_shippingaddress |
|
||||
s_order_shippingaddress_attributes |
|
||||
) |
|
||||
|
|
||||
### Media Files |
|
||||
|
|
||||
shopware5_shared_files=( |
|
||||
'/files' |
|
||||
'/media' |
|
||||
) |
|
||||
|
|
||||
### MAILER |
|
||||
|
|
||||
shopware5_local_mailer_url='' |
|
@ -0,0 +1,56 @@ |
|||||
|
{ |
||||
|
"shopware5": { |
||||
|
"shopware5_httpdocs_subpath": null, |
||||
|
"shopware5_local_user": null, |
||||
|
"shopware5_local_email": null, |
||||
|
"shopware5_local_firstname": null, |
||||
|
"shopware5_local_lastname": null, |
||||
|
"shopware5_install_name": null, |
||||
|
"shopware5_install_email": null, |
||||
|
"shopware5_install_locale": null, |
||||
|
"shopware5_install_currency": null, |
||||
|
"shopware5_install_storefront_name": null, |
||||
|
"shopware5_install_storefront_url": null, |
||||
|
"shopware5_live_urls": [], |
||||
|
"shopware5_stage_urls": [], |
||||
|
"shopware5_local_urls": [], |
||||
|
"shopware5_gdpr_tables": [ |
||||
|
"s_user", |
||||
|
"s_user_addresses", |
||||
|
"s_user_addresses_attributes", |
||||
|
"s_user_attributes", |
||||
|
"s_user_billingaddress", |
||||
|
"s_user_billingaddress_attributes", |
||||
|
"s_user_shippingaddress", |
||||
|
"s_user_shippingaddress_attributes", |
||||
|
"s_customer_search_index", |
||||
|
"s_customer_streams", |
||||
|
"s_customer_streams_attributes", |
||||
|
"s_customer_streams_mapping", |
||||
|
"s_mail_log", |
||||
|
"s_mail_log_contact", |
||||
|
"s_mail_log_document", |
||||
|
"s_mail_log_recipient", |
||||
|
"s_order_attributes", |
||||
|
"s_order_basket", |
||||
|
"s_order_basket_attributes", |
||||
|
"s_order_billingaddress", |
||||
|
"s_order_billingaddress_attributes", |
||||
|
"s_order_comparisons", |
||||
|
"s_order_details", |
||||
|
"s_order_details_attributes", |
||||
|
"s_order_documents", |
||||
|
"s_order_documents_attributes", |
||||
|
"s_order_esd", |
||||
|
"s_order_history", |
||||
|
"s_order_notes", |
||||
|
"s_order_shippingaddress", |
||||
|
"s_order_shippingaddress_attributes" |
||||
|
], |
||||
|
"shopware5_shared_files": [ |
||||
|
"/files", |
||||
|
"/media" |
||||
|
], |
||||
|
"shopware5_local_mailer_url": null |
||||
|
} |
||||
|
} |
@ -1,86 +0,0 @@ |
|||||
#!/bin/bash |
|
||||
|
|
||||
### GENERAL |
|
||||
|
|
||||
shopware6_httpdocs_subpath='' |
|
||||
|
|
||||
shopware6_local_user='' |
|
||||
shopware6_local_email='' |
|
||||
shopware6_local_firstname='' |
|
||||
shopware6_local_lastname='' |
|
||||
|
|
||||
shopware6_install_name='' |
|
||||
shopware6_install_email='' |
|
||||
shopware6_install_locale='' |
|
||||
shopware6_install_currency='' |
|
||||
shopware6_install_storefront_name='' |
|
||||
shopware6_install_storefront_url='' |
|
||||
|
|
||||
### URL MAPPING |
|
||||
|
|
||||
shopware6_live_urls=() |
|
||||
shopware6_stage_urls=() |
|
||||
shopware6_local_urls=() |
|
||||
|
|
||||
### GDPR SHOPWARE 6 TABLES |
|
||||
|
|
||||
shopware6_gdpr_tables=( |
|
||||
acl_user_role |
|
||||
cart |
|
||||
customer |
|
||||
customer_address |
|
||||
customer_recovery |
|
||||
customer_tag |
|
||||
customer_wishlist |
|
||||
customer_wishlist_product |
|
||||
elasticsearch_index_task |
|
||||
import_export_log |
|
||||
integration |
|
||||
integration_role |
|
||||
log_entry |
|
||||
message_queue_stats |
|
||||
newsletter_recipient |
|
||||
newsletter_recipient_tag |
|
||||
order |
|
||||
order_address |
|
||||
order_customer |
|
||||
order_delivery |
|
||||
order_delivery_position |
|
||||
order_line_item |
|
||||
order_tag |
|
||||
order_transaction |
|
||||
product_export |
|
||||
product_review |
|
||||
promotion_persona_customer |
|
||||
refresh_token |
|
||||
sales_channel_api_context |
|
||||
state_machine_history |
|
||||
user |
|
||||
user_access_key |
|
||||
user_config |
|
||||
user_recovery |
|
||||
version |
|
||||
version_commit |
|
||||
version_commit_data |
|
||||
klarna_payment_request_log |
|
||||
payone_payment_card |
|
||||
payone_payment_mandate |
|
||||
payone_payment_redirect |
|
||||
unzer_payment_payment_device |
|
||||
unzer_payment_transfer_info |
|
||||
enqeueue |
|
||||
product_keyword_dictionary |
|
||||
product_search_keyword |
|
||||
) |
|
||||
|
|
||||
### Media Files |
|
||||
|
|
||||
shopware6_shared_files=( |
|
||||
'/files' |
|
||||
'/public/media' |
|
||||
'/public/thumbnails' |
|
||||
) |
|
||||
|
|
||||
### MAILER |
|
||||
|
|
||||
shopware6_local_mailer_url='' |
|
@ -0,0 +1,67 @@ |
|||||
|
{ |
||||
|
"shopware6": { |
||||
|
"shopware6_httpdocs_subpath": null, |
||||
|
"shopware6_local_user": null, |
||||
|
"shopware6_local_email": null, |
||||
|
"shopware6_local_firstname": null, |
||||
|
"shopware6_local_lastname": null, |
||||
|
"shopware6_install_name": null, |
||||
|
"shopware6_install_email": null, |
||||
|
"shopware6_install_locale": null, |
||||
|
"shopware6_install_currency": null, |
||||
|
"shopware6_install_storefront_name": null, |
||||
|
"shopware6_install_storefront_url": null, |
||||
|
"shopware6_live_urls": [], |
||||
|
"shopware6_stage_urls": [], |
||||
|
"shopware6_local_urls": [], |
||||
|
"shopware6_gdpr_tables": [ |
||||
|
"acl_user_role", |
||||
|
"cart", |
||||
|
"customer", |
||||
|
"customer_address", |
||||
|
"customer_recovery", |
||||
|
"customer_tag", |
||||
|
"customer_wishlist", |
||||
|
"customer_wishlist_product", |
||||
|
"elasticsearch_index_task", |
||||
|
"import_export_log", |
||||
|
"integration", |
||||
|
"integration_role", |
||||
|
"log_entry", |
||||
|
"message_queue_stats", |
||||
|
"newsletter_recipient", |
||||
|
"newsletter_recipient_tag", |
||||
|
"order", |
||||
|
"order_address", |
||||
|
"order_customer", |
||||
|
"order_delivery", |
||||
|
"order_delivery_position", |
||||
|
"order_line_item", |
||||
|
"order_tag", |
||||
|
"order_transaction", |
||||
|
"product_export", |
||||
|
"product_review", |
||||
|
"promotion_persona_customer", |
||||
|
"refresh_token", |
||||
|
"sales_channel_api_context" |
||||
|
"state_machine_history", |
||||
|
"user", |
||||
|
"user_access_key", |
||||
|
"user_config", |
||||
|
"user_recovery", |
||||
|
"klarna_payment_request_log", |
||||
|
"payone_payment_card", |
||||
|
"payone_payment_mandate", |
||||
|
"payone_payment_redirect", |
||||
|
"enqeueue", |
||||
|
"product_keyword_dictionary", |
||||
|
"product_search_keyword" |
||||
|
], |
||||
|
"shopware6_shared_files": [ |
||||
|
"/files", |
||||
|
"/public/media", |
||||
|
"/public/thumbnails" |
||||
|
], |
||||
|
"shopware6_local_mailer_url": null |
||||
|
} |
||||
|
} |
@ -0,0 +1,9 @@ |
|||||
|
#!/bin/bash |
||||
|
|
||||
|
### DO NOT EDIT THIS FILE |
||||
|
|
||||
|
source "$project_manager_dir/src/includes/bash_header" |
||||
|
|
||||
|
shortname="$(getArgument "$1" "shortname required" true)" |
||||
|
|
||||
|
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd)/ssh" |
@ -0,0 +1,5 @@ |
|||||
|
#!/bin/bash |
||||
|
|
||||
|
### DO NOT EDIT THIS FILE |
||||
|
|
||||
|
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd)/ssh" |
@ -0,0 +1,108 @@ |
|||||
|
#!/bin/bash |
||||
|
|
||||
|
### DO NOT EDIT THIS FILE |
||||
|
|
||||
|
if [ true != ${includes_ssh:-false} ] |
||||
|
then |
||||
|
includes_ssh=true |
||||
|
|
||||
|
function prepareSSHConnection { |
||||
|
local shortname="$(getArgument "$1" "shortname required" true)" |
||||
|
local env="$(getArgument "$2" "env required" true)" |
||||
|
local overwrite="$(getArgument "$3")" |
||||
|
|
||||
|
local privateKey="$(getConfig "$shortname" "ssh.$env.private_key")" |
||||
|
local publicKey="$(getConfig "$shortname" "ssh.$env.public_key")" |
||||
|
|
||||
|
copyProjectKeys "$shortname" "$env" "$overwrite" |
||||
|
installRemoteKey "$shortname" "$env" |
||||
|
addKey "$shortname" "$env" |
||||
|
} |
||||
|
|
||||
|
function copyProjectKeys |
||||
|
{ |
||||
|
local shortname="$(getArgument "$1" "shortname required" true)" |
||||
|
local env="$(getArgument "$2" "env required" true)" |
||||
|
local overwrite="$(getArgument "$3")" |
||||
|
|
||||
|
local customer="$(getConfig "$shortname" "project_manager.projects.$shortname.customer")" |
||||
|
local project="$(getConfig "$shortname" "project_manager.projects.$shortname.project")" |
||||
|
local privateKey="$(getConfig "$shortname" "ssh.$env.private_key")" |
||||
|
local publicKey="$(getConfig "$shortname" "ssh.$env.public_key")" |
||||
|
|
||||
|
if [ "$privateKey" == "" ] || [ "$publicKey" == "" ] |
||||
|
then |
||||
|
generateKeys "$shortname" "$env" |
||||
|
else |
||||
|
local privateKeyTarget="$project_manager_dir/data/$customer/$project/.ssh/$env.private.key" |
||||
|
local publicKeyTarget="$project_manager_dir/data/$customer/$project/.ssh/$env.public.key" |
||||
|
|
||||
|
if [ ! -f "$privateKeyTarget" ] || [ "$overwrite" == true ] |
||||
|
then |
||||
|
cp "$privateKey" "$privateKeyTarget" |
||||
|
chmod 0600 "$privateKeyTarget" |
||||
|
fi |
||||
|
|
||||
|
if [ ! -f "$publicKeyTarget" ] || [ "$overwrite" == true ] |
||||
|
then |
||||
|
cp "$publicKey" "$publicKeyTarget" |
||||
|
chmod 0600 "$publicKeyTarget" |
||||
|
fi |
||||
|
fi |
||||
|
} |
||||
|
|
||||
|
function installRemoteKey |
||||
|
{ |
||||
|
local shortname="$(getArgument "$1" "shortname required" true)" |
||||
|
local env="$(getArgument "$2" "env required" true)" |
||||
|
|
||||
|
local customer="$(getConfig "$shortname" "project_manager.projects.$shortname.customer")" |
||||
|
local project="$(getConfig "$shortname" "project_manager.projects.$shortname.project")" |
||||
|
local user="$(getConfig "$shortname" "ssh.$env.user")" |
||||
|
local domain="$(getConfig "$shortname" "ssh.$env.domain")" |
||||
|
local port="$(getConfig "$shortname" "ssh.$env.port")" |
||||
|
|
||||
|
local publicKey="$project_manager_dir/data/$customer/$project/.ssh/$env.public.key" |
||||
|
|
||||
|
echo "Please enter SSH $name system password:" |
||||
|
ssh-copy-id -p "$port" -i "$publicKey" "$user@$domain" |
||||
|
} |
||||
|
|
||||
|
function addKey { |
||||
|
local shortname="$(getArgument "$1" "shortname required" true)" |
||||
|
local env="$(getArgument "$2" "env required" true)" |
||||
|
|
||||
|
local customer="$(getConfig "$shortname" "project_manager.projects.$shortname.customer")" |
||||
|
local project="$(getConfig "$shortname" "project_manager.projects.$shortname.project")" |
||||
|
local publicKey="$project_manager_dir/data/$customer/$project/.ssh/$env.public.key" |
||||
|
|
||||
|
if [ ! -f "$publicKey" ] |
||||
|
then |
||||
|
copyProjectKeys "$shortname" "$env" |
||||
|
fi |
||||
|
} |
||||
|
|
||||
|
function generateKeys { |
||||
|
local shortname="$(getArgument "$1" "shortname required" true)" |
||||
|
local env="$(getArgument "$2" "env required" true)" |
||||
|
local overwrite="$(getArgument "$3")" |
||||
|
|
||||
|
local customer="$(getConfig "$shortname" "project_manager.projects.$shortname.customer")" |
||||
|
local project="$(getConfig "$shortname" "project_manager.projects.$shortname.project")" |
||||
|
local privateKey="$project_manager_dir/data/$customer/$project/.ssh/$env.private.key" |
||||
|
local publicKey="$project_manager_dir/data/$customer/$project/.ssh/$env.public.key" |
||||
|
|
||||
|
local tempDir="$project_manager_dir/var/tmp/$customer/$project/ssh-keys" |
||||
|
|
||||
|
if [[ (! -f "$privateKey" && ! -f "$publicKey") || "$overwrite" == true ]] |
||||
|
then |
||||
|
if [ ! -d "$tempDir" ]; then mkdir -p "$tempDir"; fi |
||||
|
ssh-keygen -b 4096 -t rsa -f "$tempDir/$env" -q -N "" |
||||
|
mv "$tempDir/$env" "$privateKey" |
||||
|
chmod 0600 "$privateKey" |
||||
|
mv "$tempDir/$env.pub" "$publicKey" |
||||
|
chmod 0600 "$publicKey" |
||||
|
rmEmptyDir "$tempDir" 3 |
||||
|
fi |
||||
|
} |
||||
|
fi |
@ -1,15 +0,0 @@ |
|||||
#!/bin/bash |
|
||||
|
|
||||
### STAGE |
|
||||
|
|
||||
ssh_stage_user='' |
|
||||
ssh_stage_domain='' |
|
||||
ssh_stage_private_key='' |
|
||||
ssh_stage_public_key='' |
|
||||
|
|
||||
### LIVE |
|
||||
|
|
||||
ssh_live_user='' |
|
||||
ssh_live_domain='' |
|
||||
ssh_live_private_key='' |
|
||||
ssh_live_public_key='' |
|
@ -0,0 +1,20 @@ |
|||||
|
{ |
||||
|
"ssh": { |
||||
|
"stage": { |
||||
|
"user": null, |
||||
|
"domain": null, |
||||
|
"port": null, |
||||
|
"private_key": null, |
||||
|
"public_key": null, |
||||
|
"key_passphrase": null |
||||
|
}, |
||||
|
"live": { |
||||
|
"user": null, |
||||
|
"domain": null, |
||||
|
"port": null, |
||||
|
"private_key": null, |
||||
|
"public_key": null, |
||||
|
"key_passphrase": null |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,35 @@ |
|||||
|
#!/bin/bash |
||||
|
|
||||
|
### DO NOT EDIT THIS FILE |
||||
|
|
||||
|
function usage { |
||||
|
echo |
||||
|
echoMainTitle "Sumedia Project Manager Json Container Helper" |
||||
|
echo |
||||
|
echoSubTitle "Usage:" |
||||
|
echo |
||||
|
echo "json get [container] [configPath]" |
||||
|
echo "json has [container] [configPath]" |
||||
|
echo |
||||
|
echo "This methods return complete container as string:" |
||||
|
echo "json set [container] [configPath] [value]" |
||||
|
echo "json remove [container] [configPath]" |
||||
|
echo |
||||
|
echo "--help Prints this message" |
||||
|
echo " " |
||||
|
exit |
||||
|
} |
||||
|
|
||||
|
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd)/bash_header" |
||||
|
|
||||
|
command="$(getArgument "$1" "Invalid command given" "get set has remove")" |
||||
|
container="$(getArgument "$2" "Invalid command given" "get set has remove")" |
||||
|
configPath="$(getArgument "$3")" |
||||
|
if [ "$command" == "set" ] |
||||
|
then |
||||
|
value="$(getArgument "$4" "Parameter value not given" true)" |
||||
|
fi |
||||
|
|
||||
|
PHP=`which php` |
||||
|
script="$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd)/json.php" |
||||
|
$PHP "$script" "$@" |
@ -0,0 +1,78 @@ |
|||||
|
<?php |
||||
|
|
||||
|
### DO NOT EDIT THIS FILE
|
||||
|
|
||||
|
global $configPath, $configuration, $value; |
||||
|
$command = $_SERVER['argv'][1]; |
||||
|
$container = $_SERVER['argv'][2]; |
||||
|
$configPath = $_SERVER['argv'][3]; |
||||
|
$value = $_SERVER['argv'][4] ?? null; |
||||
|
$configuration = json_decode($container, true); |
||||
|
|
||||
|
if (function_exists($command)) { |
||||
|
if (in_array($command, ['get', 'set', 'remove', 'has'])) { |
||||
|
$command(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
function getContainerAsString() |
||||
|
{ |
||||
|
global $configuration; |
||||
|
return json_encode($configuration, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); |
||||
|
} |
||||
|
|
||||
|
function set() |
||||
|
{ |
||||
|
global $configuration, $value; |
||||
|
$value = "null" === $value ? null : $value; |
||||
|
eval("\$configuration".parsePath()." = \$value;"); |
||||
|
echo getContainerAsString(); |
||||
|
} |
||||
|
|
||||
|
function remove() |
||||
|
{ |
||||
|
global $configuration; |
||||
|
eval("unset(\$configuration".parsePath().");"); |
||||
|
echo getContainerAsString(); |
||||
|
} |
||||
|
|
||||
|
function get() |
||||
|
{ |
||||
|
global $configuration; |
||||
|
if (!is()) { |
||||
|
echo null; |
||||
|
exit(1); |
||||
|
} |
||||
|
$return = eval("return \$configuration".parsePath().";"); |
||||
|
if (is_array($return)) { |
||||
|
$echo = ''; |
||||
|
foreach (array_keys($return) as $value) { |
||||
|
$echo .= '"'.$value.'" '; |
||||
|
} |
||||
|
$echo = trim($echo, ' '); |
||||
|
echo $echo; |
||||
|
exit; |
||||
|
} |
||||
|
echo $return; |
||||
|
} |
||||
|
|
||||
|
function has() |
||||
|
{ |
||||
|
echo is() ? 'true' : 'false'; |
||||
|
} |
||||
|
|
||||
|
function is() |
||||
|
{ |
||||
|
global $configuration; |
||||
|
return eval("return isset(\$configuration".parsePath().");"); |
||||
|
} |
||||
|
|
||||
|
function parsePath() |
||||
|
{ |
||||
|
global $configPath; |
||||
|
$parsedPath = ''; |
||||
|
foreach (explode('.', $configPath) as $part) { |
||||
|
$parsedPath .= "['$part']"; |
||||
|
} |
||||
|
return $parsedPath; |
||||
|
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue