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

Last change on this file since 1259 was 1238, checked in by joergs, on Feb 27, 2018 at 11:52:09 AM

reposync-add-repo.sh: allow URLs with http and https

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