Sven Ullmann
2 years ago
14 changed files with 384 additions and 66 deletions
-
44.etc/config.sh
-
1.gitignore
-
40README.md
-
20bin/commands/clone_repo.sh
-
57bin/commands/create_local_env.sh
-
11bin/commands/import_db.sh
-
50bin/commands/import_gdpr_data.sh
-
21bin/commands/import_media.sh
-
97bin/commands/install_shopware.sh
-
2bin/commands/make_local_database.sh
-
33bin/commands/switch_system.sh
-
20bin/includes/includes.sh
-
48bin/manager
-
0shared/.keep
@ -0,0 +1,20 @@ |
|||
#!/bin/bash |
|||
|
|||
### DO NOT EDIT THIS FILE |
|||
|
|||
source "$(dirname "${BASH_SOURCE[0]}")/../includes/includes.sh" |
|||
app_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." &> /dev/null && pwd) |
|||
source "$app_dir/etc/config.sh" |
|||
|
|||
echo |
|||
echoMainTitle "Cloning Repository" |
|||
|
|||
repo_path="$app_dir/git/$project_name" |
|||
|
|||
if [ ! -d "$repo_path" ] && [ "$git_url" != "" ] |
|||
then |
|||
addSSHKey "git" |
|||
git clone "$git_url" "$repo_path" |
|||
fi |
|||
|
|||
postScript "$app_dir/bin/postscript/clone_repo.sh" |
@ -0,0 +1,57 @@ |
|||
#!/bin/bash |
|||
|
|||
### DO NOT EDIT THIS FILE |
|||
|
|||
source "$(dirname "${BASH_SOURCE[0]}")/../includes/includes.sh" |
|||
app_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." &> /dev/null && pwd) |
|||
source "$app_dir/etc/config.sh" |
|||
|
|||
env=$(getArgument "1" "Usage: create_local_env.sh [local_live|local_stage]" "local_live local_stage" | sed -e 's/local_//') |
|||
|
|||
echo |
|||
echoMainTitle "Create local .env file" |
|||
echo |
|||
|
|||
local_database_socket=$(eval "echo \"\$local_${env}_database_socket\"") |
|||
local_database_host=$(eval "echo \"\$local_${env}_database_host\"") |
|||
local_database_port=$(eval "echo \"\$local_${env}_database_port\"") |
|||
local_database_name=$(eval "echo \"\$local_${env}_database_name\"") |
|||
local_database_user=$(eval "echo \"\$local_${env}_database_user\"") |
|||
local_database_password=$(eval "echo \"\$local_${env}_database_password\"") |
|||
if [ "$local_database_socket" != "" ] |
|||
then |
|||
db_connection="mysql://$local_database_host?unix_socket=$local_database_socket&dbname=$local_database_name&user=$local_database_user&password=$local_database_password" |
|||
else |
|||
db_connection="mysql://$local_database_user:$local_database_password@$local_database_host:$local_database_port/$local_database_name" |
|||
fi |
|||
|
|||
app_url=$(eval "echo \"\$${env}_to_local_local_urls[0]\"") |
|||
|
|||
ssh_user=$(eval "echo \"\$${env}_ssh_user\"") |
|||
ssh_domain=$(eval "echo \"\$${env}_ssh_domain\"") |
|||
ssh_httpdocs_path=$(eval "echo \"\$${env}_ssh_httpdocs_path\"") |
|||
ssh_httpdocs_slug=$(eval "echo \"\$${env}_ssh_httpdocs_slug\"") |
|||
|
|||
addSSHKey "$env" |
|||
app_secret=$(ssh "$ssh_user"@"$ssh_domain" "cat \"$ssh_httpdocs_path$ssh_httpdocs_slug/.env\"" | sed -i -r 's/^APP_SECRET=\(.*\)\$/\\1/') |
|||
instance_id=$(ssh "$ssh_user"@"$ssh_domain" "cat \"$ssh_httpdocs_path$ssh_httpdocs_slug/.env\"" | sed -i -r 's/^INSTANCE_ID=\(.*\)\$/\\1/') |
|||
|
|||
host=$(eval "echo \"\$local_${env}_host}\"") |
|||
|
|||
path="$app_dir/git/$project_name" |
|||
|
|||
cat <<- EOF > "$path/.env" |
|||
APP_ENV=dev |
|||
APP_SECRET=$app_secret |
|||
APP_URL=$app_url |
|||
TRUSTED_HOSTS=$host |
|||
MAILER_URL=$local_mailer_url |
|||
INSTANCE_ID=$instance_id |
|||
DATABASE_URL=$db_connection |
|||
COMPOSER_HOME=vendor |
|||
BLUE_GREEN_DEPLOYMENT=1 |
|||
SHOPWARE_HTTP_CACHE_ENABLED=0 |
|||
SHOPWARE_HTTP_DEFAULT_TTL=0 |
|||
EOF |
|||
|
|||
postScript "$app_dir/bin/postscripts/create_local_env.sh" |
@ -0,0 +1,50 @@ |
|||
#!/bin/bash |
|||
|
|||
### DO NOT EDIT THIS FILE |
|||
|
|||
source "$(dirname "${BASH_SOURCE[0]}")/../includes/includes.sh" |
|||
app_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." &> /dev/null && pwd) |
|||
source "$app_dir/etc/config.sh" |
|||
|
|||
env=$(getArgument "1" "Usage: import_gdpr_data.sh [live|stage]" "live stage") |
|||
|
|||
echo |
|||
echoMainTitle "Fetch GDPR Data from $env" |
|||
|
|||
currentDate=$(date '+%Y-%m-%d_%H:%M:%S') |
|||
|
|||
addSSHKey "$env" |
|||
ssh_user="$(eval "echo \$${env}_ssh_user")" |
|||
ssh_domain="$(eval "echo \$${env}_ssh_domain")" |
|||
includedTables=$(buildIncludedTables "${gdprTables[@]}" |
|||
database_name=$(eval "echo \$${env}_database_name") |
|||
local_database_name=$(eval "echo \$local_${env}_database_name") |
|||
|
|||
echo "Fetching Data ..." |
|||
scp "$app_dir/etc/${env}.my.cnf" "$ssh_user"@"$ssh_domain":"~/${env}.my.cnf" |
|||
ssh "$ssh_user"@"$ssh_domain" "mysqldump --defaults-extra-file=~/${env}.my.cnf --no-tablespaces --no-create-info --skip-triggers \ |
|||
"$database_name" "${includedTables[@]}" | LANG=C LC_CTYPE=C LC_ALL=C sed -e 's/DEFINER[ ]*=[ ]*[^*]*\*/\*/' | gzip -9 > \ |
|||
~/${env}_gdpr_data.sql.gz" |
|||
scp "$ssh_user"@"$ssh_domain":"~/${env}_gdpr_data.sql.gz" "$app_dir/var/tmp/${env}_gdpr_data.sql.gz" |
|||
ssh "$ssh_user"@"$ssh_domain" "unlink ~/${env}_gdpr_data.sql.gz" |
|||
ssh "$ssh_user"@"$ssh_domain" "unlink ~/${env}.my.cnf" |
|||
|
|||
echo "Backup Data ..." |
|||
|
|||
cp "$app_dir/var/tmp/${env}_gdpr_data.sql.gz" "$app_dir/backup/database/${env}/${currentDate}_${env}_gdpr_data.sql.gz" |
|||
|
|||
echo "Uncompress Data ..." |
|||
|
|||
gzip -d "$app_dir/var/tmp/${env}_gdpr_data.sql.gz" |
|||
|
|||
echo "Import Data ..." |
|||
|
|||
mysql --defaults-extra-file="$app_dir/etc/local.my.cnf" -D "$local_database_name" < "$app_dir/var/tmp/${env}_gdpr_data.sql" |
|||
|
|||
echo "Post Scripts ..." |
|||
|
|||
postScript "$app_dir/bin/postscripts/import_gdpr_data.sh" ] |
|||
|
|||
echo "Cleanup ..." |
|||
|
|||
rm "$app_dir/var/tmp/${env}_gdpr_data.sql" |
@ -1,26 +1,37 @@ |
|||
#!/bin/bash |
|||
|
|||
### DO NOT EDIT THIS FILE |
|||
|
|||
source "$(dirname "${BASH_SOURCE[0]}")/../includes/includes.sh" |
|||
app_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." &> /dev/null && pwd) |
|||
source "$app_dir/etc/config.sh" |
|||
|
|||
env=$(getArgument "$1" "Usage: import_media.sh [live|stage] /path/to/files" "live stage") |
|||
filepath=$(getArgument "$2" "Usage: import_media.sh [live|stage] /path/to/files" "/files /public/media") |
|||
filepath=$(getArgument "$2" "Usage: import_media.sh [live|stage] /path/to/files" true) |
|||
|
|||
echo |
|||
echoMainTitle "Fetching $filepath files from $env" |
|||
|
|||
addSSHKey "$env" |
|||
ssh_user="$(eval "echo \$${env}_ssh_user")" |
|||
ssh_domain="$(eval "echo \$${env}_ssh_domain")" |
|||
slug="$(eval "echo \"\$local_${env}_slug\"")" |
|||
|
|||
source="$(eval "echo \"\$${env}_httpdocs_path\$${env}_httpdocs_slug\$filepath/.\"")" |
|||
target="$app_dir/git/${project_name}${slug}${filepath}/." |
|||
|
|||
echo |
|||
echoMainTitle "Fetching $filepath files from $env" |
|||
target="$app_dir/shared/$project_name/$env$filepath" |
|||
link="$app_dir/git/${project_name}${slug}${filepath}/." |
|||
|
|||
echo |
|||
echo "Fetch Files ..." |
|||
rsync -auvzqLK --delete "$ssh_user"@"$ssh_domain":"$source" "$target" |
|||
|
|||
if [ -f "$link" ] |
|||
then |
|||
rm -rf "$link" |
|||
fi |
|||
|
|||
ln -s "$target" "$link" |
|||
|
|||
postScript "$app_dir/bin/postscripts/import_media.sh" |
|||
|
|||
echo |
@ -0,0 +1,97 @@ |
|||
#!/bin/bash |
|||
|
|||
### DO NOT EDIT THIS FILE |
|||
|
|||
source "$(dirname "${BASH_SOURCE[0]}")/../includes/includes.sh" |
|||
app_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." &> /dev/null && pwd) |
|||
source "$app_dir/etc/config.sh" |
|||
|
|||
updatemode=0 |
|||
|
|||
echo |
|||
echoMainTitle "Shopware installer/updater" |
|||
|
|||
path="$app_dir/git/$project_name$git_shopware_path" |
|||
|
|||
if [ -f "$path/install.lock" ] |
|||
then |
|||
updatemode=1 |
|||
echo "Update mode" |
|||
else |
|||
echo "Install mode" |
|||
fi |
|||
|
|||
if [ "$updatemode" == "0" ] |
|||
then |
|||
echo |
|||
echoSequenzeTitle "Wich database to use?" |
|||
echo |
|||
echoSelect "[live] " "Local live database" |
|||
echoSelect "[stage]" "Local stage database" |
|||
echo |
|||
env=$(readConsole "Select: " "Invalid selection" "live stage") |
|||
fi |
|||
|
|||
### Fetch sources |
|||
|
|||
echo |
|||
echo "Fetch sources ..." |
|||
|
|||
wget -q --show-progress -O "$app_dir/var/tmp/sdp.html" "https://www.shopware.com/de/download/" |
|||
|
|||
if [ "$updatemode" == "0" ] |
|||
then |
|||
download_url=$(grep -Po '(?<=href=")https://releases.shopware.com/sw6/install_[^"]*' "$app_dir/var/tmp/sdp.html") |
|||
filename="shopware_install.zip" |
|||
else |
|||
download_url=$(grep -Po '(?<=href=")https://releases.shopware.com/sw6/update_[^"]*' "$app_dir/var/tmp/sdp.html") |
|||
filename="shopware_update.zip" |
|||
fi |
|||
|
|||
wget -q --show-progress -O "$app_dir/var/tmp/$filename" "$download_url" |
|||
|
|||
echo "Install files ..." |
|||
|
|||
unzip -oqq "$app_dir/var/tmp/$filename" -d "$path" |
|||
|
|||
local_database_socket=$(eval "echo \"\$local_${env}_database_socket\"") |
|||
local_database_host=$(eval "echo \"\$local_${env}_database_host\"") |
|||
local_database_port=$(eval "echo \"\$local_${env}_database_port\"") |
|||
local_database_name=$(eval "echo \"\$local_${env}_database_name\"") |
|||
local_database_user=$(eval "echo \"\$local_${env}_database_user\"") |
|||
local_database_password=$(eval "echo \"\$local_${env}_database_password\"") |
|||
|
|||
if [ "$local_database_socket" != "" ] |
|||
then |
|||
database_url="mysql:unix_socket=$local_database_socket;dbname=$local_database_name;user=$local_database_user;password=$local_database_password" |
|||
else |
|||
database_url="mysql://$local_database_user:$local_database_password@$local_database_host:$local_database_port/$local_database_name" |
|||
fi |
|||
export DATABASE_URL="$database_url" |
|||
|
|||
cwd=$(pwd) |
|||
cd "$path" |
|||
|
|||
if [ "$updatemode" == "0" ] |
|||
then |
|||
|
|||
echo "Setup Shopware ..." |
|||
cp "$app_dir/etc/.env.local" "$path/.env" |
|||
bin/console system:install --shop-name="$install_shopware_name" --shop-email="$install_shopware_email" \ |
|||
--shop-locale="$install_shopware_locale" --shop-currency="$install_shopware_currency" --no-interaction --env="dev" |
|||
bin/console sales-channel:create:storefront --name="$install_shopware_storefront_name" --url="$install_install_shopware_storefront_url" --no-interaction --quiet |
|||
bin/console user:create -a --firstName="$local_shopware_user" --lastName="$local_shopware_firstname" --email="$local_shopware_email" "$local_shopware_user" |
|||
|
|||
else |
|||
echo "Prepare Shopware setup ..." |
|||
bin/console --quiet --no-interaction --env="dev" system:update:prepare |
|||
|
|||
"$path/public/recovery/update/index.php" |
|||
fi |
|||
|
|||
cd "$cwd" |
|||
|
|||
postScript "$app_dir/bin/postscripts/install_shopware.sh" |
|||
|
|||
rm "$app_dir/var/tmp/sdp.html" |
|||
rm "$app_dir/var/tmp/$filename" |
@ -0,0 +1,33 @@ |
|||
#!/bin/bash |
|||
|
|||
### DO NOT EDIT THIS FILE |
|||
|
|||
source "$(dirname "${BASH_SOURCE[0]}")/../includes/includes.sh" |
|||
app_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." &> /dev/null && pwd) |
|||
source "$app_dir/etc/config.sh" |
|||
|
|||
env=$(getArgument "$1" "Usage: switch_system.sh [live|stage] [true|false: UpdateDatabase]" "live stage") |
|||
update_database_flag=$(getArgument "$2" "Usage: switch_system.sh [live|stage] [true|false: UpdateDatabase]" "true false") |
|||
|
|||
echoMainTitle "Switch to local_$env System" |
|||
|
|||
shopware_check_install="$app_dir/git/$project_name$git_shopware_path/src" |
|||
if [ ! -d "$shopware_check_install" ] |
|||
then |
|||
echo |
|||
echoError "No Shopware installed, try bin/commands/install_shopware.sh" |
|||
exit |
|||
fi |
|||
|
|||
if [ "$update_database_flag" == true ] |
|||
then |
|||
"$app_dir/bin/commands/import_db.sh" "$env" |
|||
"$app_dir/bin/commands/create_local_env.sh" "local_$env" |
|||
"$app_dir/bin/commands/make_local_database.sh" "$env" |
|||
fi |
|||
|
|||
for path in "${import_media_files[@]}" |
|||
do |
|||
"$app_dir/bin/commands/import_media.sh" "$env" "$path" |
|||
done |
|||
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue