#!/bin/bash
killall aria2c
ariaconf=/etc/aria2/aria2.conf
if [ ! -e ${ariaconf} ];then
	echo cannot found aria2 config file,stop update.
	exit 1
fi

list=`wget -qO- https://raw.githubusercontent.com/ngosang/trackerslist/master/trackers_all.txt|awk NF|sed ":a;N;s/\n/,/g;ta"`
if [ -z "`grep "bt-tracker" ${ariaconf}`" ]; then
	sed -i '$a bt-tracker='${list} ${ariaconf}
	echo add......
else
	sed -i "s@bt-tracker.*@bt-tracker=$list@g" ${ariaconf}
	echo update......
fi
service aria2c start
