forked from P3TERX/aria2.conf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tracker.sh
32 lines (32 loc) · 1.32 KB
/
tracker.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/bash
#=================================================
# Description: Get trackers and add to aria2.conf
# Lisence: MIT
# Version: 1.1
# 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}
# https://github.com/ngosang/trackerslist
#tracker=$(wget -qO- https://raw.githubusercontent.com/ngosang/trackerslist/master/trackers_all.txt | awk NF | sed ":a;N;s/\n/,/g;ta")
# https://github.com/XIU2/TrackersListCollection
tracker=$(wget -qO- https://raw.githubusercontent.com/XIU2/TrackersListCollection/master/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