-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #60 from shopware/allow-hooks
feat: allow hooks in the docker image
- Loading branch information
Showing
7 changed files
with
136 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
external-sources=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/usr/bin/env sh | ||
|
||
set -e | ||
|
||
wait_for_mysql() { | ||
database_host=$(trurl "$DATABASE_URL" --get '{host}') | ||
database_port=$(trurl "$DATABASE_URL" --get '{port}') | ||
MYSQL_WAIT_SECONDS=${MYSQL_WAIT_SECONDS:-20} | ||
|
||
try=0 | ||
if [ "$MYSQL_WAIT_SECONDS" != 0 ]; then | ||
until nc -z -v -w30 "$database_host" "${database_port:-3306}"; do | ||
echo "Waiting for database connection..." | ||
# wait for 5 seconds before check again | ||
sleep 1 | ||
|
||
try=$((try + 1)) | ||
|
||
if [ $try = "$MYSQL_WAIT_SECONDS" ]; then | ||
echo "Error: We have been waiting for database connection too long already; failing." | ||
exit 1 | ||
fi | ||
done | ||
fi | ||
} | ||
|
||
console() { | ||
php -derror_reporting=E_ALL bin/console "$@" | ||
} | ||
|
||
install_all_plugins() { | ||
list_with_updates=$(php bin/console plugin:list --json | jq 'map(select(.installedAt == null)) | .[].name' -r) | ||
|
||
for plugin in $list_with_updates; do | ||
console plugin:install --activate "$plugin" | ||
done | ||
} | ||
|
||
update_all_plugins() { | ||
list_with_updates=$(php bin/console plugin:list --json | jq 'map(select(.upgradeVersion != null)) | .[].name' -r) | ||
|
||
for plugin in $list_with_updates; do | ||
php -derror_reporting=E_ALL bin/console plugin:update "$plugin" | ||
done | ||
} | ||
|
||
run_hooks() { | ||
hook=$1 | ||
if [ -d "/usr/local/shopware/$hook.d" ]; then | ||
for file in "/usr/local/shopware/$hook.d"/*.sh; do | ||
echo "Running $file for $hook" | ||
# shellcheck source=/dev/null | ||
. "$file" | ||
done | ||
fi | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env sh | ||
|
||
set -e | ||
set -x | ||
|
||
. /usr/local/shopware/functions.sh | ||
|
||
if php bin/console system:config:get shopware.installed; then | ||
run_hooks pre_update | ||
|
||
console system:update:finish | ||
console plugin:refresh | ||
|
||
update_all_plugins | ||
install_all_plugins | ||
|
||
run_hooks post_update | ||
else | ||
run_hooks pre_install | ||
|
||
# Shopware is not installed | ||
console system:install --create-database "--shop-locale=$INSTALL_LOCALE" "--shop-currency=$INSTALL_CURRENCY" --force | ||
console user:create "$INSTALL_ADMIN_USERNAME" --admin --password="$INSTALL_ADMIN_PASSWORD" -n | ||
console sales-channel:create:storefront --name=Storefront --url="$APP_URL" | ||
console theme:change --all Storefront | ||
console system:config:set core.frw.completedAt '2019-10-07T10:46:23+00:00' | ||
console system:config:set core.usageData.shareUsageData false --json | ||
console plugin:refresh | ||
|
||
install_all_plugins | ||
|
||
run_hooks post_install | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/env sh | ||
|
||
set -e | ||
set -x | ||
|
||
# shellcheck source=./functions.sh | ||
. /usr/local/shopware/functions.sh | ||
|
||
wait_for_mysql | ||
|
||
if console system:is-installed; then | ||
run_hooks pre_update | ||
|
||
if [ "${SHOPWARE_SKIP_ASSET_COPY-""}" ]; then | ||
console system:update:finish --skip-asset-build | ||
else | ||
console system:update:finish | ||
fi | ||
|
||
if [ "${SHOPWARE_SKIP_ASSET_COPY-""}" ]; then | ||
console plugin:update:all | ||
else | ||
console plugin:update:all --skip-asset-build | ||
fi | ||
|
||
install_all_plugins | ||
|
||
run_hooks post_update | ||
else | ||
run_hooks pre_install | ||
|
||
console system:install --create-database "--shop-locale=$INSTALL_LOCALE" "--shop-currency=$INSTALL_CURRENCY" --force | ||
console user:create "$INSTALL_ADMIN_USERNAME" --admin --password="$INSTALL_ADMIN_PASSWORD" -n | ||
console sales-channel:create:storefront --name=Storefront --url="$APP_URL" | ||
console theme:change --all Storefront | ||
console system:config:set core.frw.completedAt '2019-10-07T10:46:23+00:00' | ||
console plugin:refresh | ||
|
||
install_all_plugins | ||
|
||
run_hooks post_install | ||
fi |