diff --git a/templates/deployment.yaml b/templates/deployment.yaml index 49a99b4..e7efcc6 100644 --- a/templates/deployment.yaml +++ b/templates/deployment.yaml @@ -145,10 +145,12 @@ spec: if [ -z "$TABLES" ]; then echo "=== Starting WordPress Installation ===" - if [ -z "$WP_ADMIN_PASSWORD" ]; then - echo "ERROR: WP_ADMIN_PASSWORD is not set. WordPress installation requires an admin password." - echo "Skipping WordPress installation. Please set WP_ADMIN_PASSWORD in values.yaml" - exit 1 + # 初回インストール時のパスワード処理 + INSTALL_PASSWORD="$WP_ADMIN_PASSWORD" + if [ -z "$INSTALL_PASSWORD" ]; then + # パスワードが空の場合は、ランダムに生成する + INSTALL_PASSWORD=$(openssl rand -base64 32 | tr -d "=+/" | cut -c1-20) + echo "INFO: WP_ADMIN_PASSWORD is not set. Generated random password." fi INSTALL_URL="http://127.0.0.1" @@ -158,13 +160,17 @@ spec: --url="$INSTALL_URL" \ --title="$WP_SITE_TITLE" \ --admin_user="$WP_ADMIN_USER" \ - --admin_password="$WP_ADMIN_PASSWORD" \ + --admin_password="$INSTALL_PASSWORD" \ --admin_email="$WP_ADMIN_EMAIL" \ --skip-email echo "=== WordPress Installation Completed ===" echo "Admin User: $WP_ADMIN_USER" - echo "Admin password was set from values.yaml" + if [ -z "$WP_ADMIN_PASSWORD" ]; then + echo "INFO: Generated admin password. Check Secret for details." + else + echo "Admin password was set from values.yaml" + fi else echo "WordPress is already installed, skipping installation" if [ -f /tmp/wp-cli.phar ]; then