-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
base: Cleanup the cpv* and mvv* scripts
- Loading branch information
1 parent
637c1e4
commit c65166b
Showing
5 changed files
with
57 additions
and
15 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,12 @@ | ||
#!/bin/sh | ||
#!/bin/bash | ||
|
||
set -eu | ||
|
||
if [[ $# == 0 || "$1" == -h || "$1" == --help ]] ; then | ||
echo Use rsync to copy files and directories. >&2 | ||
echo >&2 | ||
echo "Usage: $(basename $0) [RSYNC_OPTIONS] FILE|DIR... DESTINATION" >&2 | ||
exit 1 | ||
fi | ||
|
||
exec rsync -avPih "$@" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,18 @@ | ||
#!/bin/sh | ||
#!/bin/bash | ||
|
||
set -eu | ||
|
||
if [[ $# == 0 || "$1" == -h || "$1" == --help ]] ; then | ||
echo Use rsync to copy files and directories to a \"remote\" destination. >&2 | ||
echo A \"remote\" destination is anything that requires ssh. >&2 | ||
echo The transfer won\'t use temporary files and will compare files based on their size only. >&2 | ||
echo >&2 | ||
echo "Usage: $(basename $0) [RSYNC_OPTIONS] FILE|DIR... DESTINATION" >&2 | ||
exit 1 | ||
fi | ||
|
||
# With rsync 2.*, --append will always do a checksum and with rsync 3.+, --append won't do a | ||
# checksum. Use --append-verify to force the checksum. | ||
# Using `--inplace` might be dangerous in some cases, see | ||
# https://lists.samba.org/archive/rsync/2010-June/025178.html | ||
exec rsync -avPih --inplace --size-only --stats "$@" | ||
exec cpv --append --inplace --size-only --stats "$@" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,12 @@ | ||
#!/bin/sh | ||
#!/bin/bash | ||
|
||
exec rsync -avPih --rsync-path="sudo rsync" "$@" | ||
set -eu | ||
|
||
if [[ $# == 0 || "$1" == -h || "$1" == --help ]] ; then | ||
echo Use rsync to copy files and directories to a destination owned by root. >&2 | ||
echo >&2 | ||
echo "Usage: $(basename $0) [RSYNC_OPTIONS] FILE|DIR... DESTINATION" >&2 | ||
exit 1 | ||
fi | ||
|
||
exec cpv --rsync-path="sudo rsync" "$@" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,19 @@ | ||
#!/bin/sh | ||
|
||
if [[ $# -lt 2 ]] ; then | ||
echo "$0 expects at least one source and one destination." >&2 | ||
return 1 | ||
set -euo pipefail | ||
|
||
if [[ "$#" == 0 ]] || [[ "$1" == -h ]] || [[ "$1" == --help ]] ; then | ||
echo Use rsync to move files and directories. >&2 | ||
echo >&2 | ||
echo "Usage: $(basename $0) [RSYNC_OPTIONS] FILE|DIR... DESTINATION" >&2 | ||
exit 1 | ||
fi | ||
|
||
dirs=() | ||
for src in "${@:1:$# - 1}" ; do | ||
[[ -d "${src}" ]] && dirs+=("${src}") | ||
done | ||
|
||
if rsync -avPih --remove-source-files "$@" ; then | ||
find "${@:1:$(($# - 1))}" -type d -empty -delete | ||
[[ ${#dirs[@]} -gt 0 ]] && find "${dirs[@]}" -type d -empty -delete | ||
fi |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
#!/bin/sh | ||
|
||
if [[ $# -lt 2 ]] ; then | ||
echo "$0 expects at least one source and one destination." >&2 | ||
return 1 | ||
fi | ||
set -euo pipefail | ||
|
||
if rsync -avPih --remove-source-files --rsync-path="sudo rsync" "$@" ; then | ||
find "${@:1:$(($# - 1))}" -type d -empty -delete | ||
if [[ "$#" == 0 ]] || [[ "$1" == -h ]] || [[ "$1" == --help ]] ; then | ||
echo Use rsync to move files and directories to a destination owned by root. >&2 | ||
echo >&2 | ||
echo "Usage: $(basename $0) [RSYNC_OPTIONS] FILE|DIR... DESTINATION" >&2 | ||
exit 1 | ||
fi | ||
|
||
exec mvv --rsync-path="sudo rsync" "$@" |