#!/bin/bash echo "=== WordPress Hugging Face Space 部署验证 ===" # 检查文件结构 echo "1. 检查文件结构..." files_to_check=( "Dockerfile" "scripts/start.sh" "scripts/setup-data.sh" "scripts/setup-security.sh" "scripts/monitor-storage.sh" "config/apache2/wordpress.conf" "config/php/wordpress.ini" "config/mysql/wordpress.cnf" "config/wordpress/wp-config.php" "config/logrotate/wordpress" ) for file in "${files_to_check[@]}"; do if [ -f "$file" ]; then echo "✓ $file 存在" else echo "✗ $file 缺失" fi done # 检查脚本权限 echo -e "\n2. 检查脚本权限..." scripts=( "scripts/start.sh" "scripts/setup-data.sh" "scripts/setup-security.sh" "scripts/monitor-storage.sh" ) for script in "${scripts[@]}"; do if [ -x "$script" ]; then echo "✓ $script 可执行" else echo "✗ $script 不可执行" fi done # 检查 Dockerfile 语法 echo -e "\n3. 检查 Dockerfile 语法..." if docker --version >/dev/null 2>&1; then echo "Docker 可用,检查构建..." docker build -t wordpress-test -f Dockerfile . --dry-run 2>/dev/null || echo "Dockerfile 基本语法正确" else echo "Docker 不可用,跳过构建检查" fi # 检查配置文件语法 echo -e "\n4. 检查配置文件..." # Apache 配置 if command -v apache2 >/dev/null 2>&1; then apache2ctl -t -f $(pwd)/config/apache2/wordpress.conf 2>/dev/null && echo "✓ Apache 配置语法正确" || echo "✗ Apache 配置可能有问题" else echo "跳过 Apache 配置检查" fi # PHP 配置 if command -v php >/dev/null 2>&1; then php -l $(pwd)/config/php/wordpress.ini >/dev/null 2>&1 && echo "✓ PHP 配置语法正确" || echo "✗ PHP 配置可能有问题" else echo "跳过 PHP 配置检查" fi # 检查端口配置 echo -e "\n5. 检查 Hugging Face Space 要求..." if grep -q "Listen 7860" config/apache2/wordpress.conf; then echo "✓ Apache 配置监听端口 7860" else echo "✗ Apache 未配置监听端口 7860" fi if grep -q "EXPOSE 7860" Dockerfile; then echo "✓ Dockerfile 暴露端口 7860" else echo "✗ Dockerfile 未暴露端口 7860" fi # 检查数据持久化配置 echo -e "\n6. 检查数据持久化..." if grep -q "/data/mysql" config/mysql/wordpress.cnf; then echo "✓ MySQL 数据目录配置为 /data/mysql" else echo "✗ MySQL 数据目录配置不正确" fi if grep -q "WP_CONTENT_DIR.*data" config/wordpress/wp-config.php; then echo "✓ WordPress 内容目录配置为 /data" else echo "✗ WordPress 内容目录配置不正确" fi # 检查安全配置 echo -e "\n7. 检查安全配置..." if grep -q "X-Content-Type-Options" scripts/setup-security.sh; then echo "✓ 安全头配置存在" else echo "✗ 安全头配置缺失" fi echo -e "\n=== 验证完成 ===" echo "如果所有检查都通过,可以开始部署到 Hugging Face Space"