#!/bin/bash # #*************************************************************************** # Author: liwanggui # Email: liwanggui@163.com # Date: 2023-04-17 # FileName: install-aria2.sh # Description: This is a test script # Copyright (C): 2023 All rights reserved #*************************************************************************** # CONFIG_DIR=/etc/aria2 CONFIG_NAME=${CONFIG_DIR}/aria2.conf LOG_DIR=/var/log/aria2 DL_DIR=/opt/download config_aria2 () { local flag=n [ -d $CONFIG_DIR ] || mkdir $CONFIG_DIR [ -d $LOG_DIR ] || mkdir $LOG_DIR [ -f ${CONFIG_DIR}/aria2.session ] || touch ${CONFIG_DIR}/aria2.session if [ -f $CONFIG_NAME ]; then echo "Warring: The aria2 configuration already exists. ($CONFIG_NAME)" read -p "overwrite the original configuration? [Y/N]" flag if [[ $flag == "n" ]] || [[ $flag == "N" ]]; then echo "Abort!" exit 1 fi mv $CONFIG_NAME ${CONFIG_NAME}-bak-$(date '+%Y%m%d%H%M%S') fi cat >$CONFIG_NAME</lib/systemd/system/aria2.service</dev/null; then install_bin=apt elif command -v yum &>/dev/null; then install_bin=yum rpm -q epel-release >/dev/null || yum install -yq epel-release fi if [[ -z $install_bin ]]; then echo "Error: the current system is not supported." exit 1 fi command -v aria2c &>/dev/null || $install_bin install -y aria2 config_aria2 } main