diff options
-rw-r--r-- | mark-as-expendable-dir.in | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/mark-as-expendable-dir.in b/mark-as-expendable-dir.in index e615d3c..bb31b3e 100644 --- a/mark-as-expendable-dir.in +++ b/mark-as-expendable-dir.in @@ -59,20 +59,26 @@ done for dir in "$@" do - { - printf 'Signature: ' - printf '.IsCacheDirectory' | \ - md5sum - | \ - cut -d' ' -f 1 - printf '# This file is a cache directory tag created by %s for %s.\n' \ - "$(basename "$0")" \ - "${caller}" - printf '# For information about cache directory tags, see:\n' - printf '# http://www.brynosaurus.com/cachedir/\n' - } > "${dir}/CACHEDIR.TAG" - { - printf '+ .rsync-filter\n' - printf -- '- *\n' - } > "${dir}/.rsync-filter" - touch "${dir}/.nobackup" + if [ ! -f "${dir}/CACHEDIR.TAG" ]; then + { + printf 'Signature: ' + printf '.IsCacheDirectory' | \ + md5sum - | \ + cut -d' ' -f 1 + printf '# This file is a cache directory tag created by %s for %s.\n' \ + "$(basename "$0")" \ + "${caller}" + printf '# For information about cache directory tags, see:\n' + printf '# http://www.brynosaurus.com/cachedir/\n' + } > "${dir}/CACHEDIR.TAG" + fi + if [ ! -f "${dir}/.rsync-filter" ]; then + { + printf '+ .rsync-filter\n' + printf -- '- *\n' + } > "${dir}/.rsync-filter" + fi + if [ ! -f "${dir}/.nobackup" ]; then + touch "${dir}/.nobackup" + fi done |