Browse Source

fix " ' config issue add db:create-config

master
Sven Ullmann 2 years ago
parent
commit
9935eed95e
  1. 20
      bin/commands/create-project
  2. 4
      bin/commands/install-project-manager
  3. 10
      bin/commands/list-projects
  4. 8
      bin/commands/remove-project
  5. 1
      bin/includes/includes
  6. 2
      bin/project-manager
  7. 24
      etc/.config_template
  8. 4
      etc/.project_manager_config_template
  9. 115
      plugins/db/commands/create-config
  10. 64
      plugins/db/etc/.config_template
  11. 17
      plugins/db/etc/.my.cnf_template
  12. 20
      plugins/db/includes/includes
  13. 11
      plugins/git/commands/clone
  14. 10
      plugins/git/etc/.config_template
  15. 32
      plugins/shopware/etc/.config_template
  16. 16
      plugins/ssh/etc/.config_template

20
bin/commands/create-project

@ -22,7 +22,7 @@ function usage {
echo echo
} }
help="$(getParameter "--help" false "$@")"
help="$(getParameter "--help" false "$*")"
if [ "$help" == true ] || [ "$1" == "" ] if [ "$help" == true ] || [ "$1" == "" ]
then then
usage usage
@ -102,9 +102,9 @@ if [ ! -f "$path/etc/config" ]
then then
quoted="$(sedEscape "$project_manager_dir")" quoted="$(sedEscape "$project_manager_dir")"
cat "$project_manager_dir/etc/.config_template" | \ cat "$project_manager_dir/etc/.config_template" | \
sed "s/app_customer=\"\"/app_customer=\"$customer\"/" | \
sed "s/app_project=\"\"/app_project=\"$project\"/" | \
sed "s/app_project_manager_dir=\"\"/app_project_manager_dir=\"$quoted\"/" \
sed "s/app_customer=''/app_customer='$customer'/" | \
sed "s/app_project=''/app_project='$project'/" | \
sed "s/app_project_manager_dir=''/app_project_manager_dir='$quoted'/" \
> "$path/etc/config" > "$path/etc/config"
fi fi
@ -129,28 +129,28 @@ projects_string='';
for i in "${!projects[@]}" for i in "${!projects[@]}"
do do
((nr=i+1)) ((nr=i+1))
projects_string+="$(echo -e "\n\t\"${projects[$i]}\" # $nr")"
projects_string+="$(echo -e "\n\t'${projects[$i]}' # $nr")"
done done
((nr=nr+1)) ((nr=nr+1))
projects_string+="$(echo -e "\n\t\"$project\" # $nr")"
projects_string+="$(echo -e "\n\t'$project' # $nr")"
shortnames_string=''; shortnames_string='';
for i in "${!shortnames[@]}" for i in "${!shortnames[@]}"
do do
((nr=i+1)) ((nr=i+1))
shortnames_string+="$(echo -e "\n\t\"${shortnames[$i]}\" # $nr")"
shortnames_string+="$(echo -e "\n\t'${shortnames[$i]}' # $nr")"
done done
((nr=nr+1)) ((nr=nr+1))
shortnames_string+="$(echo -e "\n\t\"$shortname\" # $nr")"
shortnames_string+="$(echo -e "\n\t'$shortname' # $nr")"
customers_string=''; customers_string='';
for i in "${!customers[@]}" for i in "${!customers[@]}"
do do
((nr=i+1)) ((nr=i+1))
customers_string+="$(echo -e "\n\t\"${customers[$i]}\" # $nr")"
customers_string+="$(echo -e "\n\t'${customers[$i]}' # $nr")"
done done
((nr=nr+1)) ((nr=nr+1))
customers_string+="$(echo -e "\n\t\"$customer\" # $nr")"
customers_string+="$(echo -e "\n\t'$customer' # $nr")"
cat <<- EOF > "$project_manager_dir/etc/projects" cat <<- EOF > "$project_manager_dir/etc/projects"
#!/bin/bash #!/bin/bash

4
bin/commands/install-project-manager

@ -33,8 +33,8 @@ project_manager_dir="$(readConsole "Project Manager Dir" "Invalid selection" tru
if [ ! -f "$project_manager_dir/etc/config" ] if [ ! -f "$project_manager_dir/etc/config" ]
then then
cat "$project_manager_dir/etc/.project_manager_config_template" | \ cat "$project_manager_dir/etc/.project_manager_config_template" | \
sed "s/workspaces_dir=\"\"/workspaces_dir=\"$(sedEscape "$workspaces_dir")\"/" | \
sed "s/project_manager_dir=\"\"/project_manager_dir=\"$(sedEscape "$project_manager_dir")\"/" \
sed "s/workspaces_dir=''/workspaces_dir='$(sedEscape "$workspaces_dir")'/" | \
sed "s/project_manager_dir=''/project_manager_dir='$(sedEscape "$project_manager_dir")'/" \
> "$project_manager_dir/etc/config" > "$project_manager_dir/etc/config"
fi fi

10
bin/commands/list-projects

@ -36,15 +36,15 @@ if [ "$help" == true ]
then then
usage usage
exit exit
else
if [ "${#projects[@]}" -eq 0 ]
then
fi
if [ "${#projects[@]}" -eq 0 ]
then
echo echo
echo "There are currently no projects setted up" echo "There are currently no projects setted up"
echo echo
else
else
listProjects listProjects
fi
fi fi
echoSuccess "Listing done" echoSuccess "Listing done"

8
bin/commands/remove-project

@ -17,7 +17,7 @@ function usage {
echo echo
} }
help="$(getParameter "--help" false "$@")"
help="$(getParameter "--help" false "$*")"
if [ "$help" == true ] || [ "$1" == "" ] if [ "$help" == true ] || [ "$1" == "" ]
then then
usage usage
@ -85,7 +85,7 @@ do
if [ "$i" != "$index" ] if [ "$i" != "$index" ]
then then
((nr=nr+1)) ((nr=nr+1))
projects_string+="$(echo -e "\n\t\"${projects[$i]}\" # $nr")"
projects_string+="$(echo -e "\n\t'${projects[$i]}' # $nr")"
fi fi
done done
@ -96,7 +96,7 @@ do
if [ "$i" != "$index" ] if [ "$i" != "$index" ]
then then
((nr=nr+1)) ((nr=nr+1))
shortnames_string+="$(echo -e "\n\t\"${shortnames[$i]}\" # $nr")"
shortnames_string+="$(echo -e "\n\t'${shortnames[$i]}' # $nr")"
fi fi
done done
@ -107,7 +107,7 @@ do
if [ "$i" != "$index" ] if [ "$i" != "$index" ]
then then
((nr=nr+1)) ((nr=nr+1))
customers_string+="$(echo -e "\n\t\"${customers[$i]}\" # $nr")"
customers_string+="$(echo -e "\n\t'${customers[$i]}' # $nr")"
fi fi
done done

1
bin/includes/includes

@ -201,7 +201,6 @@ then
fi fi
} }
plugin_dir="$project_manager_dir/plugins" plugin_dir="$project_manager_dir/plugins"
plugins="$(ls -t "$plugin_dir")" plugins="$(ls -t "$plugin_dir")"
for plugin in ${plugins[*]} for plugin in ${plugins[*]}

2
bin/project-manager

@ -137,7 +137,7 @@ else
echo echo
exit exit
else else
source "$file" "${@:2}"
source "$file" "${*:2}"
fi fi
echo echo

24
etc/.config_template

@ -2,40 +2,40 @@
### GENERAL ### GENERAL
app_customer=""
app_project=""
app_project_manager_dir=""
app_customer=''
app_project=''
app_project_manager_dir=''
### STAGE ### STAGE
# The httpdocs folder on your server # The httpdocs folder on your server
stage_httpdocs_path=""
stage_httpdocs_path=''
# subpath from httpdocs to your installation of the project # subpath from httpdocs to your installation of the project
stage_httpdocs_git_subpath=""
stage_httpdocs_git_subpath=''
### LIVE ### LIVE
# The httpdocs folder on your server # The httpdocs folder on your server
live_httpdocs_path=""
live_httpdocs_path=''
# subpath from httpdocs to your installation of the project # subpath from httpdocs to your installation of the project
live_httpdocs_git_subpath=""
live_httpdocs_git_subpath=''
### LOCAL STAGE ### LOCAL STAGE
# url to your project on the local machine # url to your project on the local machine
local_stage_host=""
local_stage_host=''
### LOCAL LIVE ### LOCAL LIVE
# url to your project on the local machine # url to your project on the local machine
local_live_host=""
local_live_host=''
### POST SCRIPT ### POST SCRIPT
app_dir="$app_project_manager_dir/data/$customer/$project"
if [ -f "$app_dir/etc/post_config.sh" ]
app_dir='$app_project_manager_dir/data/$customer/$project'
if [ -f '$app_dir/etc/post_config.sh' ]
then then
source "$app_dir/etc/post_config.sh"
source '$app_dir/etc/post_config.sh'
fi fi

4
etc/.project_manager_config_template

@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
workspaces_dir=""
project_manager_dir=""
workspaces_dir=''
project_manager_dir=''

115
plugins/db/commands/create-config

@ -0,0 +1,115 @@
#!/bin/bash
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")"
cat "$template_file" | \
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")"
cat "$template_file" | \
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")"
cat "$template_file" | \
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")"
cat "$template_file" | \
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

64
plugins/db/etc/.config_template

@ -2,56 +2,56 @@
### STAGE ### STAGE
db_stage_socket=""
db_stage_host=""
db_stage_port=""
db_stage_name=""
db_stage_user=""
db_stage_password=""
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 # the admmin user is used to create and drop databases
db_stage_admin_user=""
db_stage_admin_password=""
db_stage_admin_user=''
db_stage_admin_password=''
### LIVE ### LIVE
db_live_socket=""
db_live_host=""
db_live_port=""
db_live_name=""
db_live_user=""
db_live_password=""
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 # the admmin user is used to create and drop databases
db_live_admin_user=""
db_live_admin_password=""
db_live_admin_user=''
db_live_admin_password=''
### LOCAL_STAGE ### LOCAL_STAGE
# you can drive you local installation with a copy of stage or live # 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_name=""
db_local_stage_user=""
db_local_stage_password=""
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 # the admmin user is used to create and drop databases
db_local_stage_admin_user=""
db_local_stage_admin_password=""
db_local_stage_admin_user=''
db_local_stage_admin_password=''
### LOCAL_LIVE ### LOCAL_LIVE
# you can drive you local installation with a copy of stage or 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_name=""
db_local_live_user=""
db_local_live_password=""
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 # the admmin user is used to create and drop databases
db_local_live_admin_user=""
db_local_live_admin_password=""
db_local_live_admin_user=''
db_local_live_admin_password=''

17
plugins/db/etc/.my.cnf_template

@ -0,0 +1,17 @@
[mysqldump]
max_allowed_packet=500M
socket=
host=
port=
database=
[mysql]
max_allowed_packet=500M
socket=
host=
port=
database=
[client]
[clientadmin]

20
plugins/db/includes/includes

@ -0,0 +1,20 @@
#!/bin/bash
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
}
function dbGetConfig {
local env=$(getArgument "$1" "Usage getEnvVar [live|stage|local_live|local_stage] var" "live stage local_live local_stage")
local suffix=$(getArgument "$2" "Usage getEnvVar [live|stage|local_live|local_stage] var" true)
echo "$(eval "echo \"\$db_${env}_$suffix\"")"
}

11
plugins/git/commands/clone

@ -15,8 +15,12 @@ function usage {
source "$project_manager_dir/bin/includes/project_header" source "$project_manager_dir/bin/includes/project_header"
gitValidate gitValidate
echo
echoMainTitle "Cloning Repository"
help="$(getParameter "--help" false "$@")"
if [ "$help" == true ] || [ "$1" == "" ]
then
usage
exit
fi
if [ "$git_url" == "" ] if [ "$git_url" == "" ]
then then
@ -26,6 +30,9 @@ then
exit exit
fi fi
echo
echoMainTitle "Cloning Repository"
echo echo
echoSubTitle "Please confirm following data" echoSubTitle "Please confirm following data"
echo echo

10
plugins/git/etc/.config_template

@ -3,10 +3,10 @@
### GIT ### GIT
# where is your project located in git # where is your project located in git
git_url=""
git_url=''
# optionaly you can let empty and use https with password # optionaly you can let empty and use https with password
git_ssh_user=""
git_ssh_domain=""
git_ssh_private_key=""
git_ssh_public_key=""
git_ssh_user=''
git_ssh_domain=''
git_ssh_private_key=''
git_ssh_public_key=''

32
plugins/shopware/etc/.config_template

@ -2,21 +2,21 @@
### GENERAL ### GENERAL
shopware_version=""
shopware_version=''
shopware6_httpdocs_subpath=""
shopware6_httpdocs_subpath=''
shopware6_local_user=""
shopware6_local_email=""
shopware6_local_firstname=""
shopware6_local_lastname=""
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=""
shopware6_install_name=''
shopware6_install_email=''
shopware6_install_locale=''
shopware6_install_currency=''
shopware6_install_storefront_name=''
shopware6_install_storefront_url=''
### URL MAPPING ### URL MAPPING
@ -78,11 +78,11 @@ shopware6_gdpr_tables=(
### Media Files ### Media Files
shopware6_shared_files=( shopware6_shared_files=(
"/files"
"/public/media"
"/public/thumbnails"
'/files'
'/public/media'
'/public/thumbnails'
) )
### MAILER ### MAILER
shopware6_local_mailer_url=""
shopware6_local_mailer_url=''

16
plugins/ssh/etc/.config_template

@ -2,14 +2,14 @@
### STAGE ### STAGE
ssh_stage_user=""
ssh_stage_domain=""
ssh_stage_private_key=""
ssh_stage_public_key=""
ssh_stage_user=''
ssh_stage_domain=''
ssh_stage_private_key=''
ssh_stage_public_key=''
### LIVE ### LIVE
ssh_live_user=""
ssh_live_domain=""
ssh_live_private_key=""
ssh_live_public_key=""
ssh_live_user=''
ssh_live_domain=''
ssh_live_private_key=''
ssh_live_public_key=''
Loading…
Cancel
Save