blob: e66c97b0392632c039c40d49a2843a30935eee1d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
#!/bin/bash
set -e
verwendung() {
>&2 echo 'mark-as-expendable-dir creates CACHEDIR.TAG and .rsync-filter files to hide directory from backups by "tar --exclude-caches" and "rsync -F".'
>&2 echo ''
>&2 echo 'Usage: mark-as-expendable-dir [OPTIONS] [DIRECTORIES]'
>&2 echo ' -c,--caller=caller name of caller to put into comment of CACHEDIR.TAG'
>&2 echo \
'#HELPTEXT# #'
exit 1
}
eval set -- "$(getopt -o c: --long caller:,help,version -n "$(basename "$0")" -- "$@" || echo verwendung)"
caller="$(ps -o comm= $PPID)"
while true
do
case "$1" in
-c|--caller)
shift
caller="$1"
;;
--help)
verwendung 0
;;
--version)
echo '#VERSION#'
exit 0
;;
--)
shift
break
;;
*)
>&2 echo "FEHLER: Verstehe Option \"$1\" doch nicht! Ich beende."
verwendung
;;
esac
shift
done
if [ $# -eq 0 ]
then
>&2 echo 'No directories given - was this intented?'
verwendung
fi
for dir in "$@"
do
if [ ! -d "${dir}" ]
then
>&2 echo "Argument '${dir}' is not a directory."
verwendung
fi
done
for dir in "$@"
do
(
echo -n 'Signature: '
echo -n '.IsCacheDirectory' | \
md5sum - | \
cut -d ' ' -f 1
echo '# This file is a cache directory tag created by '"$(basename "$0")"' for '"${caller}"'.'
echo '# For information about cache directory tags, see:'
echo '# http://www.brynosaurus.com/cachedir/'
) > "${dir}/CACHEDIR.TAG"
(
echo '+ .rsync-filter'
echo '- *'
) > "${dir}/.rsync-filter"
touch "${dir}/.nobackup"
done
|