Files
yitao-ren-gallery/setup.sh

74 lines
2.0 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# setup.sh已弃用不建议使用setup.sh进行安装。请使用README.md中的安装步骤进行安装。
# setup.sh is deprecated and not recommended for installation. Please follow the installation steps in README.md instead.
# YITAO-REN GALLERY 项目安装脚本
set -e
echo "🚀 开始安装 YITAO-REN GALLERY..."
# 检查Python版本
echo "📋 检查Python版本..."
python --version || { echo "❌ Python未安装"; exit 1; }
# 创建虚拟环境
echo "🔧 创建虚拟环境..."
python -m venv venv
# 激活虚拟环境
echo "🔧 激活虚拟环境..."
source venv/bin/activate
# 升级pip
echo "📦 升级pip..."
pip install --upgrade pip
# 安装依赖
echo "📦 安装依赖..."
pip install -r requirements.txt
# 复制环境变量文件
echo "⚙️ 配置环境变量..."
if [ ! -f .env ]; then
cp .env.example .env
echo "✅ 已创建 .env 文件,请根据需要修改配置"
fi
# 运行数据库迁移
echo "🗄️ 运行数据库迁移..."
python manage.py migrate
# 导入示例数据
echo "🖼️ 导入示例图片..."
python manage.py import_example_images
# 收集静态文件
echo "📁 收集静态文件..."
python manage.py collectstatic --noinput
# 创建超级用户
echo "👤 创建超级用户..."
read -p "是否创建超级用户?(y/n): " create_superuser
if [[ $create_superuser == "y" || $create_superuser == "Y" ]]; then
python manage.py createsuperuser
fi
echo ""
echo "🎉 安装完成!"
echo ""
echo "📋 运行以下命令启动项目:"
echo " source venv/bin/activate"
echo " python manage.py runserver"
echo ""
echo "🌐 访问地址:"
echo " - 网站首页: http://localhost:8000"
echo " - 管理后台: http://localhost:8000/admin"
echo ""
echo "🔧 其他命令:"
echo " - 导入示例图片: python manage.py import_example_images"
echo " - 创建迁移文件: python manage.py makemigrations"
echo " - 应用迁移: python manage.py migrate"
echo " - 收集静态文件: python manage.py collectstatic"
echo ""