Files
svn-manager/setup-aliyun-svn.sh
2026-02-09 17:22:26 +08:00

47 lines
1.7 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
set -e
echo "===> 检查系统信息..."
if [ -f /etc/os-release ]; then
. /etc/os-release
else
echo "找不到 /etc/os-release无法判断系统类型退出。"
exit 1
fi
if [ "$ID" != "ubuntu" ]; then
echo "当前不是 UbuntuID=$ID),本脚本按 Ubuntu + apt + 阿里云源编写,请自行确认后改造。"
exit 1
fi
CODENAME=$(lsb_release -cs 2>/dev/null || echo "$VERSION_CODENAME")
if [ -z "$CODENAME" ]; then
echo "无法获取发行版代号jammy/focal 等),退出。"
exit 1
fi
echo "===> 备份原 sources.list 到 /etc/apt/sources.list.bak ..."
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
echo "===> 写入阿里云源 (Ubuntu $CODENAME) ..."
sudo bash -c "cat >/etc/apt/sources.list <<EOF2
deb http://mirrors.aliyun.com/ubuntu/ $CODENAME main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ $CODENAME-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ $CODENAME-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ $CODENAME-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ $CODENAME main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ $CODENAME-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ $CODENAME-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ $CODENAME-backports main restricted universe multiverse
EOF2"
echo "===> apt 更新索引..."
sudo apt update
echo "===> 安装 subversion ..."
sudo apt install -y subversion
echo "===> 完成。当前 svn 版本:"
svn --version | head -n 1 || echo "svn 命令未找到,请检查安装是否成功。"