优化模板用户提示

This commit is contained in:
2025-05-02 20:52:16 +08:00
parent f01641d3fe
commit aa8b4f386d

39
main.tf
View File

@@ -15,27 +15,27 @@ locals {
} }
data "coder_parameter" "clone_reference" { data "coder_parameter" "clone_reference" {
name = "克隆参考文档站点" name = "初始化荆棘鸟文学社参考文档"
type = "bool" type = "bool"
description = "是否克隆荆棘鸟参考文档站点" description = "是否初始化荆棘鸟参考文档"
mutable = true mutable = true
default = "true" default = "true"
icon = "/emojis/1f4d6.png" icon = "/emojis/1f4d6.png"
} }
data "coder_parameter" "clone_spbook" { data "coder_parameter" "clone_spbook" {
name = "克隆高三特刊站点" name = "初始化荆棘鸟文学社高三特刊"
type = "bool" type = "bool"
description = "是否克隆荆棘鸟高三特刊站点" description = "是否初始化荆棘鸟文学社高三特刊"
mutable = true mutable = true
default = "false" default = "false"
icon = "/emojis/1f4da.png" icon = "/emojis/1f4da.png"
} }
data "coder_parameter" "clone_main" { data "coder_parameter" "clone_main" {
name = "克隆主站点" name = "初始化荆棘鸟文学社主站点"
type = "bool" type = "bool"
description = "是否克隆荆棘鸟主站点" description = "是否初始化荆棘鸟文学社主站点"
mutable = true mutable = true
default = "false" default = "false"
icon = "/emojis/1f3e0.png" icon = "/emojis/1f3e0.png"
@@ -82,12 +82,13 @@ resource "coder_agent" "main" {
mkdir -p ~/.ssh mkdir -p ~/.ssh
chmod 700 ~/.ssh chmod 700 ~/.ssh
# 生成 SSH 密钥对,不设置密码 # 生成 SSH 密钥对
ssh-keygen -t ed25519 -f ~/.ssh/git -N "" -C "${data.coder_workspace_owner.me.name}(${data.coder_workspace_owner.me.email})-${data.coder_workspace.me.name}" ssh-keygen -t ed25519 -f ~/.ssh/git -N "" -C "${data.coder_workspace_owner.me.name}(${data.coder_workspace_owner.me.email})-${data.coder_workspace.me.name}"
# 创建 SSH 配置文件 # 创建 SSH 配置文件
cat > ~/.ssh/config <<EOF cat > ~/.ssh/config <<EOF
Host ssh.lionhao.top Host ssh.lionhao.top
StrictHostKeyChecking accept-new
Port 4022 Port 4022
User git User git
IdentityFile ~/.ssh/git IdentityFile ~/.ssh/git
@@ -98,8 +99,9 @@ EOF
chmod 600 ~/.ssh/git chmod 600 ~/.ssh/git
chmod 644 ~/.ssh/git.pub chmod 644 ~/.ssh/git.pub
echo "SSH key pair created. Your public key is:" echo "SSH 密钥对创建成功,你的公钥是:"
cat ~/.ssh/git.pub cat ~/.ssh/git.pub
echo "请将以上公钥添加到 Gitea 个人 SSH 密钥中"
# 添加 git 全局配置 # 添加 git 全局配置
git config --global user.name "${data.coder_workspace_owner.me.name}" git config --global user.name "${data.coder_workspace_owner.me.name}"
@@ -109,35 +111,32 @@ EOF
# 拉取仓库 # 拉取仓库
if [ "${data.coder_parameter.clone_reference.value}" = "true" ]; then if [ "${data.coder_parameter.clone_reference.value}" = "true" ]; then
echo "正在克隆 reference 仓库..." echo "正在克隆 荆棘鸟文学社参考文档站点仓库..."
git clone https://gitea.lionhao.top/jjnwxs/jingji_reference.git git clone https://gitea.lionhao.top/jjnwxs/jingji_reference.git
echo "reference 仓库克隆完成" echo "荆棘鸟文学社参考文档站点仓库 克隆完成"
# 修改远程仓库地址为SSH
cd jingji_reference cd jingji_reference
git remote set-url origin git@ssh.lionhao.top:jjnwxs/jingji_reference.git git remote set-url origin git@ssh.lionhao.top:jjnwxs/jingji_reference.git
echo "reference 仓库远程地址已更新为SSH" echo "荆棘鸟文学社参考文档站点仓库 远程地址设置成功"
cd .. cd ..
fi fi
if [ "${data.coder_parameter.clone_spbook.value}" = "true" ]; then if [ "${data.coder_parameter.clone_spbook.value}" = "true" ]; then
echo "正在克隆 spbook 仓库..." echo "正在克隆 荆棘鸟文学社高三特刊站点仓库..."
git clone https://gitea.lionhao.top/jjnwxs/jingji_spbook.git git clone https://gitea.lionhao.top/jjnwxs/jingji_spbook.git
echo "spbook 仓库克隆完成" echo "荆棘鸟文学社高三特刊站点仓库 克隆完成"
# 修改远程仓库地址为SSH
cd jingji_spbook cd jingji_spbook
git remote set-url origin git@ssh.lionhao.top:jjnwxs/jingji_spbook.git git remote set-url origin git@ssh.lionhao.top:jjnwxs/jingji_spbook.git
echo "spbook 仓库远程地址已更新为SSH" echo " 荆棘鸟文学社高三特刊站点仓库 远程地址设置成功"
cd .. cd ..
fi fi
if [ "${data.coder_parameter.clone_main.value}" = "true" ]; then if [ "${data.coder_parameter.clone_main.value}" = "true" ]; then
echo "正在克隆 main 仓库..." echo "正在克隆 荆棘鸟文学社主站点仓库..."
git clone https://gitea.lionhao.top/jjnwxs/jingji_main.git git clone https://gitea.lionhao.top/jjnwxs/jingji_main.git
echo "main 仓库克隆完成" echo "荆棘鸟文学社主站点仓库 克隆完成"
# 修改远程仓库地址为SSH
cd jingji_main cd jingji_main
git remote set-url origin git@ssh.lionhao.top:jjnwxs/jingji_main.git git remote set-url origin git@ssh.lionhao.top:jjnwxs/jingji_main.git
echo "main 仓库远程地址已更新为SSH" echo "荆棘鸟文学社主站点仓库 远程地址设置成功"
cd .. cd ..
fi fi