fix:优化试题内容和样式排版
This commit is contained in:
63
scripts/configure-mirrors.sh
Executable file
63
scripts/configure-mirrors.sh
Executable file
@@ -0,0 +1,63 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
MODE="${1:-cn}"
|
||||
|
||||
NPM_CN_REGISTRY="https://registry.npmmirror.com"
|
||||
PIP_CN_INDEX_URL="https://mirrors.aliyun.com/pypi/simple/"
|
||||
PIP_CN_TRUSTED_HOST="mirrors.aliyun.com"
|
||||
DOCKER_CN_REGISTRY_MIRROR="https://registry.cn-hangzhou.aliyuncs.com"
|
||||
|
||||
if [[ "${MODE}" != "cn" && "${MODE}" != "global" ]]; then
|
||||
echo "用法: ./scripts/configure-mirrors.sh [cn|global]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "==> 配置 npm"
|
||||
if command -v npm >/dev/null 2>&1; then
|
||||
if [[ "${MODE}" == "cn" ]]; then
|
||||
npm config set registry "${NPM_CN_REGISTRY}"
|
||||
else
|
||||
npm config set registry "https://registry.npmjs.org"
|
||||
fi
|
||||
npm config get registry
|
||||
else
|
||||
echo "未检测到 npm,跳过"
|
||||
fi
|
||||
|
||||
echo "==> 配置 pip (用户级 ~/.pip/pip.conf)"
|
||||
mkdir -p "${HOME}/.pip"
|
||||
if [[ "${MODE}" == "cn" ]]; then
|
||||
cat > "${HOME}/.pip/pip.conf" <<EOF
|
||||
[global]
|
||||
index-url = ${PIP_CN_INDEX_URL}
|
||||
trusted-host = ${PIP_CN_TRUSTED_HOST}
|
||||
timeout = 120
|
||||
EOF
|
||||
else
|
||||
cat > "${HOME}/.pip/pip.conf" <<EOF
|
||||
[global]
|
||||
index-url = https://pypi.org/simple
|
||||
timeout = 120
|
||||
EOF
|
||||
fi
|
||||
echo "pip.conf 已更新: ${HOME}/.pip/pip.conf"
|
||||
|
||||
echo "==> Docker 镜像加速器"
|
||||
if [[ "${MODE}" == "cn" ]]; then
|
||||
cat <<EOF
|
||||
请在 Docker Desktop -> Settings -> Docker Engine 中加入:
|
||||
{
|
||||
"registry-mirrors": [
|
||||
"${DOCKER_CN_REGISTRY_MIRROR}"
|
||||
]
|
||||
}
|
||||
EOF
|
||||
else
|
||||
cat <<EOF
|
||||
如需恢复 Docker 默认源,请移除 Docker Engine 中的 "registry-mirrors" 配置后重启 Docker Desktop。
|
||||
EOF
|
||||
fi
|
||||
|
||||
echo "==> 完成 (${MODE})"
|
||||
Reference in New Issue
Block a user