From 2ba87088c3842e092e5fb9d638bfc671f39233a2 Mon Sep 17 00:00:00 2001 From: GONG Jie Date: Mon, 11 Jul 2016 13:57:48 +0800 Subject: [PATCH 1/2] [go-xcat] Use a different user-agent for wget --- xCAT-server/share/xcat/tools/go-xcat | 30 +++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/xCAT-server/share/xcat/tools/go-xcat b/xCAT-server/share/xcat/tools/go-xcat index 8c43440bf..ec0b52bf4 100755 --- a/xCAT-server/share/xcat/tools/go-xcat +++ b/xCAT-server/share/xcat/tools/go-xcat @@ -2,7 +2,7 @@ # # go-xcat - Install xCAT automatically. # -# Version 1.0.0 +# Version 1.0.1 # # Copyright (C) 2016 International Business Machines # Eclipse Public License, Version 1.0 (EPL-1.0) @@ -17,15 +17,10 @@ function usage() { local script="${0##*/}" + local version="$(version)" while read -r ; do echo "${REPLY}" ; done <<-EOF - ${script} version $( - for i in {0..9} - do - read -r - [[ ${REPLY} =~ \#\ +[Vv]ersion ]] && echo "${REPLY##* }" - done <"$0" - ) + ${script} version ${version} Usage: ${script} [OPTION]... [ACTION] Install xCAT automatically @@ -82,6 +77,20 @@ function usage() EOF } +# +# version Print out the version number. +# +function version() +{ + # Read the first ten lines of this script + for i in {0..9} + do + read -r + [[ ${REPLY} =~ \#\ +[Vv]ersion ]] && echo "${REPLY##* }" && return 0 + done <"$0" + return 1 +} + GO_XCAT_DEFAULT_BASE_URL="http://xcat.org/files/xcat/repos" GO_XCAT_DEFAULT_INSTALL_PATH="/install/xcat" @@ -573,10 +582,13 @@ function get_package_list() function download_file() { + local script="${0##*/}" + local version="$(version)" + local user_agent="${script}/${version} (${GO_XCAT_OS}; ${GO_XCAT_ARCH}; ${GO_XCAT_LINUX_DISTRO} ${GO_XCAT_LINUX_VERSION})" type wget >/dev/null 2>&1 || return 255 local url="$1" local local_file="$2" - wget -q "${url}" -O "${local_file}" + wget -U "${user_agent}" -q "${url}" -O "${local_file}" } # $1 repo file From 123f9bc400677696a9a2571e3642d12fb7c5281e Mon Sep 17 00:00:00 2001 From: GONG Jie Date: Mon, 11 Jul 2016 14:08:13 +0800 Subject: [PATCH 2/2] [go-xcat] Print out more error messages when reading repository failed. --- xCAT-server/share/xcat/tools/go-xcat | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/xCAT-server/share/xcat/tools/go-xcat b/xCAT-server/share/xcat/tools/go-xcat index ec0b52bf4..0f17c7aa5 100755 --- a/xCAT-server/share/xcat/tools/go-xcat +++ b/xCAT-server/share/xcat/tools/go-xcat @@ -1035,25 +1035,25 @@ function add_xcat_dep_repo() function update_repo_dnf() { type dnf >/dev/null 2>&1 || return 255 - dnf --nogpgcheck updateinfo /dev/null 2>&1 + dnf --nogpgcheck updateinfo } function update_repo_yum() { type yum >/dev/null 2>&1 || return 255 - yum --nogpgcheck updateinfo /dev/null 2>&1 + yum --nogpgcheck updateinfo } function update_repo_zypper() { type zypper >/dev/null 2>&1 || return 255 - zypper --gpg-auto-import-keys refresh /dev/null 2>&1 + zypper --gpg-auto-import-keys refresh } function update_repo_apt() { type apt-get >/dev/null 2>&1 || return 255 - apt-get update /dev/null 2>&1 + apt-get --allow-unauthenticated update } function update_repo() @@ -1090,7 +1090,7 @@ function install_packages_apt() type apt-get >/dev/null 2>&1 || return 255 local -a args=() [[ "$1" = "-y" ]] && args=("-y") && shift - apt-get install "${args[@]}" "$@" + apt-get --allow-unauthenticated install "${args[@]}" "$@" } function install_packages()