scripts/sync: add a "sync all" option

This commit is contained in:
2024-07-22 07:52:31 +00:00
parent 284ea45648
commit 79fbdc4e15

View File

@@ -2,29 +2,38 @@
#!nix-shell -i bash -p bash -p rsync -p sane-scripts.sync-music
usage() {
echo "sync <host> [passthrough flags]"
echo "sync all|desko|lappy|moby [passthrough flags ...]"
exit 1
}
host="$1"
shift
syncHost() {
local host=$1
shift
local syncFlags=("$@")
case "$host" in
(all)
syncHost desko "${syncFlags[@]}"
syncHost lappy "${syncFlags[@]}"
syncHost moby "${syncFlags[@]}"
;;
(desko)
test -d /mnt/servo/media/Music/Various.Artists && sane-sync-music --compat /mnt/servo/media/Music /mnt/desko/home/Music "${syncFlags[@]}"
;;
(lappy)
test -d /mnt/servo/media/Music/Various.Artists && sane-sync-music --compress --compat /mnt/servo/media/Music /mnt/lappy/home/Music "${syncFlags[@]}"
;;
(moby)
# copy photos/screenshots from moby to desko:
rsync -arv --exclude servo-macros /mnt/moby/home/Pictures/ /mnt/desko/home/Pictures/from/moby/
# copy books from servo to moby; delete old/untracked ones, but keep KOreader state files (sdr)
test -d /mnt/servo/media/Books/Books && rsync -arv --delete --exclude '*.sdr' /mnt/servo/media/Books/ /mnt/moby/home/Books/local/servo/
# copy music
test -d /mnt/servo/media/Music/Various.Artists && sane-sync-music --compat /mnt/servo/media/Music /mnt/moby/home/Music "${syncFlags[@]}"
;;
(*)
usage
;;
esac
}
case "$host" in
desko)
test -d /mnt/servo/media/Music/Various.Artists && sane-sync-music --compat /mnt/servo/media/Music /mnt/desko/home/Music "$@"
;;
lappy)
test -d /mnt/servo/media/Music/Various.Artists && sane-sync-music --compress --compat /mnt/servo/media/Music /mnt/lappy/home/Music "$@"
;;
moby)
# copy photos/screenshots from moby to desko:
rsync -arv --exclude servo-macros /mnt/moby/home/Pictures/ /mnt/desko/home/Pictures/from/moby/
# copy books from servo to moby; delete old/untracked ones, but keep KOreader state files (sdr)
test -d /mnt/servo/media/Books/Books && rsync -arv --delete --exclude '*.sdr' /mnt/servo/media/Books/ /mnt/moby/home/Books/local/servo/
# copy music
test -d /mnt/servo/media/Music/Various.Artists && sane-sync-music --compat /mnt/servo/media/Music /mnt/moby/home/Music "$@"
;;
(*)
usage
;;
esac
syncHost "$@"