#!/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/SELF_MARK_AS_INSTALLED_FROM_SCRIPT && { 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 } # = 标记已安装 test -d "$HOME"/.config/.bin/.Runtime || mkdir -p "$HOME"/.config/.bin/.Runtime cat >"$HOME"/.config/.bin/.Runtime/SELF_MARK_AS_INSTALLED_FROM_SCRIPT <