fhnw-tools/fhnw-teams-sync

56 lines
932 B
Bash
Executable File

#!/usr/bin/env sh
set -o errexit
dest_dir="$HOME/documents/fhnw/teams"
sources=""
display_help() {
echo "Usage: $0 [option...] " >&2
echo
echo " -d, root destination directory [default: $dest_dir]"
echo " -s, list of configured rclone teams sources (pipe separated)"
echo " -h, display this help and exit"
echo
}
parse_args() {
while getopts ":hd:s:" opt; do
case $opt in
h)
display_help
exit 0
;;
d)
dest_dir=$OPTARG
;;
s)
sources=$OPTARG
;;
\?)
echo "Invalid option: -$OPTARG" >&2
display_help
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
display_help
exit 1
;;
esac
done
}
sync_teams() {
echo "syncing teams..."
oldIFS=$IFS
IFS='|'
for s in $sources; do
rclone sync --progress "$s:" "$dest_dir/$s"
done
IFS=$oldIFS
}
parse_args "$@"
sync_teams