-
-
Save akaxxi/15f421d00f17447b94f90fbd5d44bf72 to your computer and use it in GitHub Desktop.
#!/bin/sh | |
DOWNLOAD_DIR="${HOME}/MiniDLNA" | |
CONFIG_DIR="${HOME}/.aria2" | |
RPC_TOKEN="changeIt" | |
RPC_PORT="6800" | |
change_apt_source(){ | |
if [ -f /etc/apt/sources.list ]; then | |
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak | |
fi | |
sudo sed -i '/^deb.*/s/^/# /g' /etc/apt/sources.list | |
sudo chmod 666 /etc/apt/sources.list | |
sudo echo "deb http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ jessie main non-free contrib" >> /etc/apt/sources.list | |
sudo echo "deb-src http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ jessie main non-free contrib" >> /etc/apt/sources.list | |
sudo chmod 644 /etc/apt/sources.list | |
} | |
# change_apt_source | |
sudo apt-get update | |
sudo apt-get install -y aria2 ca-certificates | |
if [ ! -d ${DOWNLOAD_DIR} ]; then | |
mkdir -p ${DOWNLOAD_DIR} | |
fi | |
if [ ! -d ${CONFIG_DIR} ]; then | |
mkdir -p ${CONFIG_DIR} | |
fi | |
if [ ! -f ${CONFIG_DIR}/aria2.session ]; then | |
touch ${CONFIG_DIR}/aria2.session | |
fi | |
if [ ! -f ${CONFIG_DIR}/aria2.log ]; then | |
touch ${CONFIG_DIR}/aria2.log | |
fi | |
if [ -f ${CONFIG_DIR}/aria2.conf ];then | |
mv ${CONFIG_DIR}/aria2.conf ${CONFIG_DIR}/aria2.conf.bak | |
fi | |
# Generate cfg file | |
cat > ${CONFIG_DIR}/aria2.conf <<-EOCFG | |
# For full reference: | |
# https://aria2.github.io/manual/en/html/aria2c.html | |
## | |
dir=${DOWNLOAD_DIR} | |
file-allocation=trunc | |
continue=true | |
# daemon=true | |
## | |
log=${CONFIG_DIR}/aria2.log | |
console-log-level=warn | |
log-level=notice | |
## | |
max-concurrent-downloads=5 | |
max-connection-per-server=10 | |
min-split-size=5M | |
split=10 | |
disable-ipv6=true | |
## | |
input-file=${CONFIG_DIR}/aria2.session | |
save-session=${CONFIG_DIR}/aria2.session | |
save-session-interval=30 | |
## | |
enable-rpc=true | |
rpc-allow-origin-all=true | |
rpc-listen-all=true | |
rpc-listen-port=${RPC_PORT} | |
rpc-secret=${RPC_TOKEN} | |
## | |
follow-torrent=mem | |
follow-metalink=mem | |
enable-dht6=false | |
peer-id-prefix=-TR2770- | |
user-agent=Transmission/2.77 | |
seed-time=0 | |
#seed-ratio=1.0 | |
bt-seed-unverified=true | |
bt-save-metadata=true | |
EOCFG | |
# MiniDLNA | |
sudo apt-get install -y minidlna | |
sudo cp /etc/minidlna.conf /etc/minidlna.conf.origin | |
sudo sed -i 's#^media_dir=/.*#media_dir='${DOWNLOAD_DIR}'#g' /etc/minidlna.conf | |
sudo sed -i '/#inotify=yes/s/#//g' minidlna.conf #Enable media auto discover | |
sudo sed -i '$a fs.inotify.max_user_watches=65536' /etc/sysctl.conf | |
# aria2-webui on lighttpd | |
sudo apt-get install -y lighttpd unzip | |
wget https://github.com/ziahamza/webui-aria2/archive/master.zip | |
unzip -qu master.zip | |
cd webui-aria2-master/ | |
change_token(){ | |
sed -i '/token:/s/\/\///g' configuration.js | |
sed -i 's/\$YOUR_SECRET_TOKEN\$/'${RPC_TOKEN}'/g' configuration.js | |
} | |
# change_token | |
sudo cp -Rfu . /var/www/html/ | |
cd .. | |
rm -rf webui-aria2-master master.zip | |
echo "Done!" | |
echo "Your Aria2 configuration and log file are in : ${CONFIG_DIR}" | |
echo "Your RPC token is: ${RPC_TOKEN}" | |
echo "Start aria2 with 'aria2c -D' and enjoy!" |
it is works indeed but i should give a little info to noobs like me
after finish message in order to start webui service use this commands
sudo openssl rand -base64 32
it will give you a long key
copy it and use it in this command
aria2c --enable-rpc --rpc-listen-all --rpc-secret="paste here your key and delete quotes" --daemon
after that you can login into webui by typing your raspberry lan ip (192.168.xxx.xxx)
after that in order to use webui open Settings-->Connection Settings
paste your key into "Enter the secret token (optional):" area and hit Save Connection configuration.
You are ready to go :)
will the web ui open when i type 192.168.xxx.xxx:6800 in my browser? if it will, then this script would be very useful.
I'll give it a try right now.
how can I completely reverse the changes made by this script?
a little documentation would help a lot