source: dass-tools/usr/bin/reposync-mirror-update.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: 2.3 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 [directory]
17
18 $0 will scan all subdirectories for repository (*.repo files),
19 download the missing packages,
20 recreate a repository
21 and sign it.
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
36STARTDIR=${1:-.}
37
38if ! [ -d $STARTDIR ]; then
39 echo "FAILED: $STARTDIR is not a valid directory"
40 usage
41 exit 1
42fi
43
44cd $STARTDIR
45
46ME=reposync-mirror-update
47TMPDIR=/tmp/reposync.cache/
48
49REPO_FILES=`find -name "*.repo" ! -name "vermkv-*" | sort`
50
51mkdir -p $TMPDIR
52for REPO_FILE in $REPO_FILES; do
53 NAME=`sed --quiet -r 's/^\[(.*)\]/\1/p' $REPO_FILE`
54 URL=`sed --quiet -r 's/^baseurl=(.*)/\1/ip' $REPO_FILE`
55 DIR=`dirname $REPO_FILE`
56
57 echo
58 echo
59 echo "$ME: $NAME: reposync of $DIR"
60 echo
61
62 if ! check_url "$URL"; then
63 echo " SKIPPED: url not accessable"
64 else
65
66 # reposync stores in a directory named identical as the name of the repo
67 test -L $NAME && rm $NAME
68 if test -x $NAME; then
69 echo "FAILED: remove $NAME and try again"
70 exit 1
71 fi
72
73 ln -s $DIR $NAME
74 CACHEDIR=`mktemp --directory --tmpdir=$TMPDIR`
75 if reposync --config $REPO_FILE --cachedir=$CACHEDIR --delete | grep "Downloading\|Removing"; then
76
77 test -L $NAME && rm $NAME
78
79 echo
80 echo "$ME: $NAME: createrepo"
81 createrepo --cachedir .repocache/ $DIR
82
83 echo
84 echo "$ME: $NAME: signing"
85 rm -f $DIR/repodata/repomd.xml.asc $DIR/repodata/repomd.xml.key
86 if [ "$REPOSYNC_GPG_KEY" -a "$REPOSYNC_GPG_PASSPHRASE" ]; then
87 gpg --batch --passphrase "$REPOSYNC_GPG_PASSPHRASE" -a --detach-sign --default-key "$REPOSYNC_GPG_KEY" $DIR/repodata/repomd.xml
88 gpg --batch --passphrase "$REPOSYNC_GPG_KEY" -a --export "$REPOSYNC_GPG_KEY" > $DIR/repodata/repomd.xml.key
89 fi
90 fi
91 test -L $NAME && rm $NAME
92 sleep 1
93
94 fi
95
96done
97
98rm -r $TMPDIR
99
100echo
101echo "$ME: done"
Note: See TracBrowser for help on using the repository browser.