#!/bin/bash # # SPDX-License-Identifier: Apache-2.0 # # Update script for mirror.starlingx.cengn.ca covering # tarballs and other files not downloaded from a yum repository. # The list of files to download are pulled from the .lst files # found in the stx-tools repo. # # IMPORTANT: This script is only to be run on the StarlingX mirror. # It is not for use by the general StarlinX developer. # # This script was originated by Scott Little. # DAILY_DL_SYNC_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}" )" )" LOGFILE=/export/log/daily_dl_sync.log DOWNLOAD_PATH_ROOT=/export/mirror/centos STX_TOOLS_BRANCH="master" STX_TOOLS_BRANCH_ROOT_DIR="$HOME/stx-tools" STX_TOOLS_OS_SUBDIR="centos-mirror-tools" if [ -f "$DAILY_DL_SYNC_DIR/stx_tool_utils.sh" ]; then source "$DAILY_DL_SYNC_DIR/stx_tool_utils.sh" elif [ -f "$DAILY_DL_SYNC_DIR/../stx_tool_utils.sh" ]; then source "$DAILY_DL_SYNC_DIR/../stx_tool_utils.sh" else echo "Error: Can't find 'stx_tool_utils.sh'" exit 1 fi usage () { echo "$0 [-b ] [-d ]" echo "" echo "Options:" echo " -b: Use an alternate branch of stx-tools. Default is 'master'." echo " -d: Directory where we will clone stx-tools. Default is \$HOME." echo "" } while getopts "b:d:h" opt; do case "${opt}" in b) # branch STX_TOOLS_BRANCH="${OPTARG}" if [ $"STX_TOOLS_BRANCH" == "" ]; then usage exit 1 fi ;; d) # download directory for stx-tools STX_TOOLS_BRANCH_ROOT_DIR="${OPTARG}" if [ "$STX_TOOLS_BRANCH_ROOT_DIR" == "" ]; then usage exit 1 fi ;; h) # Help usage exit 0 ;; *) usage exit 1 ;; esac done STX_TOOLS_DL_ROOT_DIR="$STX_TOOLS_BRANCH_ROOT_DIR/$STX_TOOLS_BRANCH" STX_TOOLS_DL_DIR="$STX_TOOLS_DL_ROOT_DIR/stx-tools" LST_FILE_DIR="$STX_TOOLS_DL_DIR/$STX_TOOLS_OS_SUBDIR" raw_dl_from_rpm_lst () { local FILE="$1" local RPM="" local URL="" local ERROR_COUNT=0 # Expected format # grep -v '^#' $FILE | while IFS='#' read -r RPM URL; do echo "Processing: RPM=$RPM URL=$URL" dl_file_from_url "$URL" ERR_COUNT=$((ERR_COUNT+$?)) done return $ERR_COUNT } raw_dl_from_non_rpm_lst () { local FILE="$1" local TAR="" local URL="" local METHOD="" local UTIL="" local SCRIPT="" local BRANCH="" local SUBDIRS_FILE="" local TARBALL_NAME="" local ERROR_COUNT=0 # Expected format ## # or !####[]#[