Last active
April 8, 2020 17:19
-
-
Save Stefan-Code/8ada79edc060af060af001947ec63896 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
exitcode=1 | |
mountpoints="/run/user/1000/gvfs" | |
#do check if the correct usb mtp device is mounted | |
for mountpoint in $mountpoints/mtp*/; | |
do | |
echo "Testing $mountpoint" | |
sync_folder="$mountpoint/Internal shared storage" | |
#if the device contains a .sync_boox file in internal storage, proceed | |
if test -e "$sync_folder/.sync_boox";then | |
exitcode=0 | |
# files on the USB device have priority over local ones | |
#from usb to folder if the files are newer | |
rsync -rltvvuP --inplace "$sync_folder/" ~/boox/; | |
#from folder to usb if the files are newer | |
rsync -rlvvuP --inplace ~/boox/ "$sync_folder/"; | |
break #only check a single device | |
fi | |
#if the flash is not mounted exit with exitcode=1 | |
done | |
exit $exitcode |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment