这篇博文记录了我创建了一个自动安装中国体育彩票开奖云端硬盘并将aria2的下载文件同步到中国体育彩票开奖云端硬盘的特定文件夹的过程。

Run Aria2+AriaNG 码头工人

关于docker命令及其用法,请访问以下文章: //blog.fabiandinkins.com/2020/04/docker-usage.html

Commands to install 码头工人 上 CentOS, Ubuntu.

[email protected]:/# curl -sSL //get.docker.com/ | sh

systemctl start docker
systemctl enable docker
Commands to run Aria2-ariang docker

docker run -d -i --restart=always --name ariang -p 8000:80  -p 6800:6800 -v ~/data/:/data -v /home/gdrive/:/gdrive wahyd4/aria2-ariang

请确保您的VPS打开了这两个端口:8000和6800已打开Internet。

Mapping more ports out:
docker run -d -i –restart = always –name ariang -p 8000: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:

[[email protected] ~]# docker exec -it ariang /bin/bash
bash-4.3# cp -R conf /data
bash-4.3# ls
conf
bash-4.3# exit
exit
[[email protected] ~]# 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
[[email protected] ~]# docker kill d82418f696a3
d82418f696a3
[[email protected] ~]# docker rm d82418f696a3
d82418f696a3
[[email protected] ~]# ls
data
[[email protected] ~]# cd data
[[email protected] 数据]# ls
conf
[[email protected] 数据]# mv conf ~/
[[email protected] 数据]# cd ..
[[email protected] ~]# ls
conf  data
[[email protected] ~]# 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
[[email protected] ~]#


输入docker以更改aria2服务的配置。

docker exec -it ariang /bin/bash
Inside the docker, create a shell script , rcloneupload.sh,with following code:
bash-4.3#vi rcloneupload.sh
#!/bin/bash

GID="$1";
FileNum="$2";
File="$3";
MinSize="5"  #限制最低上传大小,默认5k
MaxSize="157286400"  #限制最高文件大小(单位k),默认15G
RemoteDIR="/gdrive/";  #rclone挂载的本地文件夹,最后面保留/
LocalDIR="/data/";  #Aria2下载目录,最后面保留/

if [[ -z $(echo "$FileNum" |grep -o '[0-9]*' |head -n1) ]]; then FileNum='0'; fi
if [[ "$FileNum" -le '0' ]]; then exit 0; fi
if [[ "$#" != '3' ]]; then exit 0; fi

function LoadFile(){
  IFS_BAK=$IFS
  IFS=$'\n'
  if [[ ! -d "$LocalDIR" ]]; then return; fi
  if [[ -e "$File" ]]; then
    FileLoad="${File/#$LocalDIR}"
    while true
      do
        if [[ "$FileLoad" == '/' ]]; then return; fi
        echo "$FileLoad" |grep -q '/';
        if [[ "$?" == "0" ]]; then
          FileLoad=$(dirname "$FileLoad");
        else
          break;
        fi;
      done;
    if [[ "$FileLoad" == "$LocalDIR" ]]; then return; fi
    EXEC="$(command -v mv)"
    if [[ -z "$EXEC" ]]; then return; fi
    Option=" -f";
    cd "$LocalDIR";
    if [[ -e "$FileLoad" ]]; then
      ItemSize=$(du -s "$FileLoad" |cut -f1 |grep -o '[0-9]*' |head -n1)
      if [[ -z "$ItemSize" ]]; then return; fi
      if [[ "$ItemSize" -le "$MinSize" ]]; then
        echo -ne "\033[33m$FileLoad \033[0mtoo small to spik.\n";
        return;
      fi
      if [[ "$ItemSize" -ge "$MaxSize" ]]; then
        echo -ne "\033[33m$FileLoad \033[0mtoo large to spik.\n";
        return;
      fi
      eval "${EXEC}${Option}" \'"${FileLoad}"\' "${RemoteDIR}";
    fi
  fi
  IFS=$IFS_BAK
}
LoadFile;
make file become executable: chmod +x rcloneupload.sh
Edit Aria2 configuration file (/root/conf/aria2.conf) to add 上e line at the file end:配置文件中加上一行上-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:您希望的时间量和上载/下载比率
#种子到。如果达到了时间限制(秒)或种子比率,
#种子种子将停止。您可以将种子时间设置为零(0)以禁用
# seeding completely.
 seed-ratio=0.01
 seed-time=1

//gist.github.com/rudylacrete/dcd9779175fe18731852

从docker退出到主机服务器。重启docker ariang:
码头工人 restart ariang

Install Rclone

First to install epel source
  1. yum -y install epel-release
Install some components
  1. yum -y install wget unzip screen fuse fuse-devel
安装rclone
  1. [[email protected] 数据]# curl //rclone.org/install.sh | sudo bash


configure rclone
  1. rclone config
第一步是选择n,然后选择一个名称,在我的情况下为google-drive
  1. No remotes found - make a new 上e
  2. n) New remote
  3. s) Set configuration password
  4. q) Quit config
  5. n/s/q> n
  6. name> google-drive
choose 13 for your storage 
  1. Type of storage to configure.
  2. Enter a string value. Press Enter for the default ("").
  3. Choose a number from below, or type in your own value
  4. 1 / 1Fichier \ "fichier" 2 / Alias for an existing remote \ "alias" 3 / Amazon Drive \ "amazon cloud drive" 4 / Amazon S3 Compliant Storage Provider (AWS, Alibaba, Ceph, Digital Ocean, Dreamhost, IBM COS, Minio, etc) \ "s3" 5 / Backblaze B2 \ "b2" 6 / Box \ "box" 7 / Cache a remote \ "cache" 8 / Citrix Sharefile \ "sharefile" 9 / Dropbox \ "dropbox" 10 / Encrypt/Decrypt a remote \ "crypt" 11 / FTP Connection \ "ftp" 12 / 中国体育彩票开奖 云 Storage (this is not 中国体育彩票开奖 Drive) \ "google cloud storage" 13 / 中国体育彩票开奖 Drive \ "drive" 14 / 中国体育彩票开奖 Photos \ "google photos"
  5. Storage> 13
只需按Enter键即可获取中国体育彩票开奖 Application Client ID和client_secret
  1. 中国体育彩票开奖 Application Client Id
  2. Leave blank normally.
  3. Enter a string value. Press Enter for the default ("").
  4. client_id>
  5. 中国体育彩票开奖 Application Client Secret
  6. Leave blank normally.
  7. Enter a string value. Press Enter for the default ("").
  8. client_secret>
chosse 1 for your access to your drive
  1. Scope that rclone should use when requesting access from drive.
  2. Enter a string value. Press Enter for the default ("").
  3. Choose a number from below, or type in your own value
  4. 1 / Full access all files, excluding Application Data Folder.
  5. \ "drive"
  6. 2 / Read-上ly access to file metadata and file contents.
  7. \ "drive.readonly"
  8. / Access to files created by rclone 上ly.
  9. 3 | These are visible in the drive website.
  10. | File authorization is revoked when the user deauthorizes the app.
  11. \ "drive.file"
  12. / Allows read and write access to the Application Data folder.
  13. 4 | This is not visible in the drive website.
  14. \ "drive.appfolder"
  15. / Allows read-上ly access to file metadata but
  16. 5 | does not allow any access to read or download file content.
  17. \ "drive.metadata.readonly"
  18. scope> 1
至于您的文件夹ID和JSON服务帐户文件,请按Enter以使用默认值。 
  1. ID of the root folder
  2. Leave blank normally.
  3. Fill in to access "Computers" folders. (see docs).
  4. Enter a string value. Press Enter for the default ("").
  5. root_folder_id>
  6. Service Account Credentials JSON file path
  7. Leave blank normally.
  8. Needed 上ly if you want use SA instead of interactive login.
  9. Enter a string value. Press Enter for the default ("").
  10. service_account_file>
 N for advanced config.
  1. Edit advanced config? (y/n)
  2. y) Yes
  3. n) No
  4. y/n> n
Since we are working 上 a remote, n for auto config.
  1. Remote config
  2. Use auto config?
  3. * Say Y if not sure
  4. * Say N if you are working 上 a remote or headless machine
  5. y) Yes
  6. n) No
  7. y/n> n
您将必须复制链接以登录到您的中国体育彩票开奖帐户,以获得身份验证码:
  1. If your browser doesn't open automatically go to the following link: //accounts.google.com/o/oauth2/auth?access_type=offline&client_id=202264815644.apps.googleusercontent.com&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&response_type=code&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive&state=55663e7e07382e3dddb9025c86de4f
  2. Log in and authorize rclone for access
  3. Enter verification code> 4/UQGiRz375eb-OixO5EUtZMxBhJwAQ4zOyvA1wtJWKq2Ocmzh3zNYE
n for team drive. 
  1. Configure this as a team drive?
  2. y) Yes
  3. n) No
  4. y/n> n
 y to confirm your config
  1. --------------------
  2. [google-drive]
  3. type = drive
  4. scope = drive
  5. token = {"access_token":"ya29.GlsQByNiBURlXoPpe-bDpa2kF99Jo4rrmjicBXdWIT6loPUhS7S_zpUwHn6no0Y_LBbXYFZvyVf0gRthepF2VuPFdhBFEKY7XYJaelt","token_type":"Bearer","refresh_token":"1/ry1JGhRiqqE6-PqRN-S2icZ_Oz9uOTXfSNxWA85zUnj-6TejL6o-hjyuY","expiry":"2019-05-21T04:36:23.300542043-04:00"}
  6. --------------------
  7. y) Yes this is OK
  8. e) Edit this remote
  9. d) Delete this remote
  10. y/e/d> y
q退出。
  1. Current remotes:
  2.  
  3. Name Type
  4. ==== ====
  5. google-drive drive
  6.  
  7. e) Edit existing remote
  8. n) New remote
  9. d) Delete remote
  10. r) Rename remote
  11. c) Copy remote
  12. s) Set configuration password
  13. q) Quit config
  14. e/n/d/r/c/s/q> q
We finished the basic rclone config. 

现在我们需要挂载 将中国体育彩票开奖云端硬盘转换为VPS,即使重新启动,它仍会自动挂载中国体育彩票开奖云端硬盘
create a new folder at /home/gdrive
  1. mkdir -p /home/gdrive
挂载系统
  1. rclone mount google-drive: /home/gdrive --allow-other --allow-non-empty --vfs-cache-mode writes
google-drive is the Rclone configuration name.
You also can define a sub folder name:
  1. rclone mount google-drive:backup /home/gdrive --allow-other --allow-non-empty --vfs-cache-mode writes
google-drive:备份google-drive为Rclone的配置名称:backup为网盘里的目录名
卸载中国体育彩票开奖云端硬盘 – ssh会话中最简单的方法是ctrl + c
  1. fusermount -qzu /home/gdrive

[[email protected] 数据]# rclone ls google-drive:/
    33196 3916278.html
 1036266 69bbca83ly1gdr8plweo5g209e09yx6b.gif
       42 test.test

坐骑动作通常需要几秒钟。您可以打开第二个ssh会话进行检查。 
  1. [[email protected] ~]$ df -h Filesystem Size Used Avail Use% Mounted 上 devtmpfs 462M 0 462M 0% /dev tmpfs 494M 0 494M 0% /dev/shm tmpfs 494M 14M 481M 3% /run tmpfs 494M 0 494M 0% /sys/fs/cgroup /dev/sda3 39G 3.2G 35G 9% / /dev/sda1 512M 12M 501M 3% /boot/efi tmpfs 99M 0 99M 0% /run/user/1000 google-drive: 15G 1.2G 14G 8% /home/gdrive
To unmount, simply press “Ctrl + c” to stop the mount.
要使rclone挂载google驱动器,甚至在重新启动vps之后,请创建 /usr/lib/systemd/system/rclone.service with following information:
vi /usr/lib/systemd/system/rclone.service
  1. [Unit]
  2. Description=rclone
  3.  
  4. [Service]
  5. User=root
  6. ExecStart=/usr/bin/rclone mount google-drive: /home/gdrive --allow-other --allow-non-empty --vfs-cache-mode writes
  7. Restart=-abort
  8.  
  9. [Install]
  10. WantedBy=multi-user.target

systemctl start rclone
systemctl enable rclone
您还只能通过更改文件/root/.config/rclone/rclone.conf中的root_folder_id将其安装到中国体育彩票开奖云端硬盘的某些文件夹
[[email protected] rclone]# cat rclone.conf
[谷歌驱动器]
类型=驱动器
范围=驱动器
标记= {“ACCESS_TOKEN”:” ya29.a0Ae4lvC3NjPpY5EmltR-TaIh2_I3et3TqsXxbr73XnS0Gj19zalB4xke2FXosB8kThTG8akkjqc94ZjOoY8sLOokoxZf26YrUf04F14abUGRaGZTWznSGB”,” token_type”:”承载”,” refresh_token”:” 1 // 0fqzXgAuJUWU2CgYIARAGA8SNwF-L9IrsitYDMEfAeJgOutDZV7OyqaWLjeoaj9mDw-E-4beZlwucBY8Br32tQM5cXFl7BnyLo”,”有效期”:” 2020-05-08T20 :00:53.118819799Z”}
root_folder_id = 1lMF61yERYbDDjV86VmxQk0mJjwBwCH
一些注意事项:
把文件上传到 中国体育彩票开奖 Drive
为什么不直接把文件目录设置成挂载目录?如果直接把文件目录指定到挂载目录,会出现各种莫名其妙的错误,则:文件无法写入,读取,保存到Googlr Drive的文件不完整等等奇葩的问题。这里可以用同步命令,本地目录/home/backup 同步到网盘的 backup 目录
  1. rclone sync /home/backup gdrive:backup
相反,把目录调整下,就是把网盘 backup 目录同步到 VPS 目录/home/backup
  1. rclone sync gdrive:backup /home/backup
通过添加此参数 –ignore-existing 可以忽略在网盘上已备份的文件,这相当于增量备份
  1. rclone copy --ignore-existing /home/backup gdrive:backup
如果挂载2个网盘的话,可以同步配置名gd2的网盘里的备份目录,到配置名为gd的网盘的备份目录,反之亦然
  1. rclone sync gdrive2:backup gdrive:backup

Command outputs


    1. [[email protected] 数据]# curl //rclone.org/install.sh | sudo bash .... rclone v1.51.0 has successfully installed. Now run "rclone config" for setup. Check //rclone.org/docs/ for more details. [[email protected] 数据]# rclone config 2020/05/05 22:02:56 NOTICE: Config file "/root/.config/rclone/rclone.conf" not found - using defaults No remotes found - make a new 上e n) New remote s) Set configuration password q) Quit config n/s/q> n name> google-drive Type of storage to configure. Enter a string value. Press Enter for the default (""). Choose a number from below, or type in your own value 1 / 1Fichier \ "fichier" .... 11 / FTP Connection \ "ftp" 12 / 中国体育彩票开奖 云 Storage (this is not 中国体育彩票开奖 Drive) \ "google cloud storage" 13 / 中国体育彩票开奖 Drive \ "drive" 14 / 中国体育彩票开奖 Photos \ "google photos" 15 / Hubic \ "hubic" .... Storage> 13 ** See help for drive backend at: //rclone.org/drive/ ** 中国体育彩票开奖 Application Client Id Setting your own is recommended. See //rclone.org/drive/#making-your-own-client-id for how to create your own. If you leave this blank, it will use an internal key which is low performance. Enter a string value. Press Enter for the default (""). client_id> 中国体育彩票开奖 Application Client Secret Setting your own is recommended. Enter a string value. Press Enter for the default (""). client_secret> Scope that rclone should use when requesting access from drive. Enter a string value. Press Enter for the default (""). Choose a number from below, or type in your own value 1 / Full access all files, excluding Application Data Folder. \ "drive" 2 / Read-only access to file metadata and file contents. \ "drive.readonly" / Access to files created by rclone 上ly. 3 | These are visible in the drive website. | File authorization is revoked when the user deauthorizes the app. \ "drive.file" / Allows read and write access to the Application Data folder. 4 | This is not visible in the drive website. \ "drive.appfolder" / Allows read-only access to file metadata but 5 | does not allow any access to read or download file content. \ "drive.metadata.readonly" scope> 1 ID of the root folder Leave blank normally. Fill in to access "Computers" folders (see docs), or for rclone to use a non root folder as its starting point. Note that if this is blank, the first time rclone runs it will fill it in with the ID of the root folder. Enter a string value. Press Enter for the default (""). root_folder_id> Service Account Credentials JSON file path Leave blank normally. Needed 上ly if you want use SA instead of interactive login. Enter a string value. Press Enter for the default (""). service_account_file> Edit advanced config? (y/n) y) Yes n) No (default) y/n> n Remote config Use auto config? * Say Y if not sure * Say N if you are working 上 a remote or headless machine y) Yes (default) n) No y/n> n Please go to the following link: //accounts.google.com/o/oauth2/auth?access_type=offline&client_id=202264815644.apps.googleusercontent.com&redirect_uri=urn%3Aietf%3Awg%3Aoath%3A2.0%3Aoob&response_type=code&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive&state=wxylrgDHf7QnNy5zetieg Log in and authorize rclone for access Enter verification code> 4/zQEAebNYt68Rj1k2ckWuffBaL35WqVd-rJhf4AiCSU5MTqn-O_4ao Configure this as a team drive? y) Yes n) No (default) y/n> n -------------------- [google-drive] type = drive scope = drive token = {"access_token":"ya29.a0Ae4lvC1R7463egrz5gGDGFAwjA2elNfSs0T325er5U0FBHgw_B2pZSipzP9CXBjidavMM_cOHSm1MzRS5jxIL3wlFoXzj3eC2xcAWzJvlchzM95wOxoO6YRzu8j175S1DthpJwr6Zt_tR7Dg","token_type":"Bearer","refresh_token":"1//0fqzXgAuJUWU2CgYIRAAGA8SNwF-L9IrsitYDMEfAeJgOutDV7OyqaWLjeoaj9mDw-e-4beZlwucBY8Br32tQM5cXFl7enyLo","expiry":"2020-05-05T23:14:12.28655445Z"} -------------------- y) Yes this is OK (default) e) Edit this remote d) Delete this remote y/e/d> y Current remotes: Name Type ==== ==== google-drive drive e) Edit existing remote n) New remote d) Delete remote r) Rename remote c) Copy remote s) Set configuration password q) Quit config e/n/d/r/c/s/q> q [[email protected] /]# mkdir -p /home/gdrive [[email protected] /]# rclone mount google-drive: /home/gdrive --allow-other --allow-non-empty --vfs-cache-mode writes 2020/05/05 22:15:48 Fatal error: failed to mount FUSE fs: fusermount: exec: "fusermount": executable file not found in $PATH [[email protected] /]# yum install fuse Install 1 Package Total download size: 86 k Installed size: 218 k Is this ok [y/d/N]: y Downloading packages: fuse-2.9.2-11.el7.x86_64.rpm | 86 kB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : fuse-2.9.2-11.el7.x86_64 1/1 Verifying : fuse-2.9.2-11.el7.x86_64 1/1 Installed: fuse.x86_64 0:2.9.2-11.el7 Complete! [[email protected] /]# rclone mount google-drive: /home/gdrive --allow-other --allow-non-empty --vfs-cache-mode writes

    通过 约翰扬

    发表评论