Line | |
---|
1 | #!/bin/bash
|
---|
2 |
|
---|
3 | # because the normal mirroring tools often can't access current data
|
---|
4 | # this scripts updates the local repositories using:
|
---|
5 | # reposync + createrepo
|
---|
6 |
|
---|
7 | set -o errexit -o nounset
|
---|
8 |
|
---|
9 | DEST=""
|
---|
10 | if [ -r /etc/dass-it/reposync.conf ]; then
|
---|
11 | source /etc/dass-it/reposync.conf
|
---|
12 | fi
|
---|
13 |
|
---|
14 | usage()
|
---|
15 | {
|
---|
16 | printf "
|
---|
17 | usage: $0 REPO_FILE_URL [<DIRECTORY>]
|
---|
18 |
|
---|
19 | $0 will download REPO_FILE_URL to a subdirectory of [DIRECTORY] (default: $DEST).
|
---|
20 | It creates the repository structure, so that
|
---|
21 | reposync-mirror-update.sh will be able to download the repository.
|
---|
22 |
|
---|
23 | "
|
---|
24 | }
|
---|
25 |
|
---|
26 | check_url()
|
---|
27 | {
|
---|
28 | local URL="$1"
|
---|
29 | [ -z "$1" ] && return 1
|
---|
30 | local CODE=`curl --location --write-out %{http_code} --silent --output /dev/null -- "$URL"`
|
---|
31 | printf " %s: %s\n" "$URL" "$CODE"
|
---|
32 | test "$CODE" = "200"
|
---|
33 | return $?
|
---|
34 | }
|
---|
35 |
|
---|
36 | REPO_FILE_URL=${1:-}
|
---|
37 | STARTDIR=${2:-$DEST}
|
---|
38 |
|
---|
39 | if [[ $REPO_FILE_URL == -* ]]; then
|
---|
40 | usage
|
---|
41 | exit 0
|
---|
42 | fi
|
---|
43 |
|
---|
44 | if ! [ -d "$STARTDIR" ]; then
|
---|
45 | echo "FAILED: $STARTDIR is not a valid directory."
|
---|
46 | usage
|
---|
47 | exit 1
|
---|
48 | fi
|
---|
49 |
|
---|
50 | if ! check_url "$REPO_FILE_URL"; then
|
---|
51 | echo "FAILED: url \"$REPO_FILE_URL\" not accessable."
|
---|
52 | usage
|
---|
53 | exit 1
|
---|
54 | fi
|
---|
55 |
|
---|
56 | REPO_FILE=`sed "s|http://|$STARTDIR/|" <<< "$REPO_FILE_URL"`
|
---|
57 | mkdir -p `dirname $REPO_FILE`
|
---|
58 | curl --silent $REPO_FILE_URL -o $REPO_FILE
|
---|
59 |
|
---|
60 | mirror-adapt-repository.sh "$REPO_FILE"
|
---|
Note:
See
TracBrowser
for help on using the repository browser.