source: dass-tools/usr/bin/reposync-add-repo.sh@ 1220

Last change on this file since 1220 was 1215, checked in by joergs, on Aug 23, 2016 at 1:42:37 PM

/etc/dass-it/ directory

  • Property svn:executable set to *
File size: 1.2 KB
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
7set -o errexit -o nounset
8
9if [ -r /etc/dass-it/reposync.conf ]; then
10 source /etc/dass-it/reposync.conf
11fi
12
13usage()
14{
15 printf "
16usage: $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
25check_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
35REPO_FILE_URL=${1:-}
36STARTDIR=${2:-$DEST}
37
38if ! [ -d $STARTDIR ]; then
39 echo "FAILED: $STARTDIR is not a valid directory."
40 usage
41 exit 1
42fi
43
44if ! check_url "$REPO_FILE_URL"; then
45 echo "FAILED: url \"$REPO_FILE_URL\" not accessable."
46 usage
47 exit 1
48fi
49
50REPO_FILE=`sed "s|http://|$STARTDIR/|" <<< "$REPO_FILE_URL"`
51mkdir -p `dirname $REPO_FILE`
52curl --silent $REPO_FILE_URL -o $REPO_FILE
53
54mirror-adapt-repository.sh "$REPO_FILE"
Note: See TracBrowser for help on using the repository browser.