美文网首页Linux的小折腾
Centos, Ubuntu, Debian安装aria2

Centos, Ubuntu, Debian安装aria2

作者: 请叫我雯子小姐的小爷 | 来源:发表于2019-05-09 21:15 被阅读10次

本文中的代码部分有乱码情况,请点击此链接点击查看,或者关注微信公众号‘微电脑’查看。

#!/bin/bash
date=`date`
start_t=`date +%s`
echo "
+----------------------------------------------------------------------
| Automatic installation of the aria2
+----------------------------------------------------------------------
| Author: Rui Ma  E-mail: marui_06@outlook.com
+----------------------------------------------------------------------
| aria2 install
+----------------------------------------------------------------------
"
### 得到Linux的发行版本
Release=$(cat /etc/*-release | grep "ID"| grep -v "ID_LIKE" | grep -v "VERSION_ID" | grep -v "DISTRIB_ID" | sed -r 's/.*"(.+)".*/\1/')
Version=$(cat /etc/*-release | grep "VERSION_ID" | sed -r 's/.*"(.+)".*/\1/')

function centos7(){
        yum -y install wget
        yum -y install curl
        yum -y install epel-release
        yum -y install aria2
}
function releases(){  ### 编译安装 ### 如果安装失败可使用此方法进行安装
        sudo -s <<EOF
        wget https://github.com/aria2/aria2/releases/download/release-1.33.1/aria2-1.33.1.tar.bz2
        tar -jxv -f aria2-1.33.1.tar.bz2
        cd aria2-1.33.1
        ./configure
        make
        cd src
        cp aria2c /usr/local/bin
EOF
}

function ubuntu(){
        sudo -s <<EOF
        apt-get -y install wget
        apt-get -y install curl
        apt-get -y install aria2
EOF
}
function config(){
        mkdir -p ~/.aria2
        mkdir -p ~/aria2_download
        touch ~/.aria2/aria2.session
        touch ~/.aria2/aria2.log
        echo "## '#'开头为注释内容, 选项都有相应的注释说明, 根据需要修改 ##
## 被注释的选项填写的是默认值, 建议在需要修改时再取消注释  ##

## 文件保存相关 ##

# 文件的保存路径(可使用绝对路径或相对路径), 默认: 当前启动位置
dir=~/aria2_download/
# 启用磁盘缓存, 0为禁用缓存, 需1.16以上版本, 默认:16M
disk-cache=32M
# 文件预分配方式, 能有效降低磁盘碎片, 默认:prealloc
# 预分配所需时间: none < falloc ? trunc < prealloc
# falloc和trunc则需要文件系统和内核支持
# NTFS建议使用falloc, EXT3/4建议trunc, MAC 下需要注释此项
file-allocation=none
# 断点续传
continue=true

## 下载连接相关 ##

# 最大同时下载任务数, 运行时可修改, 默认:5
max-concurrent-downloads=10
# 同一服务器连接数, 添加时可指定, 默认:1
max-connection-per-server=5
# 最小文件分片大小, 添加时可指定, 取值范围1M -1024M, 默认:20M
# 假定size=10M, 文件为20MiB 则使用两个来源下载; 文件为15MiB 则使用一个来源下载
min-split-size=10M
# 单个任务最大线程数, 添加时可指定, 默认:5
split=20
# 整体下载速度限制, 运行时可修改, 默认:0
#max-overall-download-limit=0
# 单个任务下载速度限制, 默认:0
#max-download-limit=0">>~/.aria2/aria2.conf
}
if [[ $Release =~ 'centos' && $Version == 7 ]]
then
        centos7
        #releases
        config
fi
if [[ $Release =~ 'centos' && $Version != 7 ]]
then
        echo "不支持centos6及以下,请安装centos7 ### 未对centos6进行测试,可取消下面注释进行尝试,如未成功请使用编译安装"
        #centos7
        #releases
        #config
fi
if [[ $Release =~ 'ubuntu' ]]
then
        ubuntu
        #releases
        config
fi
if [[ $Release =~ 'debian' ]]
then
        ubuntu
        #releases
        config
fi

echo "
+---------------------------------------------------------------------------------
| Complited!
+---------------------------------------------------------------------------------
| How to use it: 'aria2c -h' or 'man aria2c'
+---------------------------------------------------------------------------------
"

end_t=`date +%s`
((outTime=(end_t-start_t)/60))
echo -e "Time used:\033[32m $outTime \033[0mMinute!"

相关文章

网友评论

    本文标题:Centos, Ubuntu, Debian安装aria2

    本文链接:https://www.haomeiwen.com/subject/uvzgoqtx.html