You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
140 lines
4.8 KiB
140 lines
4.8 KiB
#!/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
|