mgmt/scripts/utilities/quick-start.sh

114 lines
2.7 KiB
Bash
Executable File
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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
# 快速启动脚本
set -e
echo "🚀 欢迎使用基础设施管理平台!"
echo ""
# 检查必要工具
check_tool() {
if ! command -v "$1" &> /dev/null; then
echo "$1 未安装,请先运行 'make setup'"
return 1
fi
}
echo "🔍 检查必要工具..."
check_tool "tofu" || exit 1
check_tool "ansible" || exit 1
check_tool "docker" || exit 1
echo "✅ 工具检查通过"
echo ""
# 检查配置文件
CONFIG_FILE="infrastructure/environments/dev/terraform.tfvars"
if [ ! -f "$CONFIG_FILE" ]; then
echo "⚠️ 配置文件不存在,正在创建..."
cp "${CONFIG_FILE}.example" "$CONFIG_FILE"
echo "📝 请编辑配置文件: $CONFIG_FILE"
echo " 填入你的云服务商凭据后再次运行此脚本"
exit 1
fi
echo "✅ 配置文件存在"
echo ""
# 选择操作
echo "请选择要执行的操作:"
echo "1) 初始化基础设施"
echo "2) 查看执行计划"
echo "3) 应用基础设施变更"
echo "4) 部署应用"
echo "5) 启动开发环境"
echo "6) 查看监控"
echo "7) 完整部署流程"
echo ""
read -p "请输入选项 (1-7): " choice
case $choice in
1)
echo "🏗️ 初始化基础设施..."
make init
;;
2)
echo "📋 查看执行计划..."
make plan
;;
3)
echo "🚀 应用基础设施变更..."
make apply
;;
4)
echo "📦 部署应用..."
make ansible-deploy
;;
5)
echo "🐳 启动开发环境..."
make docker-up
;;
6)
echo "📊 启动监控..."
make monitor
;;
7)
echo "🎯 执行完整部署流程..."
echo ""
echo "步骤 1/4: 初始化基础设施..."
make init
echo ""
echo "步骤 2/4: 查看执行计划..."
make plan
echo ""
read -p "是否继续应用基础设施变更? (y/N): " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo "步骤 3/4: 应用基础设施变更..."
make apply
echo ""
echo "步骤 4/4: 部署应用..."
make ansible-deploy
echo ""
echo "🎉 完整部署流程完成!"
else
echo " 部署流程已取消"
fi
;;
*)
echo "❌ 无效选项"
exit 1
;;
esac
echo ""
echo "🎉 操作完成!"
echo ""
echo "📋 有用的命令:"
echo " make help - 查看所有可用命令"
echo " make plan - 查看基础设施变更计划"
echo " make apply - 应用基础设施变更"
echo " make ansible-deploy - 部署应用"
echo " make monitor - 启动监控"
echo " make clean - 清理临时文件"