Browse Source

refactoring

master
Sven Ullmann 1 year ago
parent
commit
252537b516
  1. 2
      .gitignore
  2. 2
      README.md
  3. 64
      plugins/db/etc/config.json
  4. 22
      plugins/db/etc/live.my.cnf
  5. 22
      plugins/db/etc/stage.my.cnf
  6. 39
      plugins/db/src/commands/backup
  7. 140
      plugins/db/src/commands/create-config
  8. 17
      plugins/db/src/includes/bash_header
  9. 85
      plugins/db/src/includes/db
  10. 64
      plugins/db/src/includes/db_my
  11. 73
      plugins/db/src/includes/includes
  12. 77
      plugins/db/src/includes/includes.sh
  13. 12
      plugins/git/etc/config
  14. 9
      plugins/git/etc/config.json
  15. 10
      plugins/plesk/etc/config
  16. 11
      plugins/plesk/etc/config.json
  17. 70
      plugins/shopware5/etc/config
  18. 56
      plugins/shopware5/etc/config.json
  19. 86
      plugins/shopware6/etc/config
  20. 67
      plugins/shopware6/etc/config.json
  21. 0
      plugins/ssh/bin/commands/add-key
  22. 9
      plugins/ssh/bin/includes/bash_header
  23. 5
      plugins/ssh/bin/includes/includes
  24. 0
      plugins/ssh/bin/includes/includes.sh
  25. 108
      plugins/ssh/bin/includes/ssh
  26. 15
      plugins/ssh/etc/config
  27. 20
      plugins/ssh/etc/config.json
  28. 3
      src/commands/create-project
  29. 4
      src/commands/install-plugin
  30. 8
      src/commands/install-project-manager
  31. 2
      src/includes/config.php
  32. 35
      src/includes/json
  33. 78
      src/includes/json.php
  34. 146
      src/includes/main_functions
  35. 15
      src/includes/project_manager
  36. 0
      var/.keep
  37. 0
      var/tmp/.keep

2
.gitignore

@ -4,5 +4,7 @@
/src/postscripts/plugins/*
/data/*
/etc/*
/var/*
/var/tmp/*
!/**/.keep

2
README.md

@ -13,6 +13,8 @@ Hope you will enjoy. Free to use.
### Prerequisites
- PHP
- OpenSSL
- scp
### Install Project Manager

64
plugins/db/etc/config.json

@ -1,44 +1,44 @@
{
"db": {
"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": {
"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": {
"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": {
"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
}
}
}

22
plugins/db/etc/live.my.cnf

@ -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=

22
plugins/db/etc/stage.my.cnf

@ -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=

39
plugins/db/src/commands/backup

@ -8,37 +8,46 @@ function usage {
echo
echoSubTitle "Usage:"
echo
echo "project-manager db:backup [project-shortname] [env]"
echo "project-manager db:backup [shortname] [env]"
echo
echo " [env] can be live, stage, local_live or local_stage"
echo "[env]: can be live, stage, local_live or local_stage"
echo
echo "--help Prints this message"
echo "--ignored-data-tables space seperated list of ignored tables"
echo "--mysqldump-parameters space separated mysqldump parameters"
echo
echo "--help Prints this message"
echo
}
help="$(getParameter "--help" false "$*")"
if [ "$help" == true ] || [ "$1" == "" ]
then
usage
exit
fi
source "$(cd "$(dirname "${BASH_SOURCE[0]}")/.." &> /dev/null && pwd)/includes/bash_header"
shortname="$(getArgument "$1" "$(usageError "shortname required")" true)"
env="$(getArgument "$2" "$(usageError "env required")" true)"
ignoredDataTables="$(getParameter "--ignored-data-tables" "$*")"
mysqldumpParameters="$(getParameter "--mysqldump-parameters" "$*")"
initMy "$shortname" "$env"
source "$project_manager_dir/bin/includes/project_header"
env="$(getArgument "$2" "$(usage)" "live stage local_live local_stage")"
dbValidate
customer="$(getConfig false "project_manager.projects.$shortname.customer")"
project="$(getConfig false "project_manager.projects.$shortname.project")"
database=$(dbGetConfig "$env" "database")
dbBackupDir="$project_manager_dir/data/$customer/$project/backup/database";
if [ ! -d "$dbBackupDir" ]; then mkdir -p "$dbBackupDir"; fi
echo
echoMainTitle "Backup database $env"
echo
echo "Backup structure ..."
db="$(dbDump "$env" "structure" "--no-data" "$database")"
dbdumpStructureTempFile="$(dbDump "$shortname" "$env" "structure" "$ignoredDataTables" "$mysqldumpParameters")"
cp "$dbdumpStructureTempFile" "$project_manager_dir/data/$customer/$project/backup/."
rm "$dbdumpStructureTempFile"
echo "Database structure backed up to: $db"
echo "Backup data ..."
db="$(dbDump "$env" "data" "--no-create-info --skip-triggers" "$database")"
dbdumpDataTempFile="$(dbDump "$shortname" "$env" "data" "$ignoredDataTables" "$mysqldumpParameters")"
cp "$dbdumpDataTempFile" "$project_manager_dir/data/$customer/$project/backup/."
rm "$dbdumpDataTempFile"
echo "Database data backed up to: $db"
echo

140
plugins/db/src/commands/create-config

@ -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

17
plugins/db/src/includes/bash_header

@ -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"

85
plugins/db/src/includes/db

@ -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

64
plugins/db/src/includes/db_my

@ -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

73
plugins/db/src/includes/includes

@ -2,74 +2,5 @@
### DO NOT EDIT THIS FILE
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"
}
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd)/db"
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd)/db_my"

77
plugins/db/src/includes/includes.sh

@ -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"
}

12
plugins/git/etc/config

@ -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=''

9
plugins/git/etc/config.json

@ -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
}
}

10
plugins/plesk/etc/config

@ -1,10 +0,0 @@
#!/bin/bash
plesk_host=''
plesk_user=''
plesk_private_key=''
plesk_public_key=''
plesk_db_type='mysql'
plesk_binary='plesk'

11
plugins/plesk/etc/config.json

@ -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"
}
}

70
plugins/shopware5/etc/config

@ -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=''

56
plugins/shopware5/etc/config.json

@ -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
}
}

86
plugins/shopware6/etc/config

@ -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=''

67
plugins/shopware6/etc/config.json

@ -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
plugins/ssh/commands/add-key → plugins/ssh/bin/commands/add-key

9
plugins/ssh/bin/includes/bash_header

@ -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"

5
plugins/ssh/bin/includes/includes

@ -0,0 +1,5 @@
#!/bin/bash
### DO NOT EDIT THIS FILE
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd)/ssh"

0
plugins/ssh/includes/includes → plugins/ssh/bin/includes/includes.sh

108
plugins/ssh/bin/includes/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

15
plugins/ssh/etc/config

@ -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=''

20
plugins/ssh/etc/config.json

@ -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
}
}
}

3
src/commands/create-project

@ -58,8 +58,11 @@ echo "Shortname: $shortname"
echo
confirm
cryptkey="$(randkey)"
setConfig false "project_manager.projects.$shortname.customer" "$customer"
setConfig false "project_manager.projects.$shortname.project" "$project"
setConfig "$shortname" "project.cryptkey" "$cryptkey"
runPostscripts "create-project" "$shortname"

4
src/commands/install-plugin

@ -16,8 +16,8 @@ function usage {
source "$(cd "$(dirname "${BASH_SOURCE[0]}")/.." &> /dev/null && pwd)/includes/bash_header"
shortname=$(getArgument "$1" "$(usage)" true)
plugin=$(getArgument "$2" "$(usage)" true)
shortname=$(getArgument "$1" "shortname required" true)
plugin=$(getArgument "$2" "plugin required" true)
customer=$(getConfig false "project_manager.projects.$shortname.customer")
project=$(getConfig false "project_manager.projects.$shortname.project")
project_dir="$project_manager_dir/data/$customer/$project"

8
src/commands/install-project-manager

@ -23,11 +23,12 @@ echo
echoSubTitle "Please configure Sumedia Project Manager"
echo
cryptkey="$(randkey)"
workspaces_dir="$(readConsole "Workspaces dir" "Invalid selection" true "$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." &> /dev/null && pwd)")"
apache_httpdocs="$(readConsole "Local Apache httpdocs dir (optional)")"
config_source="$project_manager/etc/template/project_manager.json"
config_target="$project_manager/etc/config.json"
config_source="$project_manager_dir/etc/template/project_manager.json"
config_target="$project_manager_dir/etc/config.json"
if [ ! -d "$(dirname "$config_target")" ]
then
@ -36,11 +37,12 @@ fi
if [ ! -f "$config_target" ]
then
cp "$source" "$target"
cp "$config_source" "$config_target"
fi
setConfig false "project_manager.workspaces_dir" "$workspaces_dir"
setConfig false "project_manager.apache_httpdocs" "$apache_httpdocs"
setConfig false "project_manager.cryptkey" "$cryptkey"
runPostscripts "install-project-manager"

2
src/includes/config.php

@ -2,7 +2,7 @@
### DO NOT EDIT THIS FILE
global $project_manager_dir, $shortname, $configPath, $configuration;
global $project_manager_dir, $shortname, $configPath, $configuration, $value;
$configuration = [];
$project_manager_dir = dirname(dirname(__DIR__));
$command = $_SERVER['argv'][1];

35
src/includes/json

@ -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" "$@"

78
src/includes/json.php

@ -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;
}

146
src/includes/main_functions

@ -69,15 +69,20 @@ then
if [ "$allow" != false ] && [ "$(isAllowed "$var" "$allow")" == false ]
then
echo >&2
echoError "$errmsg" >&2
usage >&2
exit_program
usageError "$errmsg"
fi
echo "$var"
}
function usageError {
error="$(getArgument "$1")"
echo >&2
echoError "$error" >&2
usage >&2
exit_program
}
function isAllowed {
local var="$1"
local allow="$2"
@ -108,7 +113,7 @@ then
function readConsole {
local message="$1"
local errmsg="$2"
local errmsg=${2:-"Invalid"}
local allow=${3:-false}
local default="${4:-null}"
@ -155,14 +160,6 @@ then
fi
}
function usageError {
error="$(getArgument "$1")"
echo
echoError "$error"
usage
exit
}
function postScript {
local script=$(getArgument "$1")
if [ -f "$script" ]
@ -189,13 +186,55 @@ then
fi
}
function getCryptKey
{
local shortname="$(getArgument "$1" "shortname required" true)"
if [ "$shortname" != false]
then
echo "$(getConfig "$shortname" "project_manager.cryptkey")"
else
echo "$(getConfig "$shortname" "project_manager.projects.$shortname.cryptkey")"
fi
}
function getCryptedConfig
{
local shortname="$(getArgument "$1" "shortname required" true)"
local configPath="$(getArgument "$2" "configPath required" true)"
local cryptkey="$(getCryptKey "$shortname")"
if [ "$(hasConfig "$shortname" "$configPath")" == null ]
then
readCryptedConfig "$shortname" "$configPath"
fi
echo "$(decrypt "$(getConfig "$shortname" "$configPath")" "$cryptkey")"
}
function getConfig {
local shortname="$(getArgument "$1" "shortname required" true)"
local configPath="$(getArgument "$2" "configPath required" true)"
if [ "$(hasConfig "$shortname" "$configPath")" == null ]
then
readConfig "$shortname" "$configPath"
fi
local configScript="$project_manager_dir/src/includes/config"
echo "$(source "$configScript" get "$shortname" "$configPath")"
}
function setCryptedConfig
{
local shortname="$(getArgument "$1" "shortname required" true)"
local configPath="$(getArgument "$2" "configPath required" true)"
local value="$(getArgument "$3" "value required" true)"
local cryptkey="$(getCryptKey "$shortname")"
local configScript="$project_manager_dir/src/includes/config"
source "$configScript" set "$shortname" "$configPath" "$(encrypt "$value" "$cryptkey")"
}
function setConfig {
local shortname="$(getArgument "$1" "shortname required" true)"
local configPath="$(getArgument "$2" "configPath required" true)"
@ -219,4 +258,85 @@ then
echo "$(source "$configScript" has "$shortname" "$configPath")"
}
function readyCryptedConfig
{
local shortname="$(getArgument "$1" "shortname required" true)"
local configPath="$(getArgument "$2" "configPath required" true)"
local cryptkey="$(getCryptKey "$shortname")"
local value="$(encrypt "$(readConsole "Input config for: $configPath:")" "$cryptkey")"
setConfig "$shortname" "$configPath" "$value"
}
function readConfig {
local shortname="$(getArgument "$1" "shortname required" true)"
local configPath="$(getArgument "$2" "configPath required" true)"
local value="$(readConsole "Input config for: $configPath:")"
setConfig "$shortname" "$configPath" "$value"
}
function encrypt
{
local password="$(getArgument "$1" "password required" true)"
local cryptkey="$(getArgument "$2" "crypt key required" true)"
echo "$password" | openssl enc -base64 -aes-256-cbc -nosalt -nopad -pbkdf2 -k "$cryptkey"
}
function decrypt
{
local password="$(getArgument "$1" "password required" true)"
local cryptkey="$(getArgument "$2" "crypt key required" true)"
echo "$password" | openssl enc -da -aes-256-cbc -nosalt -nopad -pbkdf2 -k "$cryptkey"
}
function randkey
{
echo "$(openssl rand -base64 32)"
}
function rmEmptyDir {
local path="$(getArgument "$1" "path required" true)"
local length="$(getArgument "$2" "length required" true)"
if [ "$length" > 0 ]
then
if [ "$(ls -A $path)" == "" ]
then
rmdir "$path";
rmEmptyDir "$(dirname "$path")" $length-1
fi
fi
}
function jsonSet {
local container="$(getArgument "$1" "container required" true)"
local configPath="$(getArgument "$2" "configPath required" true)"
local value="$(getArgument "$3" "value required" true)"
local configScript="$project_manager_dir/src/includes/json"
echo "$(source "$configScript" set "$container" "$configPath" "$value")"
}
function jsonRemove {
local container="$(getArgument "$1" "container required" true)"
local configPath="$(getArgument "$2" "configPath required" true)"
local configScript="$project_manager_dir/src/includes/json"
echo "$(source "$configScript" remove "$container" "$configPath")"
}
function jsonGet {
local container="$(getArgument "$1" "container required" true)"
local configPath="$(getArgument "$2" "configPath required" true)"
local configScript="$project_manager_dir/src/includes/json"
echo "$(source "$configScript" get "$container" "$configPath")"
}
function jsonHas {
local container="$(getArgument "$1" "container required" true)"
local configPath="$(getArgument "$2" "configPath required" true)"
local configScript="$project_manager_dir/src/includes/json"
echo "$(source "$configScript" has "$container" "$configPath")"
}
fi

15
src/includes/project_manager

@ -25,4 +25,19 @@ then
cp "$source_config_file" "$target_config_source_config_file"
fi
}
function isPluginEnabled {
local shortname="$(getArgument "$1")"
local customer="$(getConfig false "project_manager.projects.$shortname.customer")"
local project="$(getConfig false "project_manager.projects.$shortname.project")"
local plugin="$(getArgument "$2")"
local plugin_enabled_dir="$project_manager_dir/data/$customer/$project/etc/$plugin"
if [ -d "$plugin_enabled_dir" ]
then
echo true
else
echo false
fi
}
fi

0
var/.keep

0
var/tmp/.keep

Loading…
Cancel
Save