Skip to content

Instantly share code, notes, and snippets.

@Limeliz
Created November 20, 2015 00:52
Show Gist options
  • Save Limeliz/4389cc40744331736c59 to your computer and use it in GitHub Desktop.
Save Limeliz/4389cc40744331736c59 to your computer and use it in GitHub Desktop.
Edited version of sync.sh for gdrive on MotionPieOS
#!/bin/bash
# sync.sh written by Claude Pageau for pi-timolo, his excellent video processing application.
# re-purposed and mangled by Malcolm Taylor for use with MotionPie
# edited by Emil Janesten to stop duplicate running instances and duplicate files and folders in Google Drive.
# folder where motion files are located
SYNC_DIR=output
# Get current folder where this script is located
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Lockfile
LOCK=/var/tmp/gdrive_sync
# check if script is already running to avoid multiple instances
if [ -f $LOCK ]; then
echo "-- Job is already running\! --"
exit 6
fi
touch $LOCK
# Run gdrive for files in folder specified by variable $SYNC_DIR
echo "$(date)"
echo "---------------------- PROCESSING ---------------------------------"
echo "Starting gdrive Push From $DIR/$SYNC_DIR"
echo " To google drive subfolder $SYNC_DIR"
echo "-------------------------------------------------------------------"
cd $DIR
echo "Start synchronization ....."
echo "gdrive push -r -no-prompt -ignore-conflict -ignore-name-clashes $SYNC_DIR/*"
echo "Starting gdrive sync at $(date)" >> sync.log
gdrive push -r -no-prompt -ignore-conflict -ignore-name-clashes $SYNC_DIR/*
# Check if gdrive exited successfully
if [ $? -ne 0 ]
then
echo "ERROR - gdrive Processing failed."
echo "Possible Cause - No internet connection or some other reason."
fi
cd $DIR
echo "Done at $(date)."
rm $LOCK
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment