Brian Freeman | 48d3054 | 2019-08-20 13:13:58 -0500 | [diff] [blame^] | 1 | #!/bin/bash |
| 2 | |
| 3 | |
| 4 | if [ "$#" -ne 1 ]; then |
| 5 | echo "$0 <repo>" |
| 6 | echo " where <repo> is releases or staging" |
| 7 | exit 1 |
| 8 | fi |
| 9 | |
| 10 | set -x |
| 11 | REPO=$1 |
| 12 | |
| 13 | LOG_DIR=/var/www/html/logs/mirror-nexus/$REPO/ |
| 14 | mkdir -p $LOG_DIR |
| 15 | |
| 16 | LOG_FILE=$LOG_DIR/$(date +%FT%TZ).log |
| 17 | TAR_FILE=$REPO-$(date +%F).tar |
| 18 | |
| 19 | MIRRORS_DIR=/var/www/html/mirrors/nexus.onap.org |
| 20 | REPO_DIR=$MIRRORS_DIR/$REPO |
| 21 | mkdir -p $REPO_DIR |
| 22 | cd $REPO_DIR |
| 23 | |
| 24 | wget -nv --mirror --random-wait --no-if-modified-since --no-parent -e robots=off --reject "index.html*" -nH --cut-dirs=3 "https://nexus.onap.org/content/repositories/$REPO/" -o /dev/stdout | sed -u "s|URL:https://nexus.onap.org/content/repositories/$REPO/||g" | sed -u 's| ->.*||g' > $LOG_FILE |
| 25 | |
| 26 | cd $MIRRORS_DIR |
| 27 | tar cvf $TAR_FILE.part $REPO/ |
| 28 | mv -b $TAR_FILE.part $TAR_FILE |