├── .gitattributes ├── .rarreg.key ├── LICENSE ├── README.md ├── bin ├── compile ├── detect └── release ├── rclone.conf └── rclone.zip /.gitattributes: -------------------------------------------------------------------------------- 1 | * text eol=lf 2 | -------------------------------------------------------------------------------- /.rarreg.key: -------------------------------------------------------------------------------- 1 | RAR registration data 2 | ANTRAX 3 | Unlimited Company License 4 | UID=92bcacfe968499d649e8 5 | 641221225049e88c3a4a26900eaac808b9fb35f94ae86d27e3fb01 6 | 4280605b260409c52e5060fce6cb5ffde62890079861be57638717 7 | 7131ced835ed65cc743d9777f2ea71a8e32c7e593cf66794343565 8 | b41bcf56929486b8bcdac33d50ecf77399603809ca41aa4a97e94e 9 | 266a62b019fb474df47adece2d450a6481c8cc26e1e6c0f26bad0a 10 | 1ea394823a28827e5644e2f42acd2914bb4ca004a131e22760d6bc 11 | 18109fec98d3485025921ffeae5c3684e800883cc6434231975197 -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Antrax 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | ## Deploy 3 | 1. Create new app 4 | 5 | ``` 6 | heroku create myapp -b https://github.com/The-Antrax/heroku-buildpack-rclone-mod.git 7 | heroku git:clone -a myapp 8 | 9 | # or useing existed app 10 | heroku buildpacks:set https://github.com/The-Antrax/heroku-buildpack-rclone-mod.git -a myapp 11 | ``` 12 | 13 | 2. Setup Rclone by following [Rclone Docs](https://rclone.org/docs/) 14 | You can find your config from there: 15 | 16 | ``` 17 | Windows: %userprofile%\.config\rclone\rclone.conf 18 | Linux: $HOME/.config/rclone/rclone.conf 19 | ``` 20 | 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. 21 | 22 | ``` 23 | [gdrive_config] 24 | type = drive 25 | client_id = 26 | client_secret = 27 | scope = drive 28 | root_folder_id = 29 | service_account_file = /app/accounts/1.json 30 | service_account_file_path = /app/accounts/ 31 | server_side_across_configs = true 32 | token = {"access_token":"xxxxxxxxxxxxxxx,"token_type":"Bearer","refresh_token":"xxxxxxxxxxxxxxxxxxxxxxxxxxx","expiry":"2020-07-25T21:27:02.0923008+05:30"} 33 | ``` 34 | 35 | 3. Go to `myapp` directory, copy `rclone.conf` and winrar registraton key `.rarreg.key` (optional) then commit the change. 36 | 37 | ``` 38 | cd myapp 39 | git add . -f 40 | git commit -am "add config" 41 | git push heroku master 42 | ``` 43 | 44 | ## Usage 45 | ### Open Terminal 46 | ``` 47 | cd myapp 48 | heroku run bash 49 | # or 50 | heroku run bash --a myapp 51 | ``` 52 | 53 | ### Rclone 54 | Learn more from [Rclone Docs](https://rclone.org/commands/) and [Gclone Docs](https://github.com/donwa/gclone) 55 | 56 | **Upload file to Google Drive** 57 | ``` 58 | # The usual way 59 | rclone -P copy local_dir gdrive_config:remote_dirpath 60 | 61 | # The way that like using gclone 62 | rclone -P copy local_dir gdrive_config:{Destination_ID} 63 | ``` 64 | `-P` mean print progress in real time 65 | 66 | ### Aria2 67 | Learn more from [Aria2c Docs](http://aria2.github.io/manual/en/html/aria2c.html) 68 | 69 | **Download a file** 70 | ``` 71 | aria2c -x4 http://host/file.rar 72 | ``` 73 | `-x4` mean download using 4 connection 74 | 75 | ### UNRAR 76 | Learn more from [UNRAR Docs](https://pypi.org/project/unrar/) 77 | 78 | **Extract `.rar` or `.zip` Compressed file** 79 | ``` 80 | # To current directory 81 | unrar e file.rar/zip 82 | 83 | # With full path 84 | unrar x file.rar/zip 85 | ``` 86 | 87 | ## Tips 88 | 89 | **Speed up upload** 90 | 91 | If you want to upload many files smaller than 8mb increase only `--transfers` option 92 | ``` 93 | rclone -v --transfers=16 --drive-chunk-size=16384k --drive-upload-cutoff=16384k copy local_dir gdrive_config:remote_drive_dir 94 | ``` 95 | `--transfers=N` number parallel of connection. `default: 4` 96 | 97 | ` --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` 98 | 99 | `--drive-upload-cutoff=N` should be same with chunk size 100 | 101 | `-v` option to view upload progress stats 102 | -------------------------------------------------------------------------------- /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://raw.githubusercontent.com/The-Antrax/heroku-buildpack-rclone-mod/master/rclone.zip" 16 | 17 | mkdir -p "$CACHE_DIR" 18 | 19 | if ! [ -e "$CACHE_DIR/$FILE" ]; then 20 | echo "-----> Fetching Latest Rclone binaries from ANTRAX" | 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 from ANTRAX" | 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-mod by Antrax installed" | indent 47 | 48 | ###### install aria2 ########## 49 | echo "-----> Installing Aria2" 50 | 51 | FILE="aria2-1.35.0-linux-gnu-64bit-build1" 52 | FILE_ARC="${FILE}.tar.bz2" 53 | DOWNLOAD_URL="https://github.com/q3aql/aria2-static-builds/releases/download/v1.35.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.1.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=en_US.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 "rclone-mod-by-ANTRAX" 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 6 | root_folder_id = 7 | service_account_file = /app/accounts/1.json 8 | service_account_file_path = /app/accounts/ 9 | server_side_across_configs = true 10 | token = {"access_token":"xxxxxxxxxxxxxxx,"token_type":"Bearer","refresh_token":"xxxxxxxxxxxxxxxxxxxxxxxxxxx","expiry":"2020-07-25T21:27:02.0923008+05:30"} 11 | 12 | -------------------------------------------------------------------------------- /rclone.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/The-Antrax/heroku-buildpack-rclone-mod/aaa41fbfcdd5d0fd20851c4dff7ece9f4663eb6a/rclone.zip --------------------------------------------------------------------------------