harbor run -t openthoughts/tasktrove-exp-rpt-stack-bash-withtests-gpt5mini-v2-stack-bash-withtests-gpt4o-5502harbor download openthoughts/tasktrove-exp-rpt-stack-bash-withtests-gpt5mini-v2-stack-bash-withtests-gpt4o-5502Create an executable Bash script at /app/install-wordpress.sh that performs an idempotent WordPress installation/configuration routine. The script will be used in a container environment and must be safe for non-interactive runs.
Required behavior
Installation logic
Inputs and outputs
File location and name
Other requirements
This specification provides the behavior and interfaces required so the verifier can detect a correct implementation without revealing internal test checks.
The following test script will be used to verify your solution:
#!/bin/bash
# Demyx
# https://demyx.sh
set -euo pipefail
# Define variables
WORDPRESS_DB_NAME="${WORDPRESS_DB_NAME:-}"
WORDPRESS_DB_USER="${WORDPRESS_DB_USER:-}"
WORDPRESS_DB_PASSWORD="${WORDPRESS_DB_PASSWORD:-}"
WORDPRESS_DB_HOST="${WORDPRESS_DB_HOST:-}"
if [[ ! -d "$CODE_ROOT"/wp-admin ]]; then
echo "WordPress is missing, installing now."
cp -r "$CODE_CONFIG"/wordpress/* "$CODE_ROOT"
if [[ "$WORDPRESS_DB_NAME" && "$WORDPRESS_DB_USER" && "$WORDPRESS_DB_PASSWORD" && "$WORDPRESS_DB_HOST" ]]; then
mv "$CODE_ROOT"/wp-config-sample.php "$CODE_ROOT"/wp-config.php
sed -i "s/database_name_here/$WORDPRESS_DB_NAME/g" "$CODE_ROOT"/wp-config.php
sed -i "s/username_here/$WORDPRESS_DB_USER/g" "$CODE_ROOT"/wp-config.php
sed -i "s/password_here/$WORDPRESS_DB_PASSWORD/g" "$CODE_ROOT"/wp-config.php
sed -i "s/localhost/$WORDPRESS_DB_HOST/g" "$CODE_ROOT"/wp-config.php
wp core install \
--url="${WORDPRESS_DOMAIN:-}" \
--title="${WORDPRESS_DOMAIN:-}" \
--admin_user="${WORDPRESS_ADMIN_USER:-}" \
--admin_password="${WORDPRESS_ADMIN_PASSWORD:-}" \
--admin_email="${WORDPRESS_ADMIN_EMAIL:-}" \
--skip-email
wp rewrite structure '/%category%/%postname%/'
wp config shuffle-salts
sed -i "s/\$table_prefix = 'wp_';/\$table_prefix = 'wp_';\n\n\/\/ If we're behind a proxy server and using HTTPS, we need to alert Wordpress of that fact\n\/\/ see also http:\/\/codex.wordpress.org\/Administration_Over_SSL#Using_a_Reverse_Proxy\nif (isset($\_SERVER['HTTP_X_FORWARDED_PROTO']) \&\& $\_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {\n\t$\_SERVER['HTTPS'] = 'on';\n}\n/g" "$CODE_ROOT"/wp-config.php
else
echo "One or more environment variables are missing! Exiting ... "
exit 1
fi
fi