diff --git a/bin/commands/create-project b/bin/commands/create-project index 79c78d2..0856052 100644 --- a/bin/commands/create-project +++ b/bin/commands/create-project @@ -22,7 +22,7 @@ function usage { echo } -help="$(getParameter "--help" false "$@")" +help="$(getParameter "--help" false "$*")" if [ "$help" == true ] || [ "$1" == "" ] then usage @@ -102,9 +102,9 @@ if [ ! -f "$path/etc/config" ] then quoted="$(sedEscape "$project_manager_dir")" 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" fi @@ -129,28 +129,28 @@ projects_string=''; for i in "${!projects[@]}" do ((nr=i+1)) - projects_string+="$(echo -e "\n\t\"${projects[$i]}\" # $nr")" + projects_string+="$(echo -e "\n\t'${projects[$i]}' # $nr")" done ((nr=nr+1)) -projects_string+="$(echo -e "\n\t\"$project\" # $nr")" +projects_string+="$(echo -e "\n\t'$project' # $nr")" shortnames_string=''; for i in "${!shortnames[@]}" do ((nr=i+1)) - shortnames_string+="$(echo -e "\n\t\"${shortnames[$i]}\" # $nr")" + shortnames_string+="$(echo -e "\n\t'${shortnames[$i]}' # $nr")" done ((nr=nr+1)) -shortnames_string+="$(echo -e "\n\t\"$shortname\" # $nr")" +shortnames_string+="$(echo -e "\n\t'$shortname' # $nr")" customers_string=''; for i in "${!customers[@]}" do ((nr=i+1)) - customers_string+="$(echo -e "\n\t\"${customers[$i]}\" # $nr")" + customers_string+="$(echo -e "\n\t'${customers[$i]}' # $nr")" done ((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" #!/bin/bash diff --git a/bin/commands/install-project-manager b/bin/commands/install-project-manager index 5b613a4..8da7b39 100644 --- a/bin/commands/install-project-manager +++ b/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" ] then 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" fi diff --git a/bin/commands/list-projects b/bin/commands/list-projects index 90d07b1..d53a014 100644 --- a/bin/commands/list-projects +++ b/bin/commands/list-projects @@ -36,15 +36,15 @@ if [ "$help" == true ] then usage exit +fi + +if [ "${#projects[@]}" -eq 0 ] +then + echo + echo "There are currently no projects setted up" + echo else - if [ "${#projects[@]}" -eq 0 ] - then - echo - echo "There are currently no projects setted up" - echo - else - listProjects - fi + listProjects fi echoSuccess "Listing done" \ No newline at end of file diff --git a/bin/commands/remove-project b/bin/commands/remove-project index 5c98b48..ff48033 100644 --- a/bin/commands/remove-project +++ b/bin/commands/remove-project @@ -17,7 +17,7 @@ function usage { echo } -help="$(getParameter "--help" false "$@")" +help="$(getParameter "--help" false "$*")" if [ "$help" == true ] || [ "$1" == "" ] then usage @@ -85,7 +85,7 @@ do if [ "$i" != "$index" ] then ((nr=nr+1)) - projects_string+="$(echo -e "\n\t\"${projects[$i]}\" # $nr")" + projects_string+="$(echo -e "\n\t'${projects[$i]}' # $nr")" fi done @@ -96,7 +96,7 @@ do if [ "$i" != "$index" ] then ((nr=nr+1)) - shortnames_string+="$(echo -e "\n\t\"${shortnames[$i]}\" # $nr")" + shortnames_string+="$(echo -e "\n\t'${shortnames[$i]}' # $nr")" fi done @@ -107,7 +107,7 @@ do if [ "$i" != "$index" ] then ((nr=nr+1)) - customers_string+="$(echo -e "\n\t\"${customers[$i]}\" # $nr")" + customers_string+="$(echo -e "\n\t'${customers[$i]}' # $nr")" fi done diff --git a/bin/includes/includes b/bin/includes/includes index 9314bfd..20c5768 100644 --- a/bin/includes/includes +++ b/bin/includes/includes @@ -201,7 +201,6 @@ then fi } - plugin_dir="$project_manager_dir/plugins" plugins="$(ls -t "$plugin_dir")" for plugin in ${plugins[*]} diff --git a/bin/project-manager b/bin/project-manager index 510013c..130b306 100755 --- a/bin/project-manager +++ b/bin/project-manager @@ -137,7 +137,7 @@ else echo exit else - source "$file" "${@:2}" + source "$file" "${*:2}" fi echo diff --git a/etc/.config_template b/etc/.config_template index 1544b28..e60e274 100644 --- a/etc/.config_template +++ b/etc/.config_template @@ -2,40 +2,40 @@ ### GENERAL -app_customer="" -app_project="" -app_project_manager_dir="" +app_customer='' +app_project='' +app_project_manager_dir='' ### STAGE # The httpdocs folder on your server -stage_httpdocs_path="" +stage_httpdocs_path='' # subpath from httpdocs to your installation of the project -stage_httpdocs_git_subpath="" +stage_httpdocs_git_subpath='' ### LIVE # The httpdocs folder on your server -live_httpdocs_path="" +live_httpdocs_path='' # subpath from httpdocs to your installation of the project -live_httpdocs_git_subpath="" +live_httpdocs_git_subpath='' ### LOCAL STAGE # url to your project on the local machine -local_stage_host="" +local_stage_host='' ### LOCAL LIVE # url to your project on the local machine -local_live_host="" +local_live_host='' ### 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 - source "$app_dir/etc/post_config.sh" + source '$app_dir/etc/post_config.sh' fi diff --git a/etc/.project_manager_config_template b/etc/.project_manager_config_template index 6a1c6ec..da6c71b 100644 --- a/etc/.project_manager_config_template +++ b/etc/.project_manager_config_template @@ -1,5 +1,5 @@ #!/bin/bash -workspaces_dir="" -project_manager_dir="" +workspaces_dir='' +project_manager_dir='' diff --git a/plugins/db/commands/create-config b/plugins/db/commands/create-config new file mode 100644 index 0000000..92e3979 --- /dev/null +++ b/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 \ No newline at end of file diff --git a/plugins/db/etc/.config_template b/plugins/db/etc/.config_template index 9bd8f93..2e49965 100644 --- a/plugins/db/etc/.config_template +++ b/plugins/db/etc/.config_template @@ -2,56 +2,56 @@ ### 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 -db_stage_admin_user="" -db_stage_admin_password="" +db_stage_admin_user='' +db_stage_admin_password='' ### 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 -db_live_admin_user="" -db_live_admin_password="" +db_live_admin_user='' +db_live_admin_password='' ### LOCAL_STAGE # you can drive you local installation with a copy of stage or live -db_local_stage_socket="" -db_local_stage_host="" -db_local_stage_port="" -db_local_stage_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 -db_local_stage_admin_user="" -db_local_stage_admin_password="" +db_local_stage_admin_user='' +db_local_stage_admin_password='' ### LOCAL_LIVE # you can drive you local installation with a copy of stage or live -db_local_live_socket="" -db_local_live_host="" -db_local_live_port="" -db_local_live_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 -db_local_live_admin_user="" -db_local_live_admin_password="" \ No newline at end of file +db_local_live_admin_user='' +db_local_live_admin_password='' \ No newline at end of file diff --git a/plugins/db/etc/.my.cnf_template b/plugins/db/etc/.my.cnf_template new file mode 100644 index 0000000..3a2dacc --- /dev/null +++ b/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] \ No newline at end of file diff --git a/plugins/db/includes/includes b/plugins/db/includes/includes new file mode 100644 index 0000000..2443487 --- /dev/null +++ b/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\"")" +} \ No newline at end of file diff --git a/plugins/git/commands/clone b/plugins/git/commands/clone index 4858d02..7e1cb0d 100644 --- a/plugins/git/commands/clone +++ b/plugins/git/commands/clone @@ -15,8 +15,12 @@ function usage { source "$project_manager_dir/bin/includes/project_header" gitValidate -echo -echoMainTitle "Cloning Repository" +help="$(getParameter "--help" false "$@")" +if [ "$help" == true ] || [ "$1" == "" ] +then + usage + exit +fi if [ "$git_url" == "" ] then @@ -26,6 +30,9 @@ then exit fi +echo +echoMainTitle "Cloning Repository" + echo echoSubTitle "Please confirm following data" echo diff --git a/plugins/git/etc/.config_template b/plugins/git/etc/.config_template index c7a4f72..64c8f01 100644 --- a/plugins/git/etc/.config_template +++ b/plugins/git/etc/.config_template @@ -3,10 +3,10 @@ ### GIT # where is your project located in git -git_url="" +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="" \ No newline at end of file +git_ssh_user='' +git_ssh_domain='' +git_ssh_private_key='' +git_ssh_public_key='' \ No newline at end of file diff --git a/plugins/shopware/etc/.config_template b/plugins/shopware/etc/.config_template index ffb3566..5d476e0 100644 --- a/plugins/shopware/etc/.config_template +++ b/plugins/shopware/etc/.config_template @@ -2,21 +2,21 @@ ### 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 @@ -78,11 +78,11 @@ shopware6_gdpr_tables=( ### Media Files shopware6_shared_files=( - "/files" - "/public/media" - "/public/thumbnails" + '/files' + '/public/media' + '/public/thumbnails' ) ### MAILER -shopware6_local_mailer_url="" \ No newline at end of file +shopware6_local_mailer_url='' \ No newline at end of file diff --git a/plugins/ssh/etc/.config_template b/plugins/ssh/etc/.config_template index 18d1197..7877cd0 100644 --- a/plugins/ssh/etc/.config_template +++ b/plugins/ssh/etc/.config_template @@ -2,14 +2,14 @@ ### 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 -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=''