Skip to content

Instantly share code, notes, and snippets.

@sas-starbuck
Last active August 18, 2022 01:10
Show Gist options
  • Save sas-starbuck/74ba95bae6c84b1b4d85f1f90bcd36d6 to your computer and use it in GitHub Desktop.
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
#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