Skip to content

Commit

Permalink
Merge pull request #77 from FriendsOfREDAXO/schuer-fix-auto-install
Browse files Browse the repository at this point in the history
Fix REDAXO auto-install routine
  • Loading branch information
schuer authored Dec 29, 2023
2 parents f1e217d + 818168e commit 666b429
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 138 deletions.
87 changes: 41 additions & 46 deletions images/5-edge/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,54 +19,49 @@ else
cp -fp redaxo/src/core/default.config.yml redaxo/data/core/config.yml && \
echo >&2 "✅ Default configuration has been successfully copied."

# install REDAXO via cli command if available (REDAXO 5.9+)
if php redaxo/bin/console setup:run; then

# prepare database
# remember the docker database container takes some time to init!
echo >&2 "👉 Prepare database..."
repeat=10
while ! php redaxo/bin/console -q db:set-connection \
--host=$REDAXO_DB_HOST \
--database=$REDAXO_DB_NAME \
--login=$REDAXO_DB_LOGIN \
--password=$REDAXO_DB_PASSWORD 2> /dev/null || false; do
if [[ repeat -eq 0 ]]; then
echo >&2 "❌ Failed to connect database."
exit 1
fi
repeat=$((repeat - 1))
sleep 5
echo >&2 "⏳ Wait for database connection... ($repeat)"
done
echo >&2 "✅ Database has been has been successfully connected."

# run REDAXO setup
# hint: get options via `php redaxo/bin/console setup:run --help`
echo >&2 "👉 Run setup..."
setupArgs=(
"--agree-license"
"--db-createdb=no"
"--db-setup=normal"
);
[[ -n "$REDAXO_LANG" ]] && setupArgs+=("--lang=${REDAXO_LANG}");
[[ -n "$REDAXO_SERVER" ]] && setupArgs+=("--server=${REDAXO_SERVER}");
[[ -n "$REDAXO_SERVERNAME" ]] && setupArgs+=("--servername=${REDAXO_SERVERNAME}");
[[ -n "$REDAXO_ERROR_EMAIL" ]] && setupArgs+=("--error-email=${REDAXO_ERROR_EMAIL}");
[[ -n "$REDAXO_TIMEZONE" ]] && setupArgs+=("--timezone=${REDAXO_TIMEZONE}");
[[ -n "$REDAXO_DB_CHARSET" ]] && setupArgs+=("--db-charset=${REDAXO_DB_CHARSET}");
[[ -n "$REDAXO_DB_PASSWORD" ]] && setupArgs+=("--db-password=${REDAXO_DB_PASSWORD}"); # required again!
[[ -n "$REDAXO_ADMIN_USER" ]] && setupArgs+=("--admin-username=${REDAXO_ADMIN_USER}");
[[ -n "$REDAXO_ADMIN_PASSWORD" ]] && setupArgs+=("--admin-password=${REDAXO_ADMIN_PASSWORD}");

if php redaxo/bin/console setup:run -q -n "${setupArgs[@]}"; then
echo >&2 "✅ REDAXO has been successfully installed."
else
echo >&2 " "
echo >&2 "❌ REDAXO setup failed."
echo >&2 " "
# prepare database
# remember the docker database container takes some time to init!
echo >&2 "👉 Prepare database..."
repeat=10
while ! php redaxo/bin/console -q db:set-connection \
--host=$REDAXO_DB_HOST \
--database=$REDAXO_DB_NAME \
--login=$REDAXO_DB_LOGIN \
--password=$REDAXO_DB_PASSWORD 2> /dev/null || false; do
if [[ repeat -eq 0 ]]; then
echo >&2 "❌ Failed to connect database."
exit 1
fi
repeat=$((repeat - 1))
sleep 5
echo >&2 "⏳ Wait for database connection... ($repeat)"
done
echo >&2 "✅ Database has been has been successfully connected."

# run REDAXO setup
# hint: get options via `php redaxo/bin/console setup:run --help`
echo >&2 "👉 Run setup..."
setupArgs=(
"--db-createdb=no"
"--db-setup=normal"
);
[[ -n "$REDAXO_LANG" ]] && setupArgs+=("--lang=${REDAXO_LANG}");
[[ -n "$REDAXO_SERVER" ]] && setupArgs+=("--server=${REDAXO_SERVER}");
[[ -n "$REDAXO_SERVERNAME" ]] && setupArgs+=("--servername=${REDAXO_SERVERNAME}");
[[ -n "$REDAXO_ERROR_EMAIL" ]] && setupArgs+=("--error-email=${REDAXO_ERROR_EMAIL}");
[[ -n "$REDAXO_TIMEZONE" ]] && setupArgs+=("--timezone=${REDAXO_TIMEZONE}");
[[ -n "$REDAXO_DB_CHARSET" ]] && setupArgs+=("--db-charset=${REDAXO_DB_CHARSET}");
[[ -n "$REDAXO_DB_PASSWORD" ]] && setupArgs+=("--db-password=${REDAXO_DB_PASSWORD}");
[[ -n "$REDAXO_ADMIN_USER" ]] && setupArgs+=("--admin-username=${REDAXO_ADMIN_USER}");
[[ -n "$REDAXO_ADMIN_PASSWORD" ]] && setupArgs+=("--admin-password=${REDAXO_ADMIN_PASSWORD}");

if php redaxo/bin/console setup:run -q -n "${setupArgs[@]}"; then
echo >&2 "✅ REDAXO has been successfully installed."
else
echo >&2 " "
echo >&2 "❌ REDAXO setup failed."
echo >&2 " "
exit 1
fi

# update file owner and group of writable folders (cache, data)
Expand Down
87 changes: 41 additions & 46 deletions images/5-stable/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,54 +19,49 @@ else
cp -fp redaxo/src/core/default.config.yml redaxo/data/core/config.yml && \
echo >&2 "✅ Default configuration has been successfully copied."

# install REDAXO via cli command if available (REDAXO 5.9+)
if php redaxo/bin/console setup:run; then

# prepare database
# remember the docker database container takes some time to init!
echo >&2 "👉 Prepare database..."
repeat=10
while ! php redaxo/bin/console -q db:set-connection \
--host=$REDAXO_DB_HOST \
--database=$REDAXO_DB_NAME \
--login=$REDAXO_DB_LOGIN \
--password=$REDAXO_DB_PASSWORD 2> /dev/null || false; do
if [[ repeat -eq 0 ]]; then
echo >&2 "❌ Failed to connect database."
exit 1
fi
repeat=$((repeat - 1))
sleep 5
echo >&2 "⏳ Wait for database connection... ($repeat)"
done
echo >&2 "✅ Database has been has been successfully connected."

# run REDAXO setup
# hint: get options via `php redaxo/bin/console setup:run --help`
echo >&2 "👉 Run setup..."
setupArgs=(
"--agree-license"
"--db-createdb=no"
"--db-setup=normal"
);
[[ -n "$REDAXO_LANG" ]] && setupArgs+=("--lang=${REDAXO_LANG}");
[[ -n "$REDAXO_SERVER" ]] && setupArgs+=("--server=${REDAXO_SERVER}");
[[ -n "$REDAXO_SERVERNAME" ]] && setupArgs+=("--servername=${REDAXO_SERVERNAME}");
[[ -n "$REDAXO_ERROR_EMAIL" ]] && setupArgs+=("--error-email=${REDAXO_ERROR_EMAIL}");
[[ -n "$REDAXO_TIMEZONE" ]] && setupArgs+=("--timezone=${REDAXO_TIMEZONE}");
[[ -n "$REDAXO_DB_CHARSET" ]] && setupArgs+=("--db-charset=${REDAXO_DB_CHARSET}");
[[ -n "$REDAXO_DB_PASSWORD" ]] && setupArgs+=("--db-password=${REDAXO_DB_PASSWORD}"); # required again!
[[ -n "$REDAXO_ADMIN_USER" ]] && setupArgs+=("--admin-username=${REDAXO_ADMIN_USER}");
[[ -n "$REDAXO_ADMIN_PASSWORD" ]] && setupArgs+=("--admin-password=${REDAXO_ADMIN_PASSWORD}");

if php redaxo/bin/console setup:run -q -n "${setupArgs[@]}"; then
echo >&2 "✅ REDAXO has been successfully installed."
else
echo >&2 " "
echo >&2 "❌ REDAXO setup failed."
echo >&2 " "
# prepare database
# remember the docker database container takes some time to init!
echo >&2 "👉 Prepare database..."
repeat=10
while ! php redaxo/bin/console -q db:set-connection \
--host=$REDAXO_DB_HOST \
--database=$REDAXO_DB_NAME \
--login=$REDAXO_DB_LOGIN \
--password=$REDAXO_DB_PASSWORD 2> /dev/null || false; do
if [[ repeat -eq 0 ]]; then
echo >&2 "❌ Failed to connect database."
exit 1
fi
repeat=$((repeat - 1))
sleep 5
echo >&2 "⏳ Wait for database connection... ($repeat)"
done
echo >&2 "✅ Database has been has been successfully connected."

# run REDAXO setup
# hint: get options via `php redaxo/bin/console setup:run --help`
echo >&2 "👉 Run setup..."
setupArgs=(
"--db-createdb=no"
"--db-setup=normal"
);
[[ -n "$REDAXO_LANG" ]] && setupArgs+=("--lang=${REDAXO_LANG}");
[[ -n "$REDAXO_SERVER" ]] && setupArgs+=("--server=${REDAXO_SERVER}");
[[ -n "$REDAXO_SERVERNAME" ]] && setupArgs+=("--servername=${REDAXO_SERVERNAME}");
[[ -n "$REDAXO_ERROR_EMAIL" ]] && setupArgs+=("--error-email=${REDAXO_ERROR_EMAIL}");
[[ -n "$REDAXO_TIMEZONE" ]] && setupArgs+=("--timezone=${REDAXO_TIMEZONE}");
[[ -n "$REDAXO_DB_CHARSET" ]] && setupArgs+=("--db-charset=${REDAXO_DB_CHARSET}");
[[ -n "$REDAXO_DB_PASSWORD" ]] && setupArgs+=("--db-password=${REDAXO_DB_PASSWORD}");
[[ -n "$REDAXO_ADMIN_USER" ]] && setupArgs+=("--admin-username=${REDAXO_ADMIN_USER}");
[[ -n "$REDAXO_ADMIN_PASSWORD" ]] && setupArgs+=("--admin-password=${REDAXO_ADMIN_PASSWORD}");

if php redaxo/bin/console setup:run -q -n "${setupArgs[@]}"; then
echo >&2 "✅ REDAXO has been successfully installed."
else
echo >&2 " "
echo >&2 "❌ REDAXO setup failed."
echo >&2 " "
exit 1
fi

# update file owner and group of writable folders (cache, data)
Expand Down
87 changes: 41 additions & 46 deletions source/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,54 +19,49 @@ else
cp -fp redaxo/src/core/default.config.yml redaxo/data/core/config.yml && \
echo >&2 "✅ Default configuration has been successfully copied."

# install REDAXO via cli command if available (REDAXO 5.9+)
if php redaxo/bin/console setup:run; then

# prepare database
# remember the docker database container takes some time to init!
echo >&2 "👉 Prepare database..."
repeat=10
while ! php redaxo/bin/console -q db:set-connection \
--host=$REDAXO_DB_HOST \
--database=$REDAXO_DB_NAME \
--login=$REDAXO_DB_LOGIN \
--password=$REDAXO_DB_PASSWORD 2> /dev/null || false; do
if [[ repeat -eq 0 ]]; then
echo >&2 "❌ Failed to connect database."
exit 1
fi
repeat=$((repeat - 1))
sleep 5
echo >&2 "⏳ Wait for database connection... ($repeat)"
done
echo >&2 "✅ Database has been has been successfully connected."

# run REDAXO setup
# hint: get options via `php redaxo/bin/console setup:run --help`
echo >&2 "👉 Run setup..."
setupArgs=(
"--agree-license"
"--db-createdb=no"
"--db-setup=normal"
);
[[ -n "$REDAXO_LANG" ]] && setupArgs+=("--lang=${REDAXO_LANG}");
[[ -n "$REDAXO_SERVER" ]] && setupArgs+=("--server=${REDAXO_SERVER}");
[[ -n "$REDAXO_SERVERNAME" ]] && setupArgs+=("--servername=${REDAXO_SERVERNAME}");
[[ -n "$REDAXO_ERROR_EMAIL" ]] && setupArgs+=("--error-email=${REDAXO_ERROR_EMAIL}");
[[ -n "$REDAXO_TIMEZONE" ]] && setupArgs+=("--timezone=${REDAXO_TIMEZONE}");
[[ -n "$REDAXO_DB_CHARSET" ]] && setupArgs+=("--db-charset=${REDAXO_DB_CHARSET}");
[[ -n "$REDAXO_DB_PASSWORD" ]] && setupArgs+=("--db-password=${REDAXO_DB_PASSWORD}"); # required again!
[[ -n "$REDAXO_ADMIN_USER" ]] && setupArgs+=("--admin-username=${REDAXO_ADMIN_USER}");
[[ -n "$REDAXO_ADMIN_PASSWORD" ]] && setupArgs+=("--admin-password=${REDAXO_ADMIN_PASSWORD}");

if php redaxo/bin/console setup:run -q -n "${setupArgs[@]}"; then
echo >&2 "✅ REDAXO has been successfully installed."
else
echo >&2 " "
echo >&2 "❌ REDAXO setup failed."
echo >&2 " "
# prepare database
# remember the docker database container takes some time to init!
echo >&2 "👉 Prepare database..."
repeat=10
while ! php redaxo/bin/console -q db:set-connection \
--host=$REDAXO_DB_HOST \
--database=$REDAXO_DB_NAME \
--login=$REDAXO_DB_LOGIN \
--password=$REDAXO_DB_PASSWORD 2> /dev/null || false; do
if [[ repeat -eq 0 ]]; then
echo >&2 "❌ Failed to connect database."
exit 1
fi
repeat=$((repeat - 1))
sleep 5
echo >&2 "⏳ Wait for database connection... ($repeat)"
done
echo >&2 "✅ Database has been has been successfully connected."

# run REDAXO setup
# hint: get options via `php redaxo/bin/console setup:run --help`
echo >&2 "👉 Run setup..."
setupArgs=(
"--db-createdb=no"
"--db-setup=normal"
);
[[ -n "$REDAXO_LANG" ]] && setupArgs+=("--lang=${REDAXO_LANG}");
[[ -n "$REDAXO_SERVER" ]] && setupArgs+=("--server=${REDAXO_SERVER}");
[[ -n "$REDAXO_SERVERNAME" ]] && setupArgs+=("--servername=${REDAXO_SERVERNAME}");
[[ -n "$REDAXO_ERROR_EMAIL" ]] && setupArgs+=("--error-email=${REDAXO_ERROR_EMAIL}");
[[ -n "$REDAXO_TIMEZONE" ]] && setupArgs+=("--timezone=${REDAXO_TIMEZONE}");
[[ -n "$REDAXO_DB_CHARSET" ]] && setupArgs+=("--db-charset=${REDAXO_DB_CHARSET}");
[[ -n "$REDAXO_DB_PASSWORD" ]] && setupArgs+=("--db-password=${REDAXO_DB_PASSWORD}");
[[ -n "$REDAXO_ADMIN_USER" ]] && setupArgs+=("--admin-username=${REDAXO_ADMIN_USER}");
[[ -n "$REDAXO_ADMIN_PASSWORD" ]] && setupArgs+=("--admin-password=${REDAXO_ADMIN_PASSWORD}");

if php redaxo/bin/console setup:run -q -n "${setupArgs[@]}"; then
echo >&2 "✅ REDAXO has been successfully installed."
else
echo >&2 " "
echo >&2 "❌ REDAXO setup failed."
echo >&2 " "
exit 1
fi

# update file owner and group of writable folders (cache, data)
Expand Down

0 comments on commit 666b429

Please sign in to comment.