Script to set up Google Drive stuff for saltbox/cloudbox
- You have verified Google account permissions as described here: https://docs.saltbox.dev/reference/google-account-perms/
- You have created a Google project as described here: https://docs.saltbox.dev/reference/google-project-setup/
- You have the credential JSON to hand
- You have created a Google group as described here: https://docs.saltbox.dev/reference/google-group-setup/
- You have that group address to hand
- You have rclone installed
- You are running python 3.8 and have run
sudo apt install python3.8-venv -y
. Probably other python3 works [this was built on a new saltbox install, so the version is whatever that left me with]. The assumption is that I can create a Python virtual env /opt
is owned by you and writeable without sudo
There's en .envrc
that will set up the environment for you if you are using direnv
.
The python version usage is described in the saltbox docs: https://docs.saltbox.dev/reference/google-shared-drives/
sb_sd.py
- Saltbox setup for Google Shared drives
sb_cp.py
- adjusts stock Cloudplow config files for these shared drives and service accounts.
sb_pas.py
- adjusts stock Plex Autoscan config file for these shared drives.
-
Asks some questions to make sure you've done the required stuff
It's pointless to lie here since the script will just error later.
-
Read config.py
Gets prefix and various other pieces.
-
Grabs union remote name from settings
-
Makes sure that any remote by that name looks like it came from this script
-
Creates shared drives with expected file systems
-
Add service accounts to the google group you specify
-
Add Google group to shared drives as Manager
-
Create rclone remotes for the shared drives
These are authenticated with a service account file, all using
/opt/sa/all/150.json
-
Create or update rclone union remote combining the shared drives
-
Zip up all work product and upload to one of the shared drives for backup.
NOTE: the sh version of this script is described below and is not currently used by saltbox because while it always worked on my machine, it never worked on some others' machines.
This script is a two-stage thing.
First run will clone and set up safire
.
Second run will authenticate safire
, then:
-
Create shared drives if needed
Default is three, "Movies", "Music", "TV"
-
Create projects
Default is three.
-
Create service accounts
Default is 100 per project
-
Add service accounts to the google group you specify
-
Add Google group to shared drives as Manager
-
Download service account JSON files
-
Sync service account JSON files to /opt/sa/all
-
Create rclone remotes for the shared drives
These are authenticated with a service account file, all using
/opt/sa/all/000150.json
-
Create standard file systems on the shared drives
Media ├── Movies ├── Music └── TV
-
Create rclone union remote combining the shared drives
The script generates and uses a random six-character prefix to use with all the stuff it creates, so for example the default shared drives will be something like:
MWxlw9_Movies
MWxlw9_Music
MWxlw9_TV
This means everything is away from stuff you created and can be cleaned up easily if need be.
That prefix is saved in ~/safire/prefix_file
If you want to define the shared drives and paths for yourself, create a file ~/safire/list_drives
where each line is DRIVENAME|PATH
. The default used in the absence of that file is:
Movies|/Media/Movies
Music|/Media/Music
TV|/Media/TV