fix(wordpress): generate distinct MYSQL_PASSWORD and MYSQL_ROOT_PASSWORD (sed -g overwrote both)

This commit is contained in:
2026-09-07 12:09:06 +02:00
parent 34f2bd56d0
commit e6f047e45f
+2 -3
View File
@@ -64,9 +64,8 @@ if [ ! -f "$SCRIPT_DIR/.env" ]; then
# Generate random passwords for local dev # Generate random passwords for local dev
ROOT_PASS=$(openssl rand -hex 16 2>/dev/null || cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n1) ROOT_PASS=$(openssl rand -hex 16 2>/dev/null || cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n1)
WP_PASS=$(openssl rand -hex 16 2>/dev/null || cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n1) WP_PASS=$(openssl rand -hex 16 2>/dev/null || cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n1)
sed -i "s/change-me-to-a-strong-password/${ROOT_PASS}/g" "$SCRIPT_DIR/.env" sed -i "0,/change-me-to-a-strong-password/{s/change-me-to-a-strong-password/${ROOT_PASS}/}" "$SCRIPT_DIR/.env"
# Second occurrence is MYSQL_PASSWORD sed -i "s/change-me-to-a-strong-password/${WP_PASS}/" "$SCRIPT_DIR/.env"
sed -i "0,/change-me-to-a-strong-password/{s/change-me-to-a-strong-password/${WP_PASS}/}" "$SCRIPT_DIR/.env"
echo -e "${GREEN}${NC} Contraseñas generadas en ${SCRIPT_DIR}/.env" echo -e "${GREEN}${NC} Contraseñas generadas en ${SCRIPT_DIR}/.env"
fi fi