Created
January 17, 2016 09:40
-
-
Save mastix/1a93fb8c6114a3ba79ed to your computer and use it in GitHub Desktop.
Updated MotionEyeOS Google Drive sync script (added pull from Google Drive to allow local media deletion)
This file contains 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
#!/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. | |
# Jan 2016: edited by Sascha Sambale to pull changes from Google Drive as well, which allows to delete local media when deleted in Google Drive. | |
# folder where motion files are located | |
SYNC_DIR=MotionEye | |
# 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)" | |
cd $DIR | |
echo "Start synchronization ....." | |
echo "Starting gdrive sync at $(date)" >> sync.log | |
echo "Pulling changes from Google Drive Folder ($SYNC_DIR)..." | |
gdrive pull -no-prompt -ignore-conflict -ignore-name-clashes $SYNC_DIR | |
echo "Pushing changes to Google Drive Folder ($SYNC_DIR)..." | |
gdrive push -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