Run Aria2+AriaNG Docker
Regarding docker commands and usage, please visit post: https://blog.51sec.org/2020/04/docker-usage.html
Commands to install Docker on CentOS, Ubuntu.
root@linux:/# curl -sSL https://get.docker.com/ | sh
systemctl start docker
systemctl enable docker
systemctl enable docker
Commands to run Aria2-ariang docker
docker run -d -i --restart=always --name ariang -p 8080:80 -p 6800:6800 -v ~/data/:/data -v /home/gdrive/:/gdrive wahyd4/aria2-ariang
Mapping more ports out:
docker run -d -i --restart=always --name ariang -p 8080:80 -p 6800:6800 -p 6881-6999:6881-6999 -p 6881-6999:6881-6999/udp -v ~/data/:/data -v /home/gdrive/:/gdrive wahyd4/aria2-ariang
Mapping conf folder to host:
Enter into docker to make configuration change for aria2 service.
bash-4.3# cd /root/conf/
bash-4.3# ls
aria2.conf aria2.session aria2c.sh key
bash-4.3# vi aria2.conf
[root@cenos1-download ~]# docker exec -it ariang /bin/bash
bash-4.3# cp -R conf /data
bash-4.3# ls
conf
bash-4.3# exit
exit
[root@cenos1-download ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d82418f696a3 wahyd4/aria2-ariang "/bin/sh /root/conf/…" 3 minutes ago Up 3 minutes 443/tcp, 0.0.0.0:6800->6800/tcp, 0.0.0.0:8000->80/tcp ariang
[root@cenos1-download ~]# docker kill d82418f696a3
d82418f696a3
[root@cenos1-download ~]# docker rm d82418f696a3
d82418f696a3
[root@cenos1-download ~]# ls
data
[root@cenos1-download ~]# cd data
[root@cenos1-download data]# ls
conf
[root@cenos1-download data]# mv conf ~/
[root@cenos1-download data]# cd ..
[root@cenos1-download ~]# ls
conf data
[root@cenos1-download ~]# docker run -d -i --restart=always --name ariang -p 8000:80 -p 6800:6800 -v ~/conf/:/root/conf -v ~/data/:/data -v /home/gdrive/:/gdrive wahyd4/aria2-ariang
f6711085e4209239f075c9f915ffee14b04e853b376f6ac5d54b3a615129d367
[root@cenos1-download ~]#
docker exec -it ariang /bin/bash
Inside the docker, create a shell script ,
rcloneupload.sh
,with following code:
bash-4.3#vi rcloneupload.sh
make file become executable:
chmod +x rcloneupload.sh
Edit
Aria2 configuration file (/root/conf/aria2.conf) to add one line at the file end:
配置文件中加上一行on-download-complete=/root/rcloneupload.sh
即可,后面为脚本的路径。最后重启Aria2
生效。bash-4.3# cd /root/conf/
bash-4.3# ls
aria2.conf aria2.session aria2c.sh key
bash-4.3# vi aria2.conf
# Bit Torrent: The amount of time and the upload-to-download ratio you wish to
# seed to. If either the time limit ( seconds ) or the seed ratio is reached,
# torrent seeding will stop. You can set seed-time to zero(0) to disable
# seeding completely.
seed-ratio=0.01
seed-time=1
https://gist.github.com/rudylacrete/dcd9779175fe18731852
# seed to. If either the time limit ( seconds ) or the seed ratio is reached,
# torrent seeding will stop. You can set seed-time to zero(0) to disable
# seeding completely.
seed-ratio=0.01
seed-time=1
https://gist.github.com/rudylacrete/dcd9779175fe18731852
Exit from docker to host server. Reboot docker ariang:
Docker restart ariang
Install Rclone
First to install epel source
Install some components
Install rclone
configure rclone
first step is to choose n, then pick a name, which is google-drive in my case
choose 13 for your storage
just press enter for Google Application Client ID and client_secret
chosse 1 for your access to your drive
as to your folder id and json service account file, press enter to use default vaule.
N for advanced config.
Since we are working on a remote, n for auto config.
You will have to copy the link to log in to your Google account to get auth verification code:
n for team drive.
y to confirm your config
q to exit.
We finished the basic rclone config.
Now we will need to mount Google Drive to VPS and even it rebooted, it will still auto-mount Google Drive
create a new folder at /home/gdrive
mount system
google-drive is the Rclone configuration name.
You also can define a sub folder name:
google-drive:backup google-drive 为 Rclone 的配置名称:backup 为网盘里的目录名
unmount Google Drive - easiest way in a ssh session is to ctrl+c
[root@centos7-test1 data]# rclone ls google-drive:/
33196 3916278.html
1036266 69bbca83ly1gdr8plweo5g209e09yx6b.gif
42 test.test
Mount action usually take a couple seconds. You can open a second ssh session to check.
To unmount, simply press “CTRL+c” to stop the mount.
To make rclone mount the google drive even after rebooted the vps, create /usr/lib/systemd/system/rclone.service with following information:
vi /usr/lib/systemd/system/rclone.service
vi /usr/lib/systemd/system/rclone.service
systemctl start rclone
systemctl enable rclone
You also can only mount to Google Drive certain folder by changing root_folder_id at the file /root/.config/rclone/rclone.conf
[root@centos7-test1 rclone]# cat rclone.conf
[google-drive]
type = drive
scope = drive
token = {"access_token":"ya29.a0Ae4lvC3NjPpY5EmltR-TaIh2_I3et3TqsXxbr73XnS0Gj19zalB4xke2FXosB8kThTG8akkjqc94ZjOoY8sLOokoxZf26YrUf04F14abUGRaGZTWznSGB","token_type":"Bearer","refresh_token":"1//0fqzXgAuJUWU2CgYIARAGA8SNwF-L9IrsitYDMEfAeJgOutDZV7OyqaWLjeoaj9mDw-e-4beZlwucBY8Br32tQM5cXFl7BnyLo","expiry":"2020-05-08T20:00:53.118819799Z"}
root_folder_id = 1lMF61yERYbDDjV86VmxQk0mJjwBwCH
For root_folder_id, you can find it from the drive folder's url:Notes for Rclone Usage
把文件上传到 Google Drive
为什么不直接把文件目录设置成挂载目录?如果直接把文件目录指定到挂载目录,会出现各种莫名其妙的错误,比如:文件无法写入、读取、保存到 Googlr Drive 的文件不完整等等奇葩的问题。这里可以用同步命令,本地目录/home/backup 同步到网盘的 backup 目录
相反,把目录调整下,就是把网盘 backup 目录同步到 VPS 目录/home/backup
通过添加此参数 --ignore-existing 可以忽略在网盘上已备份的文件,这相当于增量备份
如果挂载 2 个网盘的话,可以同步配置名 gd2 的网盘里的 backup 目录,到配置名为 gd 的网盘的 backup 目录,反之亦然
No comments:
Post a Comment