From d6c17a99ea2b3619212761bcc218d23caeb34476 Mon Sep 17 00:00:00 2001 From: Anthony Date: Fri, 4 Apr 2025 23:55:18 +0800 Subject: [PATCH] Fixed installation --- scripts/install-wordpress.sh | 111 +++++++++++++++++++++-------------- 1 file changed, 67 insertions(+), 44 deletions(-) diff --git a/scripts/install-wordpress.sh b/scripts/install-wordpress.sh index 7faa301..b1c7fe7 100644 --- a/scripts/install-wordpress.sh +++ b/scripts/install-wordpress.sh @@ -218,47 +218,54 @@ if [ -f "wp-config.php" ]; then fi # Download WordPress core if not already present -if [ ! -f "wp-config.php" ]; then - echo -e "${YELLOW}Downloading WordPress core...${NC}" +if [ ! -f "index.php" ] && [ ! -d "wp-admin" ]; then + echo -e "${YELLOW}WordPress files not detected. Downloading WordPress core...${NC}" wp core download --skip-content --allow-root - # Get the latest Twenty* theme - echo -e "${YELLOW}Detecting latest Twenty* theme...${NC}" - mkdir -p wp-content/themes - LATEST_TWENTY_THEME=$(wp theme search twenty --fields=name,version --format=csv --allow-root | grep "^twenty" | sort -V | tail -n 1 | cut -d',' -f1) - - if [ -n "$LATEST_TWENTY_THEME" ]; then - echo -e "${YELLOW}Installing latest WordPress default theme: $LATEST_TWENTY_THEME${NC}" - wp theme install "$LATEST_TWENTY_THEME" --activate --allow-root - else - echo -e "${RED}Could not detect latest Twenty* theme. Falling back to twentytwentyfive${NC}" - wp theme install twentytwentyfive --activate --allow-root - fi + # Now WordPress core installation will handle theme installation automatically + # since we removed the --skip-themes flag from the wp core install command + echo -e "${GREEN}WordPress core downloaded successfully${NC}" +else + echo -e "${GREEN}WordPress files already exist. Skipping download.${NC}" fi -# Create wp-config.php with the new database credentials -echo -e "${YELLOW}Creating wp-config.php...${NC}" -echo -e "${YELLOW}Attempting to use WP-CLI to create config with these parameters:${NC}" -echo -e "Database: $DB_NAME" -echo -e "User: $DB_USER" -echo -e "Password: $DB_PASSWORD" -echo -e "Host: $DB_HOST" - -# Try to create wp-config.php with WP-CLI first (with error output captured) -wp config create --dbname="$DB_NAME" --dbuser="$DB_USER" --dbpass="$DB_PASSWORD" --dbhost="$DB_HOST" --allow-root --debug || { - echo -e "${RED}WP-CLI config create failed. Error code: $?${NC}" - - # Create wp-config.php manually regardless of whether WP-CLI command succeeded - echo -e "${YELLOW}Creating wp-config.php manually as a fallback...${NC}" +# Immediate check to directly create wp-config.php regardless of previous steps +# This is a critical fix to ensure wp-config.php exists before installation continues +echo -e "${YELLOW}CRITICAL FIX: Directly creating wp-config.php to prevent errors...${NC}" +if [ ! -f "wp-config.php" ]; then + echo -e "${RED}wp-config.php is still missing. Creating it directly...${NC}" cat > wp-config.php <