Ignore:
Timestamp:
Apr 12, 2016, 4:58:03 PM (9 years ago)
Author:
joergs
Message:

make mirror script more flexible.

Use configuration files and helper scripts.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.