Rev | Line | |
---|
[1214] | 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 |
|
---|
[1215] | 9 | if [ -r /etc/dass-it/reposync.conf ]; then
|
---|
| 10 | source /etc/dass-it/reposync.conf
|
---|
[1214] | 11 | fi
|
---|
| 12 |
|
---|
| 13 | usage()
|
---|
| 14 | {
|
---|
| 15 | printf "
|
---|
| 16 | usage: $0 REPO_FILE_URL [<DIRECTORY>]
|
---|
| 17 |
|
---|
| 18 | $0 will download REPO_FILE_URL to a subdirectory of [DIRECTORY] (default: $DEST).
|
---|
| 19 | It creates the repository structure, so that
|
---|
| 20 | reposync-mirror-update.sh will be able to download the repository.
|
---|
| 21 |
|
---|
| 22 | "
|
---|
| 23 | }
|
---|
| 24 |
|
---|
| 25 | check_url()
|
---|
| 26 | {
|
---|
| 27 | local URL="$1"
|
---|
| 28 | [ -z "$1" ] && return 1
|
---|
| 29 | local CODE=`curl --location --write-out %{http_code} --silent --output /dev/null "$URL"`
|
---|
| 30 | printf " %s: %s\n" "$URL" "$CODE"
|
---|
| 31 | test "$CODE" = "200"
|
---|
| 32 | return $?
|
---|
| 33 | }
|
---|
| 34 |
|
---|
| 35 | REPO_FILE_URL=${1:-}
|
---|
| 36 | STARTDIR=${2:-$DEST}
|
---|
| 37 |
|
---|
| 38 | if ! [ -d $STARTDIR ]; then
|
---|
| 39 | echo "FAILED: $STARTDIR is not a valid directory."
|
---|
| 40 | usage
|
---|
| 41 | exit 1
|
---|
| 42 | fi
|
---|
| 43 |
|
---|
| 44 | if ! check_url "$REPO_FILE_URL"; then
|
---|
| 45 | echo "FAILED: url \"$REPO_FILE_URL\" not accessable."
|
---|
| 46 | usage
|
---|
| 47 | exit 1
|
---|
| 48 | fi
|
---|
| 49 |
|
---|
| 50 | REPO_FILE=`sed "s|http://|$STARTDIR/|" <<< "$REPO_FILE_URL"`
|
---|
| 51 | mkdir -p `dirname $REPO_FILE`
|
---|
| 52 | curl --silent $REPO_FILE_URL -o $REPO_FILE
|
---|
| 53 |
|
---|
| 54 | mirror-adapt-repository.sh "$REPO_FILE"
|
---|
Note:
See
TracBrowser
for help on using the repository browser.