diff options
Diffstat (limited to 'home/profiles/base')
-rwxr-xr-x | home/profiles/base/scripts/airport.nix | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/home/profiles/base/scripts/airport.nix b/home/profiles/base/scripts/airport.nix index cedb1d4..c46573d 100755 --- a/home/profiles/base/scripts/airport.nix +++ b/home/profiles/base/scripts/airport.nix @@ -2,9 +2,10 @@ # airport.sh - shared file store # # # Environment variables - # `AIRPORT_HOST` - host to rsync to - # `AIRPORT_USER` - username to connect with - # `AIRPORT_DIR` - defaults to `~/airport`, directory to use + # `AIRPORT_HOST` - host to rsync to + # `AIRPORT_USER` - username to connect with + # `AIRPORT_DIR` - defaults to `~/airport`, directory to use + # `AIRPORT_SAFEOP` - 'safe operations' mode, which doesn't delete files set -euo pipefail @@ -47,6 +48,7 @@ HOST=''${AIRPORT_HOST:?"AIRPORT_HOST needs to be set"} USER=''${AIRPORT_USER:?"AIRPORT_USER needs to be set"} DIR=''${AIRPORT_DIR:-"$HOME/airport"} + SAFEOP=''${AIRPORT_SAFEOP:-1} [ "$#" -eq 0 ] && die "FATAL: expected exactly 1 argument, $# provided" @@ -58,15 +60,18 @@ bin_exists "rsync" || die "FATAL: couldn't find rsync" + opts=(-au --stats --info=progress2) + [ $SAFEOP ] || opts+=(--delete-after) + case "$1" in send) delay "Airport will run 'rsync -au' to $DIR to SEND" - rsync -au --stats --info=progress2 --mkpath $DIR/ $USER@$HOST:airport + rsync ''${opts[@]} --mkpath $DIR/ $USER@$HOST:airport ;; recv) delay "Airport will run 'rsync -au' to $DIR to RECV" - rsync -au --stats --info=progress2 $USER@$HOST:airport/ $DIR + rsync ''${opts[@]} $USER@$HOST:airport/ $DIR ;; configure) |