-
-
Save AmirulAndalib/dd7be449c7cb7573a0180b54e4a6e882 to your computer and use it in GitHub Desktop.
Revisions
-
rokibhasansagar revised this gist
Jun 12, 2021 . No changes.There are no files selected for viewing
-
rokibhasansagar revised this gist
Jun 12, 2021 . 1 changed file with 7 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,10 +1,14 @@ ## To use Service Accounts through script, follow this method As the `Dockerfile` defined `WORKDIR /torapp`, make sure you have `/torapp` folder in root with user write access. If you use any other `WORKDIR`, please change the path mention from this method according to your needs. ### Step 1: Put your service account in a folder I've uploaded 100 SA JSON files in "accounts" folder in a private repo. DO NOT UPLOAD them in a Public Repo. Clone the Repo with your Personal Access Token (PAT). Always keep the token secret. ```shell git clone https://${PAT}@github.com/USERNAME/PRIVATE_REPONAME --depth 1 /torapp/sa @@ -36,7 +40,7 @@ team_drive = xyz_yxz_010 ### Step 3: Set the rclone config path and remote name In `ExecVarsSample.py`, set `DEF_RCLONE_DRIVE` as the <TeamDriveID> from rclone config. Also set the rclone config path in `RCLONE_CONFIG`. Usually it's `~/.config/rclone/rclone.conf` for any user. ### Step 4: Modify `start.sh` file -
rokibhasansagar created this gist
Jun 12, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,58 @@ ## To use Service Accounts through script, follow this method Make sure you have created `/torapp` folder in root with user write access. ### Step 1: Put your service account in a folder I've uploaded 100 SA JSON files in "accounts" folder in a private repo. ```shell git clone https://${PAT}@github.com/USERNAME/PRIVATE_REPONAME --depth 1 /torapp/sa ``` This will put the JSON files inside `/torapp/sa/accounts/` folder. ### Step 2: Use pre-defined rclone config Place your rclone config with this format. Make sure you have this line in the config - `service_account_file = /torapp/sa/accounts/__ServiceAcc__` So, the full rclone config would look like this - ```shell [TeamDriveID] type = drive client_id = xxxxx-xxxxxxxxxxx.apps.googleusercontent.com client_secret = yyyyyyyyyyyyyyyyyyyyyyyy scope = drive root_folder_id = chunk_size = 128M token = {"access_token":"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz","token_type":"Bearer","refresh_token":"nnnnnnnnnnnnnnnnn","expiry":"2021-05-30T20:14:18.276611995+06:00"} service_account_file = /torapp/sa/accounts/__ServiceAcc__ team_drive = xyz_yxz_010 ``` ### Step 3: Set the rclone config path and remote name In `ExecVarsSample.py`, set `DEF_RCLONE_DRIVE` as the <TeamDriveID> from rclone config. Also set the rclone config path in `RCLONE_CONFIG`. Usually it's `~/.config/rclone/rclone.conf` for any user. ### Step 4: Modify `start.sh` file ```shell _randomSA() { # Get a list of SA JSON Filenames ls /torapp/sa/accounts/ > /torapp/sa.list # Change The SA Filename in rclone config file every 30m while true; do sed -i 's|__ServiceAcc__|'"$(shuf -n 1 /torapp/sa.list)"'|' ~/.config/rclone/rclone.conf sleep 30m done } # Run the randomizer in background _randomSA & disown # Run main Bot Start Script gunicorn tortoolkit:start_server --bind 0.0.0.0:$PORT --worker-class aiohttp.GunicornWebWorker & python3 -m tortoolkit ```