├── .gitattributes ├── .rarreg.key ├── README.md ├── bin ├── compile ├── detect └── release └── rclone.conf /.gitattributes: -------------------------------------------------------------------------------- 1 | * text eol=lf 2 | -------------------------------------------------------------------------------- /.rarreg.key: -------------------------------------------------------------------------------- 1 | put your winrar registration key here 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Heroku-Rclone-21vianet. Heroku-Rclone 世纪互联版 2 | Using Rclone with 21vianet mod and Aria2, even UNRAR easily on Heroku.
3 | 在 Heroku 上轻松运行 Rclone、Aria2,甚至是 UNRAR。 4 | 5 | Only useing Aria2 and dislike command terminal? Try this [Heroku AriaNG 21vianet](https://github.com/xinxin8816/heroku-ariang-21vianet)
6 | 仅仅想用 Aria2 下载并且不喜欢命令行?试试这个 [Heroku-AriaNG 世纪互联版](https://github.com/xinxin8816/heroku-ariang-21vianet) 7 | 8 | ## Deploy 9 | 1. Create new app 10 | 11 | ``` 12 | heroku create myapp -b https://github.com/xinxin8816/heroku-rclone-21vianet.git 13 | heroku git:clone -a myapp 14 | 15 | # or useing existed app 16 | heroku buildpacks:set https://github.com/xinxin8816/heroku-rclone-21vianet.git -a myapp 17 | ``` 18 | 19 | 2. Setup Rclone by following [Rclone Docs](https://rclone.org/docs/), Chinese users can setup with 21vianet patch to connect OneDrive by 21vianet.
20 | You can find your config from there: 21 | 22 | ``` 23 | Windows: %userprofile%\.config\rclone\rclone.conf 24 | Linux: $HOME/.config/rclone/rclone.conf 25 | ``` 26 | Optional: Using service account setup with [Gclone](https://github.com/donwa/gclone) to break Google Drive 750GB limit, or easier connect to folder or Team Drive by destination ID. Create a new folder, such as `/accounts/`, upload your json in it. Open rclone config and edit `service_account_file_path = /app/accounts/` as the json paths. 27 | 28 | Rclone with 21vianet patch and Gclone mod provided by xhuang. 29 | 30 | 3. Go to `myapp` directory, copy `rclone.conf` and winrar registraton key `.rarreg.key` (optional) then commit the change. 31 | 32 | ``` 33 | cd myapp 34 | git add . 35 | git commit -am "add config" 36 | git push heroku master 37 | ``` 38 | 39 | ## Usage 40 | ### Open Terminal 41 | ``` 42 | cd myapp 43 | heroku run bash 44 | # or 45 | heroku run bash --a myapp 46 | ``` 47 | 48 | ### Rclone 49 | Learn more from [Rclone Docs](https://rclone.org/commands/) and [Gclone Docs](https://github.com/donwa/gclone) 50 | 51 | **Upload file to Google Drive** 52 | ``` 53 | # The usual way 54 | rclone -P copy local_dir Google:remote_dirpath 55 | 56 | # The way that like using gclone 57 | rclone -P copy local_dir Google:{Destination_ID} 58 | ``` 59 | `-P` mean print progress in real time 60 | 61 | ### Aria2 62 | Learn more from [Aria2c Docs](http://aria2.github.io/manual/en/html/aria2c.html) 63 | 64 | **Download a file** 65 | ``` 66 | aria2c -x4 http://host/file.rar 67 | ``` 68 | `-x4` mean download using 4 connection 69 | 70 | ### UNRAR 71 | Learn more from [UNRAR Docs](https://pypi.org/project/unrar/) 72 | 73 | **Extract `.rar` or `.zip` Compressed file** 74 | ``` 75 | # To current directory 76 | unrar e file.rar/zip 77 | 78 | # With full path 79 | unrar x file.rar/zip 80 | ``` 81 | 82 | ## Tips 83 | 84 | **Speed up upload** 85 | 86 | If you want to upload many files smaller than 8mb increase only `--transfers` option 87 | ``` 88 | rclone -v --transfers=16 --drive-chunk-size=16384k --drive-upload-cutoff=16384k copy local_dir gdrive_config:remote_drive_dir 89 | ``` 90 | `--transfers=N` number parallel of connection. `default: 4` 91 | 92 | ` --drive-chunk-size=N` if file bigger than this size it will splits into multiple upload, increase if you want better speed. `default: 8192k or 8mb` 93 | 94 | `--drive-upload-cutoff=N` should be same with chunk size 95 | 96 | `-v` option to view upload progress stats 97 | -------------------------------------------------------------------------------- /bin/compile: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | indent() { 6 | sed -u 's/^/ /' 7 | } 8 | 9 | ###### install Rclone ########## 10 | echo "-----> Installing rclone" 11 | BUILD_DIR=$1 12 | CACHE_DIR=$2 13 | VENDOR_DIR="vendor" 14 | FILE="rclone.zip" 15 | DOWNLOAD_URL="https://github.com/xinxin8816/heroku-aria2c-21vianet/raw/master/rclone.zip" 16 | 17 | mkdir -p "$CACHE_DIR" 18 | 19 | if ! [ -e "$CACHE_DIR/$FILE" ]; then 20 | echo "-----> Fetching Latest Rclone binaries at ${DOWNLOAD_URL}" | indent 21 | wget $DOWNLOAD_URL -q -O "$CACHE_DIR/$FILE" 22 | else 23 | filestr=$(find . -name "$CACHE_DIR/$FILE" -mtime +1 -print) 24 | if [ "$filestr" = "" ]; then 25 | echo "-----> cache Expired, Fetching Latest Rclone at ${DOWNLOAD_URL}" | indent 26 | wget $DOWNLOAD_URL -q -O "$CACHE_DIR/$FILE" 27 | else 28 | echo "build using cached source" | indent 29 | fi 30 | fi 31 | 32 | cd "$BUILD_DIR" 33 | mkdir -p "$VENDOR_DIR" 34 | cd "$VENDOR_DIR" 35 | mkdir -p rclone 36 | cd rclone 37 | cp "$CACHE_DIR/$FILE" . 38 | unzip -qqj "$FILE" 39 | rm -rf "$FILE" 40 | chmod 777 rclone 41 | 42 | echo "exporting PATH" | indent 43 | PROFILE_PATH="$BUILD_DIR/.profile.d/rclone.sh" 44 | mkdir -p "$(dirname "$PROFILE_PATH")" 45 | echo 'export PATH="$PATH:${HOME}/vendor/rclone"' >> $PROFILE_PATH 46 | echo "Rclone installed" | indent 47 | 48 | ###### install aria2 ########## 49 | echo "-----> Installing Aria2" 50 | 51 | FILE="aria2-1.34.0-linux-gnu-64bit-build1" 52 | FILE_ARC="${FILE}.tar.bz2" 53 | DOWNLOAD_URL="https://github.com/q3aql/aria2-static-builds/releases/download/v1.34.0/$FILE_ARC" 54 | 55 | if ! [ -e "$CACHE_DIR/$FILE_ARC" ]; then 56 | echo "-----> Fetching Aria2 binaries at ${DOWNLOAD_URL}" | indent 57 | wget "$DOWNLOAD_URL" -q -O "$CACHE_DIR/$FILE_ARC" 58 | else 59 | echo "build using cached source" | indent 60 | fi 61 | 62 | 63 | cd "$BUILD_DIR/$VENDOR_DIR" 64 | mkdir -p aria2c 65 | cd aria2c 66 | cp "$CACHE_DIR/$FILE_ARC" . 67 | tar jxf "$FILE_ARC" 68 | mv "$FILE"/* . 69 | rm -rf "$FILE_ARC" "$FILE" 70 | 71 | echo "exporting PATH" | indent 72 | PROFILE_PATH="$BUILD_DIR/.profile.d/aria2c.sh" 73 | mkdir -p "$(dirname "$PROFILE_PATH")" 74 | echo 'export PATH="$PATH:${HOME}/vendor/aria2c"' >> $PROFILE_PATH 75 | 76 | #### install winrar ######## 77 | 78 | echo "-----> Installing winrar" 79 | 80 | FILE="rarlinux-x64-5.9.0.tar.gz" 81 | DOWNLOAD_URL="https://www.rarlab.com/rar/$FILE" 82 | 83 | if ! [ -e "$CACHE_DIR/$FILE" ]; then 84 | echo "-----> Fetching Winrar binaries at ${DOWNLOAD_URL}" | indent 85 | wget $DOWNLOAD_URL -q -O "$CACHE_DIR/$FILE" 86 | else 87 | echo "build using cached source" | indent 88 | fi 89 | 90 | cd "$BUILD_DIR/$VENDOR_DIR" 91 | mkdir -p winrar 92 | cd winrar 93 | cp "$CACHE_DIR/$FILE" . 94 | tar xf "$CACHE_DIR/$FILE" --strip-components=1 95 | 96 | echo "exporting PATH" | indent 97 | PROFILE_PATH="$BUILD_DIR/.profile.d/rar.sh" 98 | mkdir -p "$(dirname "$PROFILE_PATH")" 99 | echo 'export PATH="$PATH:${HOME}/vendor/winrar"' >> $PROFILE_PATH 100 | PROFILE_PATH="$BUILD_DIR/.profile.d/unrar.sh" 101 | mkdir -p "$(dirname "$PROFILE_PATH")" 102 | echo 'export PATH="$PATH:${HOME}/vendor/winrar"' >> $PROFILE_PATH 103 | 104 | #### moving rclone.conf ######## 105 | 106 | echo 'export LANG=zh_CN.UTF-8' >> $PROFILE_PATH 107 | mkdir -p "$BUILD_DIR"/.profile.d 108 | cat <"$BUILD_DIR"/.profile.d/rclone_config.sh 109 | #!/bin/sh 110 | cd "\$HOME" 111 | echo "-----> moving config file, rclone.conf" 112 | if [ -f "rclone.conf" ]; then 113 | mkdir -p .config/rclone 114 | mv -f rclone.conf .config/rclone/rclone.conf 115 | echo "-----> Done." 116 | else 117 | echo "rclone.conf not exist" | indent 118 | fi 119 | 120 | echo "-----> moving id_rsa" 121 | if [ -f "id_rsa" ]; then 122 | mkdir -p .ssh 123 | mv -f id_rsa .ssh/id_rsa 124 | chmod 0700 .ssh/id_rsa 125 | echo "-----> Done." 126 | else 127 | echo "id_rsa not exist" | indent 128 | fi 129 | -------------------------------------------------------------------------------- /bin/detect: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # this pack is valid for all apps 4 | echo "xinxin8816-rclone-21vianet" 5 | exit 0 6 | -------------------------------------------------------------------------------- /bin/release: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo "--- {}" 3 | -------------------------------------------------------------------------------- /rclone.conf: -------------------------------------------------------------------------------- 1 | [gdrive_config] 2 | type = drive 3 | client_id = 4 | client_secret = 5 | scope = drive.file 6 | root_folder_id = 7 | service_account_file = 8 | token = {"access_token":"xxxxxxxxxxxxxxx,"token_type":"Bearer","refresh_token":"xxxxxxxxxxxxxxxxxxxxxxxxxxx","expiry":"2018-07-25T21:27:02.0923008+07:00"} 9 | 10 | --------------------------------------------------------------------------------