Skip to content

Instantly share code, notes, and snippets.

@Soulter
Last active April 26, 2025 05:25
Show Gist options
  • Select an option

  • Save Soulter/4f988966b0646fc0dcad23d6ec72982c to your computer and use it in GitHub Desktop.

Select an option

Save Soulter/4f988966b0646fc0dcad23d6ec72982c to your computer and use it in GitHub Desktop.
AstrBot Linux 一键安装 shell 脚本
#!/bin/bash
# 1. 安装必要的包
sudo apt update
sudo apt install -y python3-pip python3-venv jq wget unzip
# 2. 定义加速地址列表
ACCELERATED_URLS=(
"https://github.moeyy.xyz"
)
MASTER_ZIP_PATH="AstrBot.zip"
REPO_ZIP_PATH="https://github.com/AstrBotDevs/AstrBot/archive/refs/heads/master.zip"
SUCCESS=0
# 3. 下载 master.zip
for BASE in "${ACCELERATED_URLS[@]}"; do
PROXY_URL="${BASE}/${REPO_ZIP_PATH}"
echo "Trying: $PROXY_URL"
if wget -O "$MASTER_ZIP_PATH" "$PROXY_URL"; then
echo "Download succeeded from: $BASE"
SUCCESS=1
break
else
echo "Failed to download from: $BASE"
fi
done
# 4. 若全部失败,使用 GitHub 官方源
if [ "$SUCCESS" -ne 1 ]; then
echo "All proxies failed. Trying official GitHub..."
if ! wget -O "$MASTER_ZIP_PATH" "$REPO_ZIP_PATH"; then
echo "Download failed from official GitHub."
exit 1
fi
fi
# 5. 解压并重命名
unzip -q "$MASTER_ZIP_PATH"
rm "$MASTER_ZIP_PATH"
mv AstrBot-master astrbot
cd astrbot
# 6. 创建虚拟环境并安装 uv
python3 -m venv .venv
source .venv/bin/activate
# 设置 pip 阿里云源
pip install --upgrade pip
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
# 安装 uv
pip install uv
# 7. 配置 uv 使用阿里云源
mkdir -p .uv
cat > .uv/config.toml <<EOF
[mirrors]
pypi = "https://pypi.tuna.tsinghua.edu.cn/simple"
EOF
# 8. 安装依赖 & 运行
uv sync -i https://mirrors.aliyun.com/pypi/simple/
uv run main.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment