Last active
August 18, 2022 01:10
-
-
Save sas-starbuck/74ba95bae6c84b1b4d85f1f90bcd36d6 to your computer and use it in GitHub Desktop.
jamf school - use rclone on many computers to sync to one or many Google Drives based on the hostname
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 characters
#check if conf exists | |
FILE=/Users/Shared/.config/rclone/rclone.conf | |
if test -f "$FILE"; then | |
echo "$FILE exists." | |
else | |
mkdir -pv /Users/Shared/.config/rclone/ | |
tee -a /Users/Shared/.config/rclone/rclone.conf << 'END' | |
[COMPUTERNAMEHERE] | |
type = drive | |
client_id = example.apps.googleusercontent.com | |
client_secret = SECRETCODEHERE | |
scope = drive | |
token = {"access_token":"asdf","token_type":"Bearer","refresh_token":"asdf","expiry":"1969-01-01T00:00:00.000000-00:00"} | |
team_drive = | |
END | |
fi | |
#perform rclone syncing | |
HOSTNAME=$(hostname) | |
COMPUTER=${HOSTNAME%".local"} #remove suffix of .local to get "COMPUTERNAMEHERE%%" | |
USER="myuser" | |
#must be run as root | |
/usr/local/bin/rclone --config /Users/Shared/.config/rclone/rclone.conf copy -u --max-age 3M --exclude .DS_Store /Users/"$USER"/Desktop/ "$COMPUTER":Desktop/ -v | |
/usr/local/bin/rclone --config /Users/Shared/.config/rclone/rclone.conf copy -u --max-age 3M --exclude .DS_Store /Users/"$USER"/Documents/ "$COMPUTER":Documents/ -v | |
/usr/local/bin/rclone --config /Users/Shared/.config/rclone/rclone.conf copy -u --max-age 3M --exclude .DS_Store /Users/"$USER"/Downloads/ "$COMPUTER":Downloads/ -v | |
/usr/local/bin/rclone --config /Users/Shared/.config/rclone/rclone.conf copy -u --max-age 3M --exclude .DS_Store /Users/"$USER"/Pictures/ "$COMPUTER":Pictures/ -v | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment