Skip to content

Commit

Permalink
Force schema update and enable plugin
Browse files Browse the repository at this point in the history
Add functionality to allow an environment variable to indicate that the
COmanage database schema should be updated (./Console/cake database).
This is helpful when deploying a new version of the code that does not
result in a change in the version number and so upgradeVersion does not
fire. An example of this scenario is when new code is introduced in the
develop branch but before a release happens.

Also add functionality to allow an environment variable to indicate that
a non-core plugin should be enabled.
  • Loading branch information
skoranda committed Nov 8, 2017
1 parent 19486f7 commit 2c718cc
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 0 deletions.
31 changes: 31 additions & 0 deletions comanage-registry-basic-auth/docker-comanage-entrypoint
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ rm -f "$SETUP_ALREADY_SCRIPT"
if [ $setup_already -eq 0 ]; then
rm -f "$COMANAGE_REGISTRY_DIR/local/Config/security.salt" > "$OUTPUT" 2>&1
rm -f "$COMANAGE_REGISTRY_DIR/local/Config/security.seed" > "$OUTPUT" 2>&1
# Run database twice until issue on develop branch is resolved. Since
# the command is idempotent normally it is not a problem to have it run
# more than once.
./Console/cake database > "$OUTPUT" 2>&1 && \
./Console/cake database > "$OUTPUT" 2>&1 && \
./Console/cake setup --admin-given-name "${COMANAGE_REGISTRY_ADMIN_GIVEN_NAME}" \
--admin-family-name "${COMANAGE_REGISTRY_ADMIN_FAMILY_NAME}" \
Expand Down Expand Up @@ -217,6 +221,33 @@ pushd "$COMANAGE_REGISTRY_DIR/app" > "$OUTPUT" 2>&1

popd > "$OUTPUT" 2>&1

# Force a datbase update if requested. This is helpful when deploying
# a new version of the code that does not result in a change in the
# version number and so upgradeVersion does not fire. An example
# of this scenario is when new code is introduced in the develop
# branch but before a release happens.
if [ -n "$COMANAGE_REGISTRY_DATABASE_SCHEMA_FORCE" ]; then
echo "Forcing a database schema update..." > "$OUTPUT" 2>&1
pushd "$COMANAGE_REGISTRY_DIR/app" > "$OUTPUT" 2>&1
./Console/cake database > "$OUTPUT" 2>&1
popd > "$OUTPUT" 2>&1
fi

# Enable any supported non-core plugins if requested.
if [ -n "$COMANAGE_REGISTRY_ENABLE_PLUGIN" ]; then
plugins=(`echo "$COMANAGE_REGISTRY_ENABLE_PLUGIN" | sed -e 's@,@ @'`) > "$OUTPUT" 2>&1
for plugin in "${plugins[@]}";
do
echo "Enabling available plugin $plugin..." > "$OUTPUT" 2>&1
pushd "$COMANAGE_REGISTRY_DIR/local/Plugin" > "$OUTPUT" 2>&1
ln -s "../../app/AvailablePlugin/$plugin" "$plugin" > "$OUTPUT" 2>&1
popd > "$OUTPUT" 2>&1
pushd "$COMANAGE_REGISTRY_DIR/app" > "$OUTPUT" 2>&1
./Console/cake database > "$OUTPUT" 2>&1
popd > "$OUTPUT" 2>&1
done
fi

# Running CakePHP console commands generates cache files so
# set the ownership of those files appropriately.
chown -R www-data:www-data "$COMANAGE_REGISTRY_DIR/app/tmp"
Expand Down
31 changes: 31 additions & 0 deletions comanage-registry-mod-auth-openidc/docker-comanage-entrypoint
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ rm -f "$SETUP_ALREADY_SCRIPT"
if [ $setup_already -eq 0 ]; then
rm -f "$COMANAGE_REGISTRY_DIR/local/Config/security.salt" > "$OUTPUT" 2>&1
rm -f "$COMANAGE_REGISTRY_DIR/local/Config/security.seed" > "$OUTPUT" 2>&1
# Run database twice until issue on develop branch is resolved. Since
# the command is idempotent normally it is not a problem to have it run
# more than once.
./Console/cake database > "$OUTPUT" 2>&1 && \
./Console/cake database > "$OUTPUT" 2>&1 && \
./Console/cake setup --admin-given-name "${COMANAGE_REGISTRY_ADMIN_GIVEN_NAME}" \
--admin-family-name "${COMANAGE_REGISTRY_ADMIN_FAMILY_NAME}" \
Expand Down Expand Up @@ -217,6 +221,33 @@ pushd "$COMANAGE_REGISTRY_DIR/app" > "$OUTPUT" 2>&1

popd > "$OUTPUT" 2>&1

# Force a datbase update if requested. This is helpful when deploying
# a new version of the code that does not result in a change in the
# version number and so upgradeVersion does not fire. An example
# of this scenario is when new code is introduced in the develop
# branch but before a release happens.
if [ -n "$COMANAGE_REGISTRY_DATABASE_SCHEMA_FORCE" ]; then
echo "Forcing a database schema update..." > "$OUTPUT" 2>&1
pushd "$COMANAGE_REGISTRY_DIR/app" > "$OUTPUT" 2>&1
./Console/cake database > "$OUTPUT" 2>&1
popd > "$OUTPUT" 2>&1
fi

# Enable any supported non-core plugins if requested.
if [ -n "$COMANAGE_REGISTRY_ENABLE_PLUGIN" ]; then
plugins=(`echo "$COMANAGE_REGISTRY_ENABLE_PLUGIN" | sed -e 's@,@ @'`) > "$OUTPUT" 2>&1
for plugin in "${plugins[@]}";
do
echo "Enabling available plugin $plugin..." > "$OUTPUT" 2>&1
pushd "$COMANAGE_REGISTRY_DIR/local/Plugin" > "$OUTPUT" 2>&1
ln -s "../../app/AvailablePlugin/$plugin" "$plugin" > "$OUTPUT" 2>&1
popd > "$OUTPUT" 2>&1
pushd "$COMANAGE_REGISTRY_DIR/app" > "$OUTPUT" 2>&1
./Console/cake database > "$OUTPUT" 2>&1
popd > "$OUTPUT" 2>&1
done
fi

# Running CakePHP console commands generates cache files so
# set the ownership of those files appropriately.
chown -R www-data:www-data "$COMANAGE_REGISTRY_DIR/app/tmp"
Expand Down
31 changes: 31 additions & 0 deletions comanage-registry-shibboleth-sp/docker-comanage-entrypoint
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ rm -f "$SETUP_ALREADY_SCRIPT"
if [ $setup_already -eq 0 ]; then
rm -f "$COMANAGE_REGISTRY_DIR/local/Config/security.salt" > "$OUTPUT" 2>&1
rm -f "$COMANAGE_REGISTRY_DIR/local/Config/security.seed" > "$OUTPUT" 2>&1
# Run database twice until issue on develop branch is resolved. Since
# the command is idempotent normally it is not a problem to have it run
# more than once.
./Console/cake database > "$OUTPUT" 2>&1 && \
./Console/cake database > "$OUTPUT" 2>&1 && \
./Console/cake setup --admin-given-name "${COMANAGE_REGISTRY_ADMIN_GIVEN_NAME}" \
--admin-family-name "${COMANAGE_REGISTRY_ADMIN_FAMILY_NAME}" \
Expand Down Expand Up @@ -217,6 +221,33 @@ pushd "$COMANAGE_REGISTRY_DIR/app" > "$OUTPUT" 2>&1

popd > "$OUTPUT" 2>&1

# Force a datbase update if requested. This is helpful when deploying
# a new version of the code that does not result in a change in the
# version number and so upgradeVersion does not fire. An example
# of this scenario is when new code is introduced in the develop
# branch but before a release happens.
if [ -n "$COMANAGE_REGISTRY_DATABASE_SCHEMA_FORCE" ]; then
echo "Forcing a database schema update..." > "$OUTPUT" 2>&1
pushd "$COMANAGE_REGISTRY_DIR/app" > "$OUTPUT" 2>&1
./Console/cake database > "$OUTPUT" 2>&1
popd > "$OUTPUT" 2>&1
fi

# Enable any supported non-core plugins if requested.
if [ -n "$COMANAGE_REGISTRY_ENABLE_PLUGIN" ]; then
plugins=(`echo "$COMANAGE_REGISTRY_ENABLE_PLUGIN" | sed -e 's@,@ @'`) > "$OUTPUT" 2>&1
for plugin in "${plugins[@]}";
do
echo "Enabling available plugin $plugin..." > "$OUTPUT" 2>&1
pushd "$COMANAGE_REGISTRY_DIR/local/Plugin" > "$OUTPUT" 2>&1
ln -s "../../app/AvailablePlugin/$plugin" "$plugin" > "$OUTPUT" 2>&1
popd > "$OUTPUT" 2>&1
pushd "$COMANAGE_REGISTRY_DIR/app" > "$OUTPUT" 2>&1
./Console/cake database > "$OUTPUT" 2>&1
popd > "$OUTPUT" 2>&1
done
fi

# Running CakePHP console commands generates cache files so
# set the ownership of those files appropriately.
chown -R www-data:www-data "$COMANAGE_REGISTRY_DIR/app/tmp"
Expand Down
31 changes: 31 additions & 0 deletions comanage-registry/docker-comanage-entrypoint
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ rm -f "$SETUP_ALREADY_SCRIPT"
if [ $setup_already -eq 0 ]; then
rm -f "$COMANAGE_REGISTRY_DIR/local/Config/security.salt" > "$OUTPUT" 2>&1
rm -f "$COMANAGE_REGISTRY_DIR/local/Config/security.seed" > "$OUTPUT" 2>&1
# Run database twice until issue on develop branch is resolved. Since
# the command is idempotent normally it is not a problem to have it run
# more than once.
./Console/cake database > "$OUTPUT" 2>&1 && \
./Console/cake database > "$OUTPUT" 2>&1 && \
./Console/cake setup --admin-given-name "${COMANAGE_REGISTRY_ADMIN_GIVEN_NAME}" \
--admin-family-name "${COMANAGE_REGISTRY_ADMIN_FAMILY_NAME}" \
Expand Down Expand Up @@ -217,6 +221,33 @@ pushd "$COMANAGE_REGISTRY_DIR/app" > "$OUTPUT" 2>&1

popd > "$OUTPUT" 2>&1

# Force a datbase update if requested. This is helpful when deploying
# a new version of the code that does not result in a change in the
# version number and so upgradeVersion does not fire. An example
# of this scenario is when new code is introduced in the develop
# branch but before a release happens.
if [ -n "$COMANAGE_REGISTRY_DATABASE_SCHEMA_FORCE" ]; then
echo "Forcing a database schema update..." > "$OUTPUT" 2>&1
pushd "$COMANAGE_REGISTRY_DIR/app" > "$OUTPUT" 2>&1
./Console/cake database > "$OUTPUT" 2>&1
popd > "$OUTPUT" 2>&1
fi

# Enable any supported non-core plugins if requested.
if [ -n "$COMANAGE_REGISTRY_ENABLE_PLUGIN" ]; then
plugins=(`echo "$COMANAGE_REGISTRY_ENABLE_PLUGIN" | sed -e 's@,@ @'`) > "$OUTPUT" 2>&1
for plugin in "${plugins[@]}";
do
echo "Enabling available plugin $plugin..." > "$OUTPUT" 2>&1
pushd "$COMANAGE_REGISTRY_DIR/local/Plugin" > "$OUTPUT" 2>&1
ln -s "../../app/AvailablePlugin/$plugin" "$plugin" > "$OUTPUT" 2>&1
popd > "$OUTPUT" 2>&1
pushd "$COMANAGE_REGISTRY_DIR/app" > "$OUTPUT" 2>&1
./Console/cake database > "$OUTPUT" 2>&1
popd > "$OUTPUT" 2>&1
done
fi

# Running CakePHP console commands generates cache files so
# set the ownership of those files appropriately.
chown -R www-data:www-data "$COMANAGE_REGISTRY_DIR/app/tmp"
Expand Down

0 comments on commit 2c718cc

Please sign in to comment.