Google Shared Drives
This guide will show you how to create default Saltbox Shared Drives and add your group of SAs to them.
It's assuming you're working through the steps from here and have completed the following steps:
- verified account drive permissions
- created the required project
- created the required group
- installed the gcloud SDK tools
- created the expected projects and service accounts
NOTE: This guide is assuming a Google Gsuite Business/Workspace account.
IF YOU HAVE DONE THIS BEFORE, THERE IS NO REASON TO REPEAT IT. THIS SCRIPT MAY PRODUCE A SECOND SET OF SHARED DRIVES, AND THERE IS NO REASON FOR THIS.
-
Retrieve the
sb-gd
codecd /opt && git clone https://github.com/chazlarson/sb_gd.git && cd sb_gd
-
Create and activate a virtual environment:
python3 -m venv sb_gd && source sb_gd/bin/activate
If you see something like this:
The virtual environment was not created successfully because ensurepip is not available. On Debian/Ubuntu systems, you need to install the python3-venv package using the following command. apt install python3.8-venv You may need to use sudo with that command. After installing the python3-venv package, recreate your virtual environment. Failing command: ['/home/YOU/sb_gd/sb_gd/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']
run the suggested command with
sudo
:sudo apt install python3.8-venv
Then try the virtual-environment command in step 2 again.
-
Install script requirements:
python -m pip install -r requirements.txt
-
Edit the
config.py
script:nano config.py
Edit as indicated by
<<<<
below:prefix = 'akIhSwlKdf' # the prefix you generated previously group_email = "all-sa@DOMAIN.com" # the group you created previously sa_file = "/opt/sa/all/150.json" # edit this path if required; if you've followed all previous steps correctly it's not required drive_data = { # add additional drives and media paths here if needed. Media paths should be unique per drive. 'Movies': '/Media/Movies', 'Music': '/Media/Music', 'TV': '/Media/TV' }
-
Copy your credential JSON into this directory:
cp /opt/sa/project-creds.json client_secrets.json
This is the credential file you downloaded a couple steps ago. Recall that in that step I said I would later assume you'd put it at
/opt/sa/project_creds.json
. Here's that assumption.If you've stored the file elsewhere, copy it from there via whatever means. It just has to end up at
/opt/sb_gd/client_secrets.json
. -
Run the
sb_sd.py
script:python sb_sd.py
You will be asked a bunch of questions about the previsou steps. If the answers are not all "YES", you'll need to go complete those steps. If you lie and answer YES when you haven't completed those steps, this script will fail in some way. There is no way to avoid performing all the steps.
You will be asked to authenticate in the usual Google way. Follow the prompts.
For the time being, due to changes in the Google OAuth process, this will try to redirect you to a
localhost
URL, which will fail. The URL will look like:http://localhost:8000/oauth2callback?code=4/NUMBERS_AND_STUFF&scope=https://www.googleapis.com/auth/drive
Copy everything following
code=
[i.e.4/NUMBERS_AND_STUFF&scope=https://www.googleapis.com/auth/drive
] and paste it at the prompt where the script is waiting.We're working on making this a bit more friendly.
This script will create three shared drives, add your group email as a manager, create mount files and ID folders on the root of each drive, build the folder structure as defined in the config, and create rclone remotes for the individual shared drives and a union rclone remote for use with Saltbox.
You should see output similar to this:
Note: the script uses
/opt/sa/all/150.json
in the rclone configuration for these remotes; that's not something you have to set or create [you'll note that it hasn't been mentioned much above]. That one is used because it's right in the middle of the SAs you just created, so it's unlikely that SA cycling in cloudplow will ever exhaust enough SAs to hit this one and possibly affect your mounts.** Team Drive aZaSjsklaj-Movies created, ID: 123456789 ** user all-sa@domain.com created as organizer, ID: 123456789 ** Folder -- aZaSjsklaj-Movies Shared -- created, ID 123456789 ** bin file created on root, ID 123456789 ** Folder Media created, ID 123456789 ** Folder Movies created, ID 123456789 -------------------- [aZaSjsklaj-Movies] type = drive scope = drive service_account_file = /opt/sa/all/150.json team_drive = 123456789 -------------------- 0 ** Team Drive aZaSjsklaj-Music created, ID: 123456789 ** user all-sa@domain.com created as organizer, ID: 123456789 ** Folder -- aZaSjsklaj-Music Shared -- created, ID 123456789 ** bin file created on root, ID 123456789 ** Folder Media created, ID 123456789 ** Folder Music created, ID 123456789 -------------------- [aZaSjsklaj-Music] type = drive scope = drive service_account_file = /opt/sa/all/150.json team_drive = 123456789 -------------------- 0 ** Team Drive aZaSjsklaj-TV created, ID: 123456789 ** user all-sa@domain.com created as organizer, ID: 123456789 ** Folder -- aZaSjsklaj-TV Shared -- created, ID 123456789 ** bin file created on root, ID 123456789 ** Folder Media created, ID 123456789 ** Folder TV created, ID 123456789 -------------------- [aZaSjsklaj-TV] type = drive scope = drive service_account_file = /opt/sa/all/150.json team_drive = 123456789 -------------------- 0 -------------------- [google] type = union upstreams = aZaSjsklaj-Movies: aZaSjsklaj-Music: aZaSjsklaj-TV: --------------------
Drive names and IDs will be written to
drive_create_log
.What are those directories and files for?
This script creates an empty directory and a zero-byte file on the root of each shared drive.
The file will be useful later on when you need "is this disk mounted?" flags for things like
plex_autoscan
orautoscan
.The directory is a belt-and-suspenders convenience you can use to see if your union remote and/or mergerfs config is including everything it should. We create both a file and a dir so you will get this information whether you use
rclone ls REMOTE
orrclone lsd REMOTE
or whatever other means:$ rclone lsd google: -1 2021-11-21 17:09:13 -1 -- aZaSjsklaj-Movies Shared -- -1 2021-11-21 17:11:50 -1 -- aZaSjsklaj-Music Shared -- -1 2021-11-21 17:12:09 -1 -- aZaSjsklaj-TV Shared -- -3 2021-11-21 17:12:11 -1 Media $ rclone ls google: 0 azasjsklaj-movies_mounted.bin 0 azasjsklaj-tv_mounted.bin 0 azasjsklaj-music_mounted.bin
-
You're done. Deactivate the virtual env used by this script.
deactivate
BEFORE YOU DO ANYTHING ELSE:
- BACK UP
/opt/sa
TO YOUR LOCAL COMPUTER - BACK UP
/home/YOU/.config/rclone/rclone.conf
TO YOUR LOCAL COMPUTER
If for some reason you want to wipe your machine and start again OUTSIDE THE USUAL BACKUP/RESTORE you will need those files. You can just restore them rather than going through this whole process again.
If you are going through the manual rclone instructions, continue with the next step