blob: 5b46a8ef9887f8a5ba2aa41c287e8b7c62cce6a9 (
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
#!/bin/bash
# parameters
MIRROR_DIR="/srv/http/mirror/mirror.archlinux32.org"
ARCHIVE_DIR="/srv/http/mirror/archive.archlinux32.org/iso"
usage() {
>&2 echo ""
>&2 echo "cleanup-isos: cleanup mirror and archive ISOs of Archlinux32"
>&2 echo ""
>&2 echo "possible options:"
>&2 echo " -h|--help: show this help and exit."
>&2 echo " --mirror-dir where are the ISOs stored on the mirror, default is '$MIRROR_DIR'."
>&2 echo " --archive-dir where are the ISOs stored in the archive, default is '$ARCHIVE_DIR'."
>&2 echo " -n do not do anything, just print what would be done."
[ -z "$1" ] && exit 1 || exit "$1"
}
# fail on first error
set -e
# cleanup hook
tmp_dir="$(mktemp -d)"
cleanup() {
rm -rf --one-file-system "${tmp_dir}"
}
trap cleanup EXIT
eval set -- "$(
getopt -o hn \
--long help \
--long mirror-dir: \
--long archive-dir: \
-n "$(basename "$0")" -- "$@" || \
echo usage
)"
mirror_dir="${MIRROR_DIR}"
archive_dir="${ARCHIVE_DIR}"
do_it=1
while [ $# -gt 0 ]; do
case "$1" in
'--mirror-dir')
shift
mirror_dir="$1"
;;
'--archive-dir')
shift
archive_dir="$1"
;;
'-n')
do_it=0
;;
'--help'|'-h')
usage 0
;;
'--')
shift
break
;;
*)
printf 'Whoops, option "%s" is not yet implemented!\n' "$1" >&2
exit 42
;;
esac
shift
done
if [ $# -gt 0 ]; then
>&2 echo 'Too many arguments.'
exit 2
fi
echo "checking for old isos in '${mirror_dir}'..."
exit 0
#--TODO FROM HERE
find "${destination}" \( -name 'archlinux32-*' -o -name 'archlinux-*' \) -not -name 'archlinux32-'"${date}"'-*' \
| while read -r to_delete; do
if diff -q "${to_delete}" "${archive}/iso/${to_delete#${destination}/}" >/dev/null; then
rm "${to_delete}"
printf '%s\n' "${to_delete}" \
| sed '
s@^.*/@@
s/\./\\./g
s@.*@/ \0$/d@
'
fi
done \
>> "${tmp_dir}/delete-regex"
sed -i -f "${tmp_dir}/delete-regex" "${destination}/sha512sums"
sed -i -f "${tmp_dir}/delete-regex" "${destination}/md5sums"
echo '... done.'
;;
|