|
|
@ -3,13 +3,13 @@ |
|
|
|
# https://github.com/P3TERX/aria2.sh |
|
|
|
# Description: Aria2 One-click installation management script |
|
|
|
# System Required: CentOS/Debian/Ubuntu |
|
|
|
# Version: 2.5.4 |
|
|
|
# Version: 2.5.5 |
|
|
|
# Author: Toyo |
|
|
|
# Maintainer: P3TERX |
|
|
|
# Blog: https://p3terx.com |
|
|
|
#============================================================= |
|
|
|
|
|
|
|
sh_ver="2.5.4" |
|
|
|
sh_ver="2.5.5" |
|
|
|
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin |
|
|
|
export PATH |
|
|
|
aria2_conf_dir="/root/.aria2c" |
|
|
@ -73,43 +73,43 @@ check_pid() { |
|
|
|
PID=$(ps -ef | grep "aria2c" | grep -v grep | grep -v "aria2.sh" | grep -v "init.d" | grep -v "service" | awk '{print $2}') |
|
|
|
} |
|
|
|
check_new_ver() { |
|
|
|
echo -e "${Info} 请输入 Aria2 版本号,格式如:[ 1.35.0 ],获取地址:[ https://github.com/P3TERX/aria2-builder/releases ]" |
|
|
|
read -e -p "默认回车自动获取最新版本号:" aria2_new_ver |
|
|
|
#echo -e "${Info} 请输入 Aria2 版本号,格式如:[ 1.35.0 ],获取地址:[ https://github.com/P3TERX/aria2-builder/releases ]" |
|
|
|
#read -e -p "默认回车自动获取最新版本号:" aria2_new_ver |
|
|
|
#if [[ -z ${aria2_new_ver} ]]; then |
|
|
|
aria2_new_ver=$( |
|
|
|
{ |
|
|
|
wget -t2 -T3 -qO- "https://api.github.com/repos/P3TERX/aria2-builder/releases/latest" || |
|
|
|
wget -t2 -T3 -qO- "https://gh-api.p3terx.com/repos/P3TERX/aria2-builder/releases/latest" |
|
|
|
} | grep -o '"tag_name": ".*"' | head -n 1 | cut -d'"' -f4 |
|
|
|
) |
|
|
|
if [[ -z ${aria2_new_ver} ]]; then |
|
|
|
aria2_new_ver=$( |
|
|
|
{ |
|
|
|
wget -t2 -T3 -qO- "https://api.github.com/repos/P3TERX/aria2-builder/releases/latest" || |
|
|
|
wget -t2 -T3 -qO- "https://gh-api.p3terx.com/repos/P3TERX/aria2-builder/releases/latest" |
|
|
|
} | grep -o '"tag_name": ".*"' | head -n 1 | cut -d'"' -f4 |
|
|
|
) |
|
|
|
if [[ -z ${aria2_new_ver} ]]; then |
|
|
|
echo -e "${Error} Aria2 最新版本获取失败,请手动获取最新版本号[ https://github.com/P3TERX/aria2-builder/releases ]" |
|
|
|
read -e -p "请输入版本号 [ 格式如 1.35.0 ] :" aria2_new_ver |
|
|
|
[[ -z "${aria2_new_ver}" ]] && echo "取消..." && exit 1 |
|
|
|
else |
|
|
|
echo -e "${Info} 检测到 Aria2 最新版本为 [ ${aria2_new_ver} ]" |
|
|
|
fi |
|
|
|
else |
|
|
|
echo -e "${Info} 即将准备下载 Aria2 版本为 [ ${aria2_new_ver} ]" |
|
|
|
echo -e "${Error} Aria2 最新版本获取失败,请手动获取最新版本号[ https://github.com/P3TERX/aria2-builder/releases ]" |
|
|
|
read -e -p "请输入版本号:" aria2_new_ver |
|
|
|
[[ -z "${aria2_new_ver}" ]] && echo "取消..." && exit 1 |
|
|
|
#else |
|
|
|
# echo -e "${Info} 检测到 Aria2 最新版本为 [ ${aria2_new_ver} ]" |
|
|
|
fi |
|
|
|
#else |
|
|
|
# echo -e "${Info} 即将准备下载 Aria2 版本为 [ ${aria2_new_ver} ]" |
|
|
|
#fi |
|
|
|
} |
|
|
|
check_ver_comparison() { |
|
|
|
aria2_now_ver=$(${aria2c} -v | head -n 1 | awk '{print $3}') |
|
|
|
[[ -z ${aria2_now_ver} ]] && echo -e "${Error} Aria2 当前版本获取失败 !" && exit 1 |
|
|
|
if [[ "${aria2_now_ver}" != "${aria2_new_ver}" ]]; then |
|
|
|
echo -e "${Info} 发现 Aria2 已有新版本 [ ${aria2_new_ver} ](当前版本:${aria2_now_ver})" |
|
|
|
read -e -p "是否更新(会中断当前下载任务,请注意) ? [Y/n] :" yn |
|
|
|
[[ -z "${yn}" ]] && yn="y" |
|
|
|
if [[ $yn == [Yy] ]]; then |
|
|
|
check_pid |
|
|
|
[[ ! -z $PID ]] && kill -9 ${PID} |
|
|
|
check_sys |
|
|
|
Download_aria2 "update" |
|
|
|
Start_aria2 |
|
|
|
fi |
|
|
|
else |
|
|
|
echo -e "${Info} 当前 Aria2 已是最新版本 [ ${aria2_new_ver} ]" && exit 1 |
|
|
|
#aria2_now_ver=$(${aria2c} -v | head -n 1 | awk '{print $3}') |
|
|
|
#[[ -z ${aria2_now_ver} ]] && echo -e "${Error} Aria2 当前版本获取失败 !" && exit 1 |
|
|
|
#if [[ "${aria2_now_ver}" != "${aria2_new_ver}" ]]; then |
|
|
|
# echo -e "${Info} 发现 Aria2 已有新版本 [ ${aria2_new_ver} ](当前版本:${aria2_now_ver})" |
|
|
|
read -e -p "是否更新(会中断当前下载任务) ? [Y/n] :" yn |
|
|
|
[[ -z "${yn}" ]] && yn="y" |
|
|
|
if [[ $yn == [Yy] ]]; then |
|
|
|
check_pid |
|
|
|
[[ ! -z $PID ]] && kill -9 ${PID} |
|
|
|
check_sys |
|
|
|
Download_aria2 "update" |
|
|
|
Start_aria2 |
|
|
|
fi |
|
|
|
#else |
|
|
|
# echo -e "${Info} 当前 Aria2 已是最新版本 [ ${aria2_new_ver} ]" && exit 1 |
|
|
|
#fi |
|
|
|
} |
|
|
|
Download_aria2() { |
|
|
|
update_dl=$1 |
|
|
@ -132,7 +132,7 @@ Download_aria2() { |
|
|
|
} | tar -zx |
|
|
|
[[ ! -s "aria2c" ]] && echo -e "${Error} Aria2 下载失败 !" && exit 1 |
|
|
|
[[ ${update_dl} = "update" ]] && rm -f "${aria2c}" |
|
|
|
mv aria2c /usr/local/bin |
|
|
|
mv -f aria2c "${aria2c}" |
|
|
|
[[ ! -e ${aria2c} ]] && echo -e "${Error} Aria2 主程序安装失败!" && exit 1 |
|
|
|
chmod +x ${aria2c} |
|
|
|
echo -e "${Info} Aria2 主程序安装完成!" |
|
|
|