代码拉取完成,页面将自动刷新
#!/bin/bash
# 初始化路径常量
ROOT_DIR="${HOME}/.local/${USER}"
SCR_DIR="${ROOT_DIR}/scripts"
APP_DIR="${ROOT_DIR}/applications"
TMP_DIR="${ROOT_DIR}/tmp"
FG_DIR="${APP_DIR}/fastgithub"
if [ ! -d "${TMP_DIR}" ]; then
mkdir -p "${TMP_DIR}"
fi
# 判断脚本是否被直接执行
if [ ! -f "${SCR_DIR}/fastgithub_568.sh" ]; then
echo "正在安装脚本。"
if [ ! -d "${SCR_DIR}" ]; then
mkdir -p "${SCR_DIR}"
fi
wget -P "${TMP_DIR}" https://gitee.com/PJ-568/PJ568-sh/raw/main/fastgithub_568.sh || { echo "下载更新 失败,退出。"; exit 1; }
mv -f "${TMP_DIR}/fastgithub_568.sh" "${SCR_DIR}/fastgithub_568.sh" || { echo "移动文件失败,退出。"; exit 1; }
echo "给予脚本可执行权限。"
chmod +x "${SCR_DIR}/fastgithub_568.sh"
echo "脚本已安装。"
fi
echo "检查本目录是否在 PATH 中。"
if ! grep -q "${SCR_DIR}" <<< "$PATH"; then
echo "请手动将脚本目录添加到 PATH 中。如运行以下命令:"
echo "echo \"export PATH=\$PATH:${SCR_DIR}\" >> ~/.bashrc"
exit 0
fi
# 判断是否已安装 FastGithub
if [ ! -f "${FG_DIR}/fastgithub" ]; then
echo "FastGithub 不存在,下载安装。"
if [ ! -d "${APP_DIR}" ]; then
mkdir -p "${APP_DIR}"
fi
wget -P "${TMP_DIR}" https://github.moeyy.xyz/https://github.com/WangGithubUser/FastGitHub/releases/download/v2.1.5/fastgithub_linux-x64.zip || { echo "下载 FastGithub 失败,退出。"; exit 1; }
unzip -n "${TMP_DIR}/fastgithub_linux-x64.zip" -d "${TMP_DIR}/"
rm "${TMP_DIR}/fastgithub_linux-x64.zip"
mv -f "${TMP_DIR}/fastgithub_linux-x64" "${FG_DIR}"
chmod +x "${FG_DIR}/fastgithub"
fi
# 命令行参数解析
for i in $@; do
if [ "$i" == "start" ]; then
sudo ${FG_DIR}/fastgithub start || { echo "启动失败。"; exit 1; }
echo "FastGithub 启动成功,默认代理地址:http://localhost:38457"
git config --global http.https://github.com.proxy http://127.0.0.1:38457
git config --global https.https://github.com.proxy http://127.0.0.1:38457
exit 0
elif [ "$i" == "stop" ]; then
sudo ${FG_DIR}/fastgithub stop || { echo "停止失败。"; exit 1; }
echo "FastGithub 停止成功。"
git config --global --unset http.proxy
git config --global --unset https.proxy
exit 0
elif [ "$i" == "update" ]; then
wget -P "${TMP_DIR}" https://gitee.com/PJ-568/PJ568-sh/raw/main/fastgithub_568.sh || { echo "下载更新 失败,退出。"; exit 1; }
mv -f "${TMP_DIR}/fastgithub_568.sh" "${SCR_DIR}/fastgithub_568.sh" || { echo "移动文件失败,退出。"; exit 1; }
chmod +x "${SCR_DIR}/fastgithub_568.sh"
echo "更新成功,请重启脚本。"
exit 0
fi
done
echo "使用方法|Usage: fastgithub [start|stop|update]"
exit 0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。