Changeset 1210 for dass-tools


Ignore:
Timestamp:
04/12/16 16:58:03 (6 years ago)
Author:
joergs
Message:

make mirror script more flexible.

Use configuration files and helper scripts.

Location:
dass-tools
Files:
3 added
4 edited

Legend:

Unmodified
Added
Removed
  • dass-tools/dass-tools.spec

    r1193 r1210  
    11#
    2 # Copyright  (c)  2012-2015  dass IT GmbH, Koeln, Germany.
     2# Copyright  (c)  2012-2016  dass IT GmbH, Koeln, Germany.
    33# This file and all modifications and additions to the pristine
    44# package are under the same license as the package itself.
     
    4040
    4141%install
     42mkdir -p $RPM_BUILD_ROOT/etc/
     43install -m 644 etc/profile.d/*.conf $RPM_BUILD_ROOT/etc/
    4244mkdir -p $RPM_BUILD_ROOT/etc/profile.d/
    4345install -m 644 etc/profile.d/*.sh $RPM_BUILD_ROOT/etc/profile.d/
     
    5759%files
    5860%defattr(-,root,root)
     61/etc/mirror-*.conf
    5962/etc/profile.d/*
    6063/usr/bin/*
    6164/usr/sbin/*
    62 
  • dass-tools/debian/install

    r1199 r1210  
     1/etc/mirror-*.conf
    12/etc/profile.d/*.sh
    23/usr/bin/*.sh
  • dass-tools/usr/bin/mirror-obs.sh

    r1093 r1210  
    11#!/bin/bash
    22
    3 SOURCE_OPENSUSE="ftp5.gwdg.de::pub/opensuse/"
     3set -o errexit -o nounset
    44
    5 REPOS="repositories/home:/dassit
    6 "
     5CONFIG=${1:-/etc/mirror-obs.conf}
    76
    8 #
    9 # disabled repos:
    10 #
    11 #distribution/11.2/repo update/11.2 distribution/12.1/repo update/12.1
     7if ! [ -r "$CONFIG" ]; then
     8  echo "failed to read config file $CONFIG."
     9  exit 1
     10fi
     11source $CONFIG
    1212
    1313RSYNC_DELETE="--delete"
    14 
    15 #RSYNC_OPTS="-v -rlLptx --safe-links --stats \
    16 #        --exclude=*.src.rpm --exclude=*.nosrc.rpm --exclude=*.spm \
    17 #        --exclude=*.patch.rpm"
    18 
    19 RSYNC_OPTS="-v -rlLptx --safe-links --stats"
    20 
    21 DEST="/space/installtree/install/download.opensuse.org"
     14RSYNC_OPTS="-v -rlLptx --safe-links --stats $RSYNC_EXTRA_OPTS"
    2215
    2316rsync_if_exists()
    2417{
    25         src=$1
    26         dest=$2
     18    src=$1
     19    dest=$2
    2720
    28         rsync -q $src || return 1
    29         echo rsync-quelle $src gefunden.
    30         [ -d "$dest" ] || return 2
    31         rsync $RSYNC_OPTS $RSYNC_DELETE $src ./$dest
     21    rsync -q $src || return 1
     22    echo "found rsync source: $src"
     23    [ -d "$dest" ] || return 2
     24    rsync $RSYNC_OPTS $RSYNC_DELETE $src $dest
    3225}
    3326
    3427# ---------------- mirror openSUSE repositories ------------------------
    35 FAILED_REPOS=""
    36 SUCCESSFUL=""
     28FAILED=""
     29SUCCESS=""
     30
    3731
    3832cd $DEST
    3933
    40 for DIR in $REPOS
    41 do
     34for DIR in $REPOS; do
    4235  SOURCE_DIR=${SOURCE_OPENSUSE}/${DIR}/.
    4336  DEST_DIR=${DEST}/${DIR}/.
    4437  mkdir -p ${DEST_DIR}
    45   rsync_if_exists  "${SOURCE_OPENSUSE}$DIR/" "$DIR"
    46   case $? in
    47         1)      echo Distribution $DIR nicht gefunden
    48                 FAILED_REPOS="$FAILED_REPOS $DIR"
    49                 ;;
    50         2)      echo Zielverzeichnis $(pwd)/$DIR nicht vorhanden
    51                 FAILED_REPOS="$FAILED_REPOS $DIR"
    52                 ;;
    53         0)
    54                 SUCCESSFUL="$SUCCESSFUL $DIR"
    55                 ;;
    56         *)
    57                 echo Fehler $?
    58                 FAILED_REPOS="$FAILED_REPOS $DIR"
    59                 ;;
     38  rc=0
     39  rsync_if_exists  "${SOURCE_DIR}" "${DEST_DIR}" || rc=$?
     40  case $rc in
     41    1)  echo Distribution $DIR nicht gefunden
     42        FAILED="$FAILED $DIR"
     43        ;;
     44    2)  echo Zielverzeichnis ${DEST_DIR} nicht vorhanden
     45        FAILED="$FAILED $DIR"
     46        ;;
     47    0)
     48        SUCCESS="$SUCCESS $DIR"
     49        if [ "${POST_SCRIPT:-}" ]; then
     50            $POST_SCRIPT ${DEST_DIR}
     51        fi
     52        ;;
     53    *)
     54        echo Fehler $?
     55        FAILED="$FAILED $DIR"
     56        ;;
    6057  esac
     58  echo
     59  echo
    6160done
    6261
    63 # /usr/local/sbin/mirror-report-errors.sh mirror-osb "$SUCCESSFUL" "$FAILED_REPOS"
    64 #
    65 # # adapt repository sources
    66 # for i in `find $DEST/repositories -name "*.repo" -a ! -name "vermkv-*.repo"`; do
    67 #       basename=`basename $i`
    68 #       dirname=`dirname $i`
    69 #         sed "s|http://|http://install.vermkv/freigabe/|" $i > $dirname/vermkv-$basename
    70 # done
    71 
     62if [ "${REPORT_SCRIPT:-}" ]; then
     63    $REPORT_SCRIPT mirror-urls "$SUCCESS" "$FAILED"
     64fi
  • dass-tools/usr/bin/mirror-urls.sh

    r1091 r1210  
    11#!/bin/bash
    22
    3 export http_proxy=http://proxy:3128
    4 export ftp_proxy=http://proxy:3128
     3set -o errexit -o nounset
    54
    6 NSCA_CMD="/usr/local/bin/nagios_send_nsca.sh"
     5CONFIG=${1:-/etc/mirror-urls.conf}
    76
    8 PROJECTS="
    9 http://download.videolan.org/pub/vlc/SuSE/11.2/
    10 http://download.videolan.org/pub/vlc/SuSE/12.1/
    11 "
     7# default value, may be overwritten by CONFIG
     8DEST="/cds/linux/mirror/"
    129
    13 # TODO:
    14 # not working, because dir listings are forbidden
    15 # http://download.nvidia.com/opensuse/11.2/
    16 # (with hftp://download.nvidia.com/opensuse/11.2/ directory listings are possible,
    17 #  but file access in denied)
     10if ! [ -r "$CONFIG" ]; then
     11  echo "failed to read config file $CONFIG."
     12  exit 1
     13fi
     14source $CONFIG
    1815
    19 SUCCESSFUL=""
    2016FAILED=""
    21 
    22 DEST="/anlagen/vmlxlamp/repo/"
     17SUCCESS=""
    2318
    2419cd $DEST
    2520
    26 
    2721for url in $PROJECTS; do
    28   echo $url
    29   protocol=`sed -r "s|^([a-zA-Z]+)://.*|\1|" <<< $url`
    30   host=`sed -r "s|^$protocol://([^/]+)/.*|\1|" <<< $url`
    31   path=`sed -r "s|$protocol://$host||" <<< $url`
    32   mkdir -p $host/$path
    33   set -x
    34   if ! lftp -c "open -e \"mirror --verbose=1 --continue --delete $path/. $DEST/$host/$path\" ${protocol}://${host}"; then
    35         FAILED="$FAILED $url"
    36   else
    37         SUCCESS="$SUCCESS $url"
    38   fi
    39   set +x
     22    printf "$url:\n"
     23    protocol=`sed -r "s|^([a-zA-Z]+)://.*|\1|" <<< $url`
     24    host=`sed -r "s|^$protocol://([^/]+)/.*|\1|" <<< $url`
     25    path=`sed -r "s|$protocol://$host||" <<< $url`
     26    mkdir -p $host/$path
     27    DESTDIR=$DEST/$host/$path
     28    #set -x
     29    if ! lftp -c "open -e \"mirror --verbose=1 --parallel=20 --continue --delete $path/. ${DESTDIR}\" ${protocol}://${host}"; then
     30        set +x
     31        printf "    failed\n"
     32        FAILED="$FAILED $url"
     33    else
     34        set +x
     35        if [ "${POST_SCRIPT:-}" ]; then
     36            $POST_SCRIPT ${DESTDIR}
     37        fi
     38        printf "    ${DESTDIR}\n"
     39        SUCCESS="$SUCCESS $url"
     40    fi
     41    printf "\n"
    4042done
    4143
    42 # adapt repository sources
    43 for i in `find $DEST -name "*.repo" -a ! -name "vermkv-*.repo"`; do
    44         basename=`basename $i`
    45         dirname=`dirname $i`
    46         sed "s|http://|http://install.vermkv/freigabe/|" $i > $dirname/vermkv-$basename
    47 done
    48 
    49 /usr/local/sbin/mirror-report-errors.sh mirror-urls "$SUCCESS" "$FAILED"
     44if [ "${REPORT_SCRIPT:-}" ]; then
     45    $REPORT_SCRIPT mirror-urls "$SUCCESS" "$FAILED"
     46fi
Note: See TracChangeset for help on using the changeset viewer.