🎉 feat: 更新一键启动脚本,添加安装标记以避免重复安装

This commit is contained in:
HawkinC Macbook 2025-04-17 18:14:51 +08:00
parent 30fcc09cfb
commit b7eaa5e499
1 changed files with 11 additions and 3 deletions

View File

@ -24,20 +24,28 @@ while getopts ":hb:" opt; do
done done
# = clone 到 tmp/.config 并加载profile入口 # = clone 到 tmp/.config 并加载profile入口
test -f "$HOME/.config/.bin/.Runtime/local.env.ini" && { # == 如果已安装过,则不再执行
test -f "$HOME"/.config/.bin/.Runtime/SELF_MARK_AS_INSTALLED_FROM_SCRIPT && {
echo "local.env.ini already exists, end the install. please remove it first if need re-install." echo "local.env.ini already exists, end the install. please remove it first if need re-install."
exit 1 exit 1
} }
# = 移动原有配置 # == 移走原有配置目录
[ -d "/tmp/.config" ] && rm -rf /tmp/.config # 如果存在, 删除 /tmp/.config [ -d "/tmp/.config" ] && rm -rf /tmp/.config # 如果存在, 删除 /tmp/.config
[ -d "$HOME/.config" ] && mv "$HOME/.config" /tmp/.config # 移动原有 $HOME/.config 配置到 /tmp/.config [ -d "$HOME/.config" ] && mv "$HOME/.config" /tmp/.config # 移动原有 $HOME/.config 配置到 /tmp/.config
# 克隆,如果失败则退出
git clone --depth 1 --branch "$BRANCH" --single-branch https://gitea.yever.top/Hawkin/.config.git "$HOME"/.config git clone --depth 1 --branch "$BRANCH" --single-branch https://gitea.yever.top/Hawkin/.config.git "$HOME"/.config
test $? -ne 0 && { test $? -ne 0 && {
echo "git clone failed, please check your network." echo "git clone failed, please check your network."
exit 1 exit 1
} }
# = 标记已安装
test -d "$HOME"/.config/.bin/.Runtime || mkdir -p "$HOME"/.config/.bin/.Runtime
cat >"$HOME"/.config/.bin/.Runtime/SELF_MARK_AS_INSTALLED_FROM_SCRIPT <<EOF
此文件存在时自动跳过克隆安装, 在安装完成时创建.
如果你想要重新安装, 请删除此文件——下次安装时会将当前配置仓库移动到备份目录(默认为~/.local/share/Origin_Config_Backup.
EOF
echo "git clone success, init project by script itself..." echo "git clone success, init project by script itself..."
# = 通过目标仓库的初始化脚本进行初始化 # = 通过目标仓库的初始化脚本进行初始化