forked from P3TERX/aria2.conf
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
P3TERX
committed
Oct 23, 2019
1 parent
c5bdc63
commit 8ce8195
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/bash | ||
#================================================= | ||
# Description: Get trackers and add to aria2.conf | ||
# Lisence: MIT | ||
# Version: 1.0 | ||
# Author: P3TERX | ||
# Blog: https://p3terx.com | ||
#================================================= | ||
INFO="[\033[32mINFO\033[0m]" | ||
ERROR="[\033[31mERROR\033[0m]" | ||
echo && echo -e "$INFO Get trackers ..." | ||
aria2_conf=${1:-aria2.conf} | ||
tracker=$(curl -fLs https://raw.githubusercontent.com/ngosang/trackerslist/master/trackers_all.txt | awk NF | sed ":a;N;s/\n/,/g;ta") | ||
[ -z $tracker ] && echo -e " | ||
$ERROR Unable to get trackers, network failure or invalid links." && exit 1 | ||
echo -e " | ||
--------------------[TRACKERS]-------------------- | ||
${tracker} | ||
--------------------[TRACKERS]-------------------- | ||
" | ||
[ ${aria2_conf} == "cat" ] && exit 0 | ||
echo -e "$INFO Adding trackers to '${aria2_conf}' ..." && echo | ||
if [ ! -f ${aria2_conf} ]; then | ||
echo -e "$ERROR '${aria2_conf}' does not exist." | ||
exit 1 | ||
else | ||
[ -z $(grep "bt-tracker=" ${aria2_conf}) ] && echo "bt-tracker=" >>${aria2_conf} | ||
sed -i "s@^\(bt-tracker=\).*@\1${tracker}@" ${aria2_conf} && echo -e "$INFO Trackers added successfully!" | ||
fi |