From 30fcc09cfb2fde35b0a9ff27de04861e748302e6 Mon Sep 17 00:00:00 2001 From: HawkinC Macbook Date: Thu, 17 Apr 2025 17:08:32 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=89=20feat:=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E4=B8=80=E9=94=AE=E8=84=9A=E6=9C=AC=E5=90=AF=E5=8A=A8Hawkin/.c?= =?UTF-8?q?onfig=E9=A1=B9=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config-os-and-apps.sh | 44 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 config-os-and-apps.sh diff --git a/config-os-and-apps.sh b/config-os-and-apps.sh new file mode 100644 index 0000000..3a29992 --- /dev/null +++ b/config-os-and-apps.sh @@ -0,0 +1,44 @@ +#!/bin/bash +# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +# 一键启动Project +# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +# 默认分支 +BRANCH="dev" + +# 使用getopts处理参数 +while getopts ":hb:" opt; do + case $opt in + b) BRANCH="$OPTARG" ;; + h) + echo "使用方法: $0 [-d] [-h]" + echo " -d 开发模式" + echo " -h 显示帮助" + exit 0 + ;; + \?) + echo "无效选项: -$OPTARG" >&2 + exit 1 + ;; + esac +done + +# = clone 到 tmp/.config 并加载profile入口 +test -f "$HOME/.config/.bin/.Runtime/local.env.ini" && { + echo "local.env.ini already exists, end the install. please remove it first if need re-install." + exit 1 +} +# = 移动原有配置 +[ -d "/tmp/.config" ] && rm -rf /tmp/.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 +test $? -ne 0 && { + echo "git clone failed, please check your network." + exit 1 +} + +echo "git clone success, init project by script itself..." + +# = 通过目标仓库的初始化脚本进行初始化 +bash "$HOME"/.config/.bin/bin/Init.sh