71 lines
1.8 KiB
Bash
Executable File
71 lines
1.8 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# 快速安装脚本 - 从 Gitea 仓库直接安装 ZSH 配置
|
|
# 用法: curl -fsSL https://your-gitea.com/ben/mgmt/raw/branch/main/configuration/zsh/quick-install.sh | bash
|
|
|
|
set -euo pipefail
|
|
|
|
# 颜色定义
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
BLUE='\033[0;34m'
|
|
NC='\033[0m'
|
|
|
|
log_info() {
|
|
echo -e "${BLUE}[INFO]${NC} $1"
|
|
}
|
|
|
|
log_success() {
|
|
echo -e "${GREEN}[SUCCESS]${NC} $1"
|
|
}
|
|
|
|
log_error() {
|
|
echo -e "${RED}[ERROR]${NC} $1"
|
|
}
|
|
|
|
# Gitea 仓库信息
|
|
GITEA_URL="https://ben:8d7d70f324796be650b79415303c31f567bf459b@gitea.tailnet-68f9.ts.net/ben/mgmt.git"
|
|
MGMT_DIR="/root/mgmt"
|
|
|
|
log_info "开始快速安装 ZSH 配置..."
|
|
|
|
# 检查 root 权限
|
|
if [[ $EUID -ne 0 ]]; then
|
|
log_error "此脚本需要 root 权限运行"
|
|
exit 1
|
|
fi
|
|
|
|
# 克隆或更新仓库
|
|
if [[ -d "$MGMT_DIR" ]]; then
|
|
log_info "更新现有仓库..."
|
|
cd "$MGMT_DIR"
|
|
git pull origin main
|
|
else
|
|
log_info "克隆仓库..."
|
|
git clone "$GITEA_URL" "$MGMT_DIR"
|
|
cd "$MGMT_DIR"
|
|
fi
|
|
|
|
# 检查并设置代理(如果需要)
|
|
if [[ -f "$MGMT_DIR/configuration/proxy.env" ]]; then
|
|
log_info "发现代理配置,先设置代理..."
|
|
source "$MGMT_DIR/configuration/proxy.env"
|
|
|
|
# 测试代理连接
|
|
if curl -s --connect-timeout 5 --proxy "$http_proxy" https://httpbin.org/ip >/dev/null 2>&1; then
|
|
log_success "代理连接正常,将使用代理安装"
|
|
else
|
|
log_warning "代理连接失败,将使用直连安装"
|
|
unset http_proxy https_proxy HTTP_PROXY HTTPS_PROXY
|
|
fi
|
|
fi
|
|
|
|
# 运行安装脚本
|
|
log_info "运行 ZSH 配置安装脚本..."
|
|
chmod +x "$MGMT_DIR/configuration/zsh/install-zsh-config.sh"
|
|
"$MGMT_DIR/configuration/zsh/install-zsh-config.sh"
|
|
|
|
log_success "快速安装完成!"
|
|
log_info "请重新登录或运行: source ~/.zshrc"
|