Created
June 4, 2021 22:32
-
-
Save alashow/5235623b87cd92af8368f7ce81e1b2c5 to your computer and use it in GitHub Desktop.
Simple gdrive service account rotations with rclone
This file contains 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 characters
[driva-0-sa] | |
type = drive | |
scope = drive | |
team_drive = xyz0 | |
root_folder_id = xyz0 | |
service_account_file = path | |
[driva-1-sa] | |
type = drive | |
scope = drive | |
team_drive = xyz1 | |
root_folder_id = xyz1 | |
service_account_file = path | |
[driva-2-sa] | |
type = drive | |
scope = drive | |
team_drive = xyz2 | |
root_folder_id = xyz2 | |
service_account_file = path | |
[drive] | |
type = union | |
remotes = driva-0-sa: driva-1-sa: driva-2-sa: | |
action_policy = all | |
create_policy = rand | |
search_policy = all |
This file contains 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 characters
#!/bin/bash | |
RCLONE_CONFIG="/opt/rclone/rclone.conf" | |
LOG_FILE="/opt/rclone/logs/sa-rotations.log" | |
ACCOUNTS_FOLDER="/opt/rclone/accounts" | |
RCLONE_ADDR=127.0.0.1:49205 | |
TARGET_REMOTES=(drive-0-sa drive-1-sa drive-2-sa) | |
for targetRemote in ${TARGET_REMOTES[@]}; do | |
RANDOM_ACCOUNT=`find $ACCOUNTS_FOLDER -type f | shuf -n 1` | |
rclone rc --rc-addr $RCLONE_ADDR --rc-no-auth backend/command command=set fs="$targetRemote": -o \ | |
service_account_file=$RANDOM_ACCOUNT \ | |
--config=$RCLONE_CONFIG \ | |
--log-level=DEBUG 2>&1 | tee -a $LOG_FILE | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment