Last active
June 4, 2021 14:18
-
-
Save moriglia/35a0de9b94927c6c167056f964cc35f4 to your computer and use it in GitHub Desktop.
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
+ /classified/**.gpg | |
- /classified/** | |
- /.remote | |
- /.filter |
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
my_remote_onedrive:Thesis |
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 | |
print_usage(){ | |
echo "Usage: $(basename $0) {upload|download} [copy|sync] [<extra-rclone-params]"; | |
echo " " | |
echo "Before using this script you need to follow some steps:" | |
echo "1) Configure a remote with rclone" | |
echo "2) Write \"remote:path/to/root\" to the \".remote\" file" | |
echo "3) Optionally create a \".filter\" file" | |
echo " with the rclone filtering syntax" | |
} | |
if [ "$1" == "--help" ] ; then | |
print_usage ; | |
exit 0 ; | |
fi | |
if [ -f ".filter" ] ; then | |
filter_option="--filter-from .filter"; | |
else | |
filter_option=""; | |
fi | |
if [ ! -f ".remote" ] ; then | |
echo "You need a .remote file to be parsed"; | |
exit 1; | |
else | |
remote=$(head -n 1 .remote); | |
fi | |
if [ $# -lt 1 ] ; then | |
print_usage ; | |
exit 1; | |
fi | |
direction=$1; | |
shift ; | |
if [ $# -ge 1 ] ; then | |
case $1 in | |
sync) | |
command=$1; | |
shift ; | |
;; | |
copy) | |
command=$1 ; | |
shift ; | |
;; | |
*) | |
command="copy"; | |
# Don't shift! It is a parameter to pass to rclone | |
;; | |
esac | |
else | |
command="copy"; | |
fi | |
# The remaining params are to be fed to rclone | |
case $direction in | |
upload) | |
rclone $command . $remote $filter_option $@ ; | |
;; | |
download) | |
rclone $command $remote . $filter_option $@ ; | |
;; | |
*) | |
print_usage ; | |
exit 1 | |
;; | |
esac ; | |
exit 0 ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment